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. passing structures across processes

passing structures across processes

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncareer
5 Posts 4 Posters 1 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.
  • R Offline
    R Offline
    Raghunandan S
    wrote on last edited by
    #1

    Hi All, I have a structure of CString variabls.I need to pass this variable from one application to other application.I was trying WM_COPYDATA message to pass the data but i'm unable to receive the structure in the destination process.can someone help me out in this. my code looks like this typedef struct { CString name; Cstring job; } Raghu; Raghu raghu; raghu.name = "Raghu"; raghu.job = "none"; COPYDATASTRUCT datastruct; datastruct.lpdata = (void*)&raghu; datastrcut.cbdata=raghu.name .getlength() + raghu.job.getlength();//is this correct way?? ::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct); Thanks in advance

    E A 2 Replies Last reply
    0
    • R Raghunandan S

      Hi All, I have a structure of CString variabls.I need to pass this variable from one application to other application.I was trying WM_COPYDATA message to pass the data but i'm unable to receive the structure in the destination process.can someone help me out in this. my code looks like this typedef struct { CString name; Cstring job; } Raghu; Raghu raghu; raghu.name = "Raghu"; raghu.job = "none"; COPYDATASTRUCT datastruct; datastruct.lpdata = (void*)&raghu; datastrcut.cbdata=raghu.name .getlength() + raghu.job.getlength();//is this correct way?? ::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct); Thanks in advance

      E Offline
      E Offline
      ElCachubrey
      wrote on last edited by
      #2

      You can't pass pointers between process WM_COPYDTA designated for transfer easy weight data (no more than LONG) You can shared data among process use memory mapped files or use __declspec(allocate) see MSDN or "Ritcher Programming for Windows"

      1 Reply Last reply
      0
      • R Raghunandan S

        Hi All, I have a structure of CString variabls.I need to pass this variable from one application to other application.I was trying WM_COPYDATA message to pass the data but i'm unable to receive the structure in the destination process.can someone help me out in this. my code looks like this typedef struct { CString name; Cstring job; } Raghu; Raghu raghu; raghu.name = "Raghu"; raghu.job = "none"; COPYDATASTRUCT datastruct; datastruct.lpdata = (void*)&raghu; datastrcut.cbdata=raghu.name .getlength() + raghu.job.getlength();//is this correct way?? ::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct); Thanks in advance

        A Offline
        A Offline
        autodebug
        wrote on last edited by
        #3

        You can't used class with WM_COPYDATA. Only like this. typedef struct { char name[256]; char job[256]; } Raghu; Raghu raghu; strcpy(raghu.name, "Raghu"); strcpy(raghu.job, "none"); COPYDATASTRUCT datastruct; datastruct.lpdata = (void*)&raghu; datastrcut.cbdata=sizeof(raghu)? ::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct); --------------------------- Auto Debug for Windows website: http://www.autodebug.com/

        R 1 Reply Last reply
        0
        • A autodebug

          You can't used class with WM_COPYDATA. Only like this. typedef struct { char name[256]; char job[256]; } Raghu; Raghu raghu; strcpy(raghu.name, "Raghu"); strcpy(raghu.job, "none"); COPYDATASTRUCT datastruct; datastruct.lpdata = (void*)&raghu; datastrcut.cbdata=sizeof(raghu)? ::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct); --------------------------- Auto Debug for Windows website: http://www.autodebug.com/

          R Offline
          R Offline
          Raghunandan S
          wrote on last edited by
          #4

          Hi, Thanks for the suggestion. The code works.but whenever i send this broad cast message microsoft outlook gives a message "The command line argument is not valid. Verify the switch you are using.". i tried giving different value to datastruct.dwData variable.but is of no use.can you please help me on this Regards Raghu

          W 1 Reply Last reply
          0
          • R Raghunandan S

            Hi, Thanks for the suggestion. The code works.but whenever i send this broad cast message microsoft outlook gives a message "The command line argument is not valid. Verify the switch you are using.". i tried giving different value to datastruct.dwData variable.but is of no use.can you please help me on this Regards Raghu

            W Offline
            W Offline
            wb
            wrote on last edited by
            #5

            :) if you broadcast a message, all the apps are geting it and if they have a function mapped to this message, you get funny results. you mustnt broadcast a message. send it to a particular window.

            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