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. Regarding string conversion

Regarding string conversion

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 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.
  • H Offline
    H Offline
    H4u32
    wrote on last edited by
    #1

    Hi all, I want to convert char* to unsigned short* string. How would i accomplish it?? Please give me some hint to make it work. it would be a great help to me. Thanks

    I 1 Reply Last reply
    0
    • H H4u32

      Hi all, I want to convert char* to unsigned short* string. How would i accomplish it?? Please give me some hint to make it work. it would be a great help to me. Thanks

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      Search terms to look for: USES_CONVERSION A2T A2W MultiByteToWideChar Iain.

      H 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        Search terms to look for: USES_CONVERSION A2T A2W MultiByteToWideChar Iain.

        H Offline
        H Offline
        H4u32
        wrote on last edited by
        #3

        char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks

        C M 2 Replies Last reply
        0
        • H H4u32

          char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          I really suggest you read this article[^]. You will learn everything you need to handle the problem (and even much more).

          Cédric Moonen Software developer
          Charting control [v1.5] OpenGL game tutorial in C++

          1 Reply Last reply
          0
          • H H4u32

            char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Your code works fine for me. Are you sure subKey points to a NULL-terminated string? Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            H 1 Reply Last reply
            0
            • M Mark Salsbery

              Your code works fine for me. Are you sure subKey points to a NULL-terminated string? Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              H Offline
              H Offline
              H4u32
              wrote on last edited by
              #6

              Thank you all of you. I also got my solution However, Thanks a lot Regards, Hemang

              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