Click here to Skip to main content
15,880,608 members
Articles / Desktop Programming / Win32

How to do CreateFileMapping in a C++ DLL and access it in C#, VB and C++

Rate me:
Please Sign up or sign in to vote.
5.00/5 (8 votes)
10 Mar 2009CPOL 82.6K   2.2K   57  
This is yet another example for memory mapped files. What is cool though is unlike other samples, I have a SetData(TCHAR* Key, TCHAR* value) / GetData(TCHAR* key) pattern here.
��<html>

<head>

<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-16">

</head>

<body>

<pre>

<table width=100% bgcolor=#CFCFE5><tr> <td> <font face=arial size=+3>

Build Log

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>

<h3>Build started: Project: sharedmem, Configuration: Release|Win32</h3>

</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>

Command Lines

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Creating temporary file "c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\RSP00002241562464.rsp" with contents

[

/OUT:&quot;C:\Release\sharedmem.dll&quot; /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:&quot;Release\sharedmem.dll.intermediate.manifest&quot; /MANIFESTUAC:&quot;level='asInvoker' uiAccess='false'&quot; /DEF:&quot;module.def&quot; /DEBUG /PDB:&quot;c:\Release\sharedmem.pdb&quot; /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib


&quot;.\Release\dllmain.obj&quot;


&quot;.\Release\sharedmem.obj&quot;


&quot;.\Release\stdafx.obj&quot;

]

Creating command line "link.exe @"c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\RSP00002241562464.rsp" /NOLOGO /ERRORREPORT:PROMPT"

Creating temporary file "c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\RSP00002541562464.rsp" with contents

[

/outputresource:&quot;..\..\..\..\..\..\Release\sharedmem.dll;#2&quot; /manifest


&quot;.\Release\sharedmem.dll.intermediate.manifest&quot;

]

Creating command line "mt.exe @"c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\RSP00002541562464.rsp" /nologo"

Creating temporary file "c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\BAT00002641562464.bat" with contents

[

@echo Manifest resource last updated at %TIME% on %DATE% &gt; &quot;.\Release\mt.dep&quot;

]

Creating command line """c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\BAT00002641562464.bat"""

</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>

Output Window

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Linking...

   Creating library C:\Release\sharedmem.lib and object C:\Release\sharedmem.exp

Generating code

Finished generating code

Embedding manifest...

</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>

Results

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Build log was saved at "file://c:\Users\Pranav\Documents\Visual Studio 2008\Projects\sharedmem\Release\BuildLog.htm"

sharedmem - 0 error(s), 0 warning(s)

</pre></table><table   width=100% height=20 bgcolor=#CFCFE5><tr><td><font face=arial size=+2>

</font></table></body></html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions