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. Converting LPSTR to BYTE *?

Converting LPSTR to BYTE *?

Scheduled Pinned Locked Moved C / C++ / MFC
performancetutorialquestion
5 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.
  • B Offline
    B Offline
    billiam904
    wrote on last edited by
    #1

    I have a WAVEHDR structure set up and I want to store the data from the lpData element which is of type LPSTR to BYTE * for allocating a memory block using GlobalAlloc and to pass back the pointer of this new memory block. Does anyone know how I can convert LPSTR to BYTE* to do this or can someone show me how to dump the data from the lpData element of a WAVEHDR structure to a BYTE-based memory buffer? Thanks. Bill Dennis Orlando, FL

    C 1 Reply Last reply
    0
    • B billiam904

      I have a WAVEHDR structure set up and I want to store the data from the lpData element which is of type LPSTR to BYTE * for allocating a memory block using GlobalAlloc and to pass back the pointer of this new memory block. Does anyone know how I can convert LPSTR to BYTE* to do this or can someone show me how to dump the data from the lpData element of a WAVEHDR structure to a BYTE-based memory buffer? Thanks. Bill Dennis Orlando, FL

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      int len = strlen(lpStr); HGLOBAL hMem = GlobalAlloc(0, len); memcpy((BYTE*)hMem, lpStr, len); Cleek | Image Toolkits | Thumbnail maker

      J 1 Reply Last reply
      0
      • C Chris Losinger

        int len = strlen(lpStr); HGLOBAL hMem = GlobalAlloc(0, len); memcpy((BYTE*)hMem, lpStr, len); Cleek | Image Toolkits | Thumbnail maker

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        I need to ask.. why GlobalAlloc()? Been using it alot lately? :) -- Keep talking! You're the fool, I'm the preacher.

        C 1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          I need to ask.. why GlobalAlloc()? Been using it alot lately? :) -- Keep talking! You're the fool, I'm the preacher.

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          i use it all the time because you can't use malloc or new to share mem between C++ and VB, for example. but, the original poster mentioned GlobalAlloc, here. Cleek | Image Toolkits | Thumbnail maker

          J 1 Reply Last reply
          0
          • C Chris Losinger

            i use it all the time because you can't use malloc or new to share mem between C++ and VB, for example. but, the original poster mentioned GlobalAlloc, here. Cleek | Image Toolkits | Thumbnail maker

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #5

            Chris Losinger wrote: but, the original poster mentioned GlobalAlloc, here. :doh: -- Keep talking! You're the fool, I'm the preacher.

            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