Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

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

, 10 Mar 2009 CPOL
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.
MMF_SetData_GetData.zip
tubelite
bin
Client_CSharp.exe
Client_CSharp.vshost.exe
Client_CSharp.vshost.exe.manifest
Client_VBNET.exe
Client_Win32Console.exe
Client_Win32Console.ilk
SHAREDMEM.dll
SHAREDMEM.exp
SHAREDMEM.ilk
SHAREDMEM.lib
CSharpConsumer
bin
Debug
WindowsFormsApplication1.exe
Properties
Settings.settings
SHAREDMEM
module.def
Release
mt.dep
sharedmem.dll.intermediate.manifest
sharedmem.pch
vc90.idb
sharedmem.vcproj.Pranav-PC.Pranav.user
UnmanagedConsumer
Release
mt.dep
Test1.exe.intermediate.manifest
vc90.idb
Test1.vcproj.Pranav-PC.Pranav.user
VBNETConsumer
bin
My Project
Application.myapp
Settings.settings
��<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)

Share

About the Author

nkrscorpio
Software Developer
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 10 Mar 2009
Article Copyright 2008 by nkrscorpio
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid