Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. IPC: named shared memory

IPC: named shared memory

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
4 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devvvy
    wrote on last edited by
    #1

    can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ?? code fragment would be welcome. and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE?? thanks norm

    D 1 Reply Last reply
    0
    • D devvvy

      can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ?? code fragment would be welcome. and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE?? thanks norm

      D Offline
      D Offline
      Daniel Lohmann
      wrote on last edited by
      #2

      norm wrote: can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ?? CoCreateGuid() will do it :-) norm wrote: and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE?? Yes, this means you have to use some other IPC channel to send the HANDLE to the target process. WM_COPYDATA is one idea, if the first process creates the second one, you could also use handle inheritance. However, a named object is usually the most convinient solution. BTW: I recommend to use not only a GUID for the name, but also a "human readable" part (somthing like My_app_shared_data_63dcc4b9-b122-4337-b897-88f6a7f49f3f). This would make it much easier for you and others to find your section in tools like Process Explorer and other debugging tools. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

      D 1 Reply Last reply
      0
      • D Daniel Lohmann

        norm wrote: can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ?? CoCreateGuid() will do it :-) norm wrote: and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE?? Yes, this means you have to use some other IPC channel to send the HANDLE to the target process. WM_COPYDATA is one idea, if the first process creates the second one, you could also use handle inheritance. However, a named object is usually the most convinient solution. BTW: I recommend to use not only a GUID for the name, but also a "human readable" part (somthing like My_app_shared_data_63dcc4b9-b122-4337-b897-88f6a7f49f3f). This would make it much easier for you and others to find your section in tools like Process Explorer and other debugging tools. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

        D Offline
        D Offline
        devvvy
        wrote on last edited by
        #3

        thanks for the feedback first of all, but i dont understand the whole issue about handle inheritance. u can set the some flags in security attribute when u create the handle and when u CreateProcess. but the child process still have no idea what the handle is!? the child process has the right to inherit, but it still doesnt know what to inherit until the parent process send the handle via mechanism such as WM_COPYDATA?? norm

        D 1 Reply Last reply
        0
        • D devvvy

          thanks for the feedback first of all, but i dont understand the whole issue about handle inheritance. u can set the some flags in security attribute when u create the handle and when u CreateProcess. but the child process still have no idea what the handle is!? the child process has the right to inherit, but it still doesnt know what to inherit until the parent process send the handle via mechanism such as WM_COPYDATA?? norm

          D Offline
          D Offline
          Daniel Lohmann
          wrote on last edited by
          #4

          The usual (and most easy) way to pass the inherited handles to a child process is via the command line or environment variables. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups