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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. NetMessageBufferSend question

NetMessageBufferSend question

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomjsonworkspace
6 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.
  • T Offline
    T Offline
    Tom Wright
    wrote on last edited by
    #1

    I'm having trouble with the LPBYTE param of this API. I want to move text from my dialog based application to this api to send. LPTSTR buffer; m_cSendText.GetWindowText(buffer, 256); nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)buffer, 256); When I run my program all I get is a string of ?'s. How do I setup the 4th param so that it sends the text properly? Thanks Tom Wright tawright915@yahoo.com

    T 1 Reply Last reply
    0
    • T Tom Wright

      I'm having trouble with the LPBYTE param of this API. I want to move text from my dialog based application to this api to send. LPTSTR buffer; m_cSendText.GetWindowText(buffer, 256); nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)buffer, 256); When I run my program all I get is a string of ?'s. How do I setup the 4th param so that it sends the text properly? Thanks Tom Wright tawright915@yahoo.com

      T Offline
      T Offline
      Tom Wright
      wrote on last edited by
      #2

      Okay I found that I did not have this set correctly is should be CString buffer; m_cSendText.GetWindowText(buffer); nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)&buffer, m_cSendText.GetWindowTextLength()); But I'm still getting junk in the message box. Any suggestions? Tom Wright tawright915@yahoo.com

      S 1 Reply Last reply
      0
      • T Tom Wright

        Okay I found that I did not have this set correctly is should be CString buffer; m_cSendText.GetWindowText(buffer); nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)&buffer, m_cSendText.GetWindowTextLength()); But I'm still getting junk in the message box. Any suggestions? Tom Wright tawright915@yahoo.com

        S Offline
        S Offline
        Stephen C Steel
        wrote on last edited by
        #3

        The problem is the unecessary & to take the address of the CString object. If you only need read access to the string data in a CString object, you can use the (LPCTSTR) conversion operator to get a pointer to the buffer. Then you'll have to use a cast, because NetMessageBufferSend() expects an LPBYTE rather than an LPCTSTR. That is, change (LPBYTE)&buffer, to (LPBYTE)(LPCTSTR) buffer, Casting away the constness of the LPCTSTR doesn't matter in this case, since NetMessageBufferSend () is only going to read the buffer. Stephen C. Steel Kerr Vayne Systems Ltd.

        T 1 Reply Last reply
        0
        • S Stephen C Steel

          The problem is the unecessary & to take the address of the CString object. If you only need read access to the string data in a CString object, you can use the (LPCTSTR) conversion operator to get a pointer to the buffer. Then you'll have to use a cast, because NetMessageBufferSend() expects an LPBYTE rather than an LPCTSTR. That is, change (LPBYTE)&buffer, to (LPBYTE)(LPCTSTR) buffer, Casting away the constness of the LPCTSTR doesn't matter in this case, since NetMessageBufferSend () is only going to read the buffer. Stephen C. Steel Kerr Vayne Systems Ltd.

          T Offline
          T Offline
          Tom Wright
          wrote on last edited by
          #4

          No this still does not work. I must not be setting something up right. I have a dialog based app with 2 edit fields on it. And a control variables called: m_cCompName. m_cSendText. LPWSTR awcToNameW; LPWSTR awcFromNameW; CString ComputerName; awcToNameW = T2W(ComputerName); awcFromNameW = T2W(ComputerName); NET_API_STATUS nasStatus; nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)(LPCTSTR)TextSend, TextSend.GetLength()); So what am I doing wrong. This should work. Right? Thanks Tom Wright tawright915@yahoo.com

          D 1 Reply Last reply
          0
          • T Tom Wright

            No this still does not work. I must not be setting something up right. I have a dialog based app with 2 edit fields on it. And a control variables called: m_cCompName. m_cSendText. LPWSTR awcToNameW; LPWSTR awcFromNameW; CString ComputerName; awcToNameW = T2W(ComputerName); awcFromNameW = T2W(ComputerName); NET_API_STATUS nasStatus; nasStatus = NetMessageBufferSend(NULL, awcToNameW, awcFromNameW, (LPBYTE)(LPCTSTR)TextSend, TextSend.GetLength()); So what am I doing wrong. This should work. Right? Thanks Tom Wright tawright915@yahoo.com

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

            Usually NetXXX Api never use ANIS strings. Even if not explicitly mentioned in MSDN, I would try to convert the message buffer also to UNICODE. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

            T 1 Reply Last reply
            0
            • D Daniel Lohmann

              Usually NetXXX Api never use ANIS strings. Even if not explicitly mentioned in MSDN, I would try to convert the message buffer also to UNICODE. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

              T Offline
              T Offline
              Tom Wright
              wrote on last edited by
              #6

              That's what I ended up doing. Thanks Tom Wright tawright915@yahoo.com

              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