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. wParam referring to A STRING...

wParam referring to A STRING...

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelp
3 Posts 3 Posters 0 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.
  • V Offline
    V Offline
    vtalau
    wrote on last edited by
    #1

    I have a trouble like below description : My program has a dll file and a server application in the mydll.dll, I want to send a message to the server application. The message has the wParam referring to a string. I wrote my code : CString speak1; .... LPTSTR str = (LPTSTR)malloc((speak1.GetLength()+1) * sizeof(TCHAR)); ....//copy the data of the "speak1" to the "str" ::PostMessage(hMainWindow,WM_USER+1,(WPARAM)str,str.GetLength()+1); free(str) ; in my server application, I try to get the address of the string from the wParam. However, I can't get the content. Please, help me, point me to some pages or give me some intruction. Thanks a lot.

    N D 2 Replies Last reply
    0
    • V vtalau

      I have a trouble like below description : My program has a dll file and a server application in the mydll.dll, I want to send a message to the server application. The message has the wParam referring to a string. I wrote my code : CString speak1; .... LPTSTR str = (LPTSTR)malloc((speak1.GetLength()+1) * sizeof(TCHAR)); ....//copy the data of the "speak1" to the "str" ::PostMessage(hMainWindow,WM_USER+1,(WPARAM)str,str.GetLength()+1); free(str) ; in my server application, I try to get the address of the string from the wParam. However, I can't get the content. Please, help me, point me to some pages or give me some intruction. Thanks a lot.

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      vtalau wrote:

      ::PostMessage(hMainWindow,WM_USER+1,(WPARAM)str,str.GetLength()+1); free(str) ;

      Use SendMessage instead of PostMessage. Otherwise free(str) will get executed before the message is processed. As PostMessage does not wait for the message to be processed.


      Nibu thomas Software Developer

      1 Reply Last reply
      0
      • V vtalau

        I have a trouble like below description : My program has a dll file and a server application in the mydll.dll, I want to send a message to the server application. The message has the wParam referring to a string. I wrote my code : CString speak1; .... LPTSTR str = (LPTSTR)malloc((speak1.GetLength()+1) * sizeof(TCHAR)); ....//copy the data of the "speak1" to the "str" ::PostMessage(hMainWindow,WM_USER+1,(WPARAM)str,str.GetLength()+1); free(str) ; in my server application, I try to get the address of the string from the wParam. However, I can't get the content. Please, help me, point me to some pages or give me some intruction. Thanks a lot.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        You need to be using new and delete instead of malloc() and free(). Otherwise, the CString object's constructor and destructor do not get called. In addition, if you are going to use PostMessage(), you'll need to move delete to the server so that it can free the memory after it is done with it.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "We will be known forever by the tracks we leave." - Native American Proverb

        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