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. convert TCHAR[] to BYTE*

convert TCHAR[] to BYTE*

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
8 Posts 4 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.
  • R Offline
    R Offline
    Rakesh5
    wrote on last edited by
    #1

    Hi , can anyone guide me how to convert content of type TCHAR[] to BYTE*.... Thanks, Rakesh.

    _ 1 Reply Last reply
    0
    • R Rakesh5

      Hi , can anyone guide me how to convert content of type TCHAR[] to BYTE*.... Thanks, Rakesh.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Use the WideCharToMultiByte[^] function.

      «_Superman_» I love work. It gives me something to do between weekends.

      R 1 Reply Last reply
      0
      • _ _Superman_

        Use the WideCharToMultiByte[^] function.

        «_Superman_» I love work. It gives me something to do between weekends.

        R Offline
        R Offline
        Rakesh5
        wrote on last edited by
        #3

        But its saying like Widechartomultibyte cannot convert 5 parameter from BYTE[128] to LPSTR.. code: WCHAR szstring[256]; length = lstrlen(szstring); BYTE pByte[128]; WideCharToMultiByte(CP_ACP, 0, szstring, -1, pByte, length, NULL, NULL); Can you please guide me where am i going wrong? Thanks, Rakesh.

        _ 1 Reply Last reply
        0
        • R Rakesh5

          But its saying like Widechartomultibyte cannot convert 5 parameter from BYTE[128] to LPSTR.. code: WCHAR szstring[256]; length = lstrlen(szstring); BYTE pByte[128]; WideCharToMultiByte(CP_ACP, 0, szstring, -1, pByte, length, NULL, NULL); Can you please guide me where am i going wrong? Thanks, Rakesh.

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          The expected 5th parameter is char* and you're giving it an unsigned char*. All you need to do is typecast pByte as (LPSTR)pByte.

          «_Superman_» I love work. It gives me something to do between weekends.

          R 1 Reply Last reply
          0
          • _ _Superman_

            The expected 5th parameter is char* and you're giving it an unsigned char*. All you need to do is typecast pByte as (LPSTR)pByte.

            «_Superman_» I love work. It gives me something to do between weekends.

            R Offline
            R Offline
            Rakesh5
            wrote on last edited by
            #5

            hey superman, sorry to disturb u.. i tried with tat too(before replying u..) i forgot to mention tat one... Its not copying the exact content rather its showing "???" marks... i actually tried to copy chinese characters.. can u please help me to solve this issue? thanks, rakesh.

            A D 2 Replies Last reply
            0
            • R Rakesh5

              hey superman, sorry to disturb u.. i tried with tat too(before replying u..) i forgot to mention tat one... Its not copying the exact content rather its showing "???" marks... i actually tried to copy chinese characters.. can u please help me to solve this issue? thanks, rakesh.

              A Offline
              A Offline
              Adam Roderick J
              wrote on last edited by
              #6

              [Message Deleted]

              R 1 Reply Last reply
              0
              • A Adam Roderick J

                [Message Deleted]

                R Offline
                R Offline
                Rakesh5
                wrote on last edited by
                #7

                I have already done that ARJ... in the properties.. as "use unicode character set".. Thanks, rakesh

                1 Reply Last reply
                0
                • R Rakesh5

                  hey superman, sorry to disturb u.. i tried with tat too(before replying u..) i forgot to mention tat one... Its not copying the exact content rather its showing "???" marks... i actually tried to copy chinese characters.. can u please help me to solve this issue? thanks, rakesh.

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

                  Rakesh5 wrote:

                  ...its showing "???" marks...

                  Where?

                  "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  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