From: Srijit Kumar Bhadra on
Hello,
I have posted a similar message in microsoft.public.win32.programmer.

I am looking for a simple example with CreateSharedMemory API using
Visual C++ 7.1.

Thanks.

Best Regards,
/Srijit

From: Tim Robinson on
"Srijit Kumar Bhadra" <srijit(a)yahoo.com> wrote in message
news:1110999073.780277.231630(a)l41g2000cwc.googlegroups.com...
> Hello,
> I have posted a similar message in microsoft.public.win32.programmer.
>
> I am looking for a simple example with CreateSharedMemory API using
> Visual C++ 7.1.

Are you sure this is the function you want?

From MSDN:
"The CreateSharedMemory function creates a section of memory that is shared
by client processes and the **security package***."

Note the emphasis on ***security package*** -- this is part of the security
API, not a general-purpose function.

If you want to create a block of memory that's shared between arbitrary
processes, you need to do the following:

1. Call CreateFileMapping to return a handle to a file mapping object
2. Call MapViewOfFile on the file mapping object to return a pointer
3. Use the pointer returned by MapViewOfFile
4. Call UnmapViewOfFile on the pointer
5. Call CloseHandle on the file mapping object

MSDN has an example linked from the CreateFileMapping page.

--
Tim Robinson
MVP, Windows SDK


From: Srijit Kumar Bhadra on
Hello,
Thanks for your reply. As rightly mentioned by you, I wanted to create
a block of memory that is shared between arbitrary processes.
I have found CreateFileMapping example, as suggested by you.

I am curious to know about an example where CreateSharedMemory function
is used.

Best Regards,
/Srijit