473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

ATS
HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

Please help,

I have a UserControl that I want to have "talk" to a C++/MFC/EXE program
that is already running via a memory map.

The C++/MFC/EXE app is using the traditional WIN32 commands like

OpenFileMapping
MapViewOfFile
UnmapViewOfFile

And others.

Put another way, the C++/MFC/EXE is using plain/jain Memory Map Techniques,
where the memory map has a "known" name, and any application can access the
memory map in the same "Desktop".

I am not sure which C#/.NET functionality I should use. I see the
MemoryStream class, but I see no reference to it being "compatible" to Memory
Maps.

Please advise.
Nov 17 '05 #1
7 5826
ATS,

The MemoryStream class is just a class that will allow you to get
stream-semantics while using a byte array as the back-end store. It has
nothing to do with memory maps.

If you want to use memory maps, you will have to make a call to the same
API calls through the P/Invoke layer.

You could wrap it up in a Stream-based class if you want, and then
read/write back and forth.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ATS" <AT*@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com...
HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

Please help,

I have a UserControl that I want to have "talk" to a C++/MFC/EXE program
that is already running via a memory map.

The C++/MFC/EXE app is using the traditional WIN32 commands like

OpenFileMapping
MapViewOfFile
UnmapViewOfFile

And others.

Put another way, the C++/MFC/EXE is using plain/jain Memory Map
Techniques,
where the memory map has a "known" name, and any application can access
the
memory map in the same "Desktop".

I am not sure which C#/.NET functionality I should use. I see the
MemoryStream class, but I see no reference to it being "compatible" to
Memory
Maps.

Please advise.

Nov 17 '05 #2
ATS
Thanks Nicholas for the reply,

So, there is no .NET/C# equivalent for Memory Maps at all?
Nov 17 '05 #3
ATS,

No, there is not.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ATS" <AT*@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Thanks Nicholas for the reply,

So, there is no .NET/C# equivalent for Memory Maps at all?

Nov 17 '05 #4
I put together a caching mechanism using memory-mapped files and had the
opportunity to try out three or four different implementations in .NET. The
best and most reliable one I found was a freeware offering called
"MetalWrench ToolBox", which is unfortunately no longer "findable" on the
net. However, there is a copy of it in the download that accompanies this
article that I wrote about it:

http://www.eggheadcafe.com/articles/20050116.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ATS" wrote:
HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

Please help,

I have a UserControl that I want to have "talk" to a C++/MFC/EXE program
that is already running via a memory map.

The C++/MFC/EXE app is using the traditional WIN32 commands like

OpenFileMapping
MapViewOfFile
UnmapViewOfFile

And others.

Put another way, the C++/MFC/EXE is using plain/jain Memory Map Techniques,
where the memory map has a "known" name, and any application can access the
memory map in the same "Desktop".

I am not sure which C#/.NET functionality I should use. I see the
MemoryStream class, but I see no reference to it being "compatible" to Memory
Maps.

Please advise.

Nov 17 '05 #5
ATS
Thanks for the reply,

That is a big dissapointment that .NET does not support Memory Mapped Files.
The excuse of scrapping all code features for the cause of "managed code" is
obviously the reasoning behind not supporting Memory Mapped Files, and it is
a poor excuse. Interprocess communnication with Memory Map Files is a valid
and highly needed software development technique.
Nov 17 '05 #6
There are lots of Windows API's that aren't built in to the .NET platform.
That's what the P/Invoke layer is for.
Cheers,
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ATS" wrote:
HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

Please help,

I have a UserControl that I want to have "talk" to a C++/MFC/EXE program
that is already running via a memory map.

The C++/MFC/EXE app is using the traditional WIN32 commands like

OpenFileMapping
MapViewOfFile
UnmapViewOfFile

And others.

Put another way, the C++/MFC/EXE is using plain/jain Memory Map Techniques,
where the memory map has a "known" name, and any application can access the
memory map in the same "Desktop".

I am not sure which C#/.NET functionality I should use. I see the
MemoryStream class, but I see no reference to it being "compatible" to Memory
Maps.

Please advise.

Nov 17 '05 #7
ATS,

Actually, I wouldn't think that is the case. I think security is a
bigger reason why there are no memory mapped file implementations.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ATS" <AT*@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
Thanks for the reply,

That is a big dissapointment that .NET does not support Memory Mapped
Files.
The excuse of scrapping all code features for the cause of "managed code"
is
obviously the reasoning behind not supporting Memory Mapped Files, and it
is
a poor excuse. Interprocess communnication with Memory Map Files is a
valid
and highly needed software development technique.

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Josef Sachs | last post by:
Is Andrew Kuchling's regex-to-re HOWTO available anywhere? I've found the following (dead) links on various Web pages: http://py-howto.sourceforge.net/regex-to-re/regex-to-re.html...
7
by: Guy Robinson | last post by:
Hello, I have a directory of python scripts that all (should) contain a number of attributes and methods of the same name. I need to import each module, test for these items and unload the...
11
by: CSN | last post by:
Is it possible to iterate over an array in plpgsql? Something like: function insert_stuff (rel_ids int) .... foreach rel_ids as id insert into table (rel_id, val) values (id, 5);
5
by: Brian Reed | last post by:
I have a class that I want to serialize to an XML string. I want the XML to serialize to utf-8 encoding. When I serialize to an XML file, the data looks great. When I try to serialize to a String...
2
by: Allan Ebdrup | last post by:
Hi I have two strings in memory, a XML document and a Schema, I would like a function that takes these two as parameters and returns an errordescription if the XML does not validate and an empty...
0
by: Mark Harrison | last post by:
HOWTO: Integrating Posgresql queries into an event loop. Mark Harrison mh@pixar.com May 27, 2004 Problem ------- The commonly used postgresql APIs will block until completed.
1
by: BStrick | last post by:
I would like to know what may be the "Best" way to approach with problem. I have an application that I created to transfers data dynamically from an unknown source (ie maybe Excel, Access, XML,...
4
by: Bernd Muent | last post by:
Hi together, I made a DLL in the following way (simplified example just to explain what is the problem) using devcpp and gcc compiler on Windows XP: dll.h: #ifndef _DLL_H_ #define _DLL_H_ #if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.