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 CString to unsigned short

convert CString to unsigned short

Scheduled Pinned Locked Moved C / C++ / MFC
help
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.
  • U Offline
    U Offline
    User 3650979
    wrote on last edited by
    #1

    hi CString str = "000001"; unsigned short st =_com_util::ConvertStringToBSTR(str); st = 0x00000 is coming... please help any body..

    A L 2 Replies Last reply
    0
    • U User 3650979

      hi CString str = "000001"; unsigned short st =_com_util::ConvertStringToBSTR(str); st = 0x00000 is coming... please help any body..

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

      If you dont bother to get the value in unsigned long then strtoul, wcstoul can be used[^].

      Member 3653751 wrote:

      unsigned short st =_com_util::ConvertStringToBSTR(str);

      Well your code is not seems to be correct. It convert the LPTSTR to BSTR, it wont convert it to unsigned short :)

      Величие не Бога может быть недооценена.

      U 1 Reply Last reply
      0
      • U User 3650979

        hi CString str = "000001"; unsigned short st =_com_util::ConvertStringToBSTR(str); st = 0x00000 is coming... please help any body..

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        We already explained how to do this here[^]. Please take some time to read the documentation in the posted link.

        It's time for a new signature.

        1 Reply Last reply
        0
        • A Adam Roderick J

          If you dont bother to get the value in unsigned long then strtoul, wcstoul can be used[^].

          Member 3653751 wrote:

          unsigned short st =_com_util::ConvertStringToBSTR(str);

          Well your code is not seems to be correct. It convert the LPTSTR to BSTR, it wont convert it to unsigned short :)

          Величие не Бога может быть недооценена.

          U Offline
          U Offline
          User 3650979
          wrote on last edited by
          #4

          hi convertStringtoBSTR() this function is returning unsigned short only... i am giving correct input....but output is coming worning.... please help.... actual my problem is i have vb dll... Public Function f1(SendString As String) As String after loading vb dll t is the class pointer of vb dll... CString str = "000001"; unsigned short *stemp = _com_util::ConvertStringToBSTR(str); //stemp = 48 means 0 t->f1(&stemp) input / output unsigned short its showing...

          L 1 Reply Last reply
          0
          • U User 3650979

            hi convertStringtoBSTR() this function is returning unsigned short only... i am giving correct input....but output is coming worning.... please help.... actual my problem is i have vb dll... Public Function f1(SendString As String) As String after loading vb dll t is the class pointer of vb dll... CString str = "000001"; unsigned short *stemp = _com_util::ConvertStringToBSTR(str); //stemp = 48 means 0 t->f1(&stemp) input / output unsigned short its showing...

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You also need to read the documentation for ConvertStringToBSTR(). [edit]Also you need to understand C programming and return values.[/edit]

            It's time for a new signature.

            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