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. String from VB to VC

String from VB to VC

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicstutorial
7 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.
  • S Offline
    S Offline
    SiddharthAtw
    wrote on last edited by
    #1

    Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

    P 1 Reply Last reply
    0
    • S SiddharthAtw

      Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      Widebytetomultibyte will help you convert wstring to string. But since the input is from VB i guess it must be BSTR so to convert BSTR to string put USES_CONVERSION as the first line in the function and when you want to convert BSTR to string use this macro OLE2A to finish the job.


      Still Alive!!! Thank you God.

      S 1 Reply Last reply
      0
      • P Prakash Nadar

        Widebytetomultibyte will help you convert wstring to string. But since the input is from VB i guess it must be BSTR so to convert BSTR to string put USES_CONVERSION as the first line in the function and when you want to convert BSTR to string use this macro OLE2A to finish the job.


        Still Alive!!! Thank you God.

        S Offline
        S Offline
        SiddharthAtw
        wrote on last edited by
        #3

        Bulls eye boss, in identifying the problem. Really U are great. I am trying it. Will get back to you. One point I want to clarify USES_CONVERSION is not included in Index part of MSDN. Nor OLE2A

        P 2 Replies Last reply
        0
        • S SiddharthAtw

          Bulls eye boss, in identifying the problem. Really U are great. I am trying it. Will get back to you. One point I want to clarify USES_CONVERSION is not included in Index part of MSDN. Nor OLE2A

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          SiddharthAtw wrote: Really U are great humm, ab chane ke jhad pe mat chada. ;)


          Still Alive!!! Thank you God.

          S M 2 Replies Last reply
          0
          • P Prakash Nadar

            SiddharthAtw wrote: Really U are great humm, ab chane ke jhad pe mat chada. ;)


            Still Alive!!! Thank you God.

            S Offline
            S Offline
            SiddharthAtw
            wrote on last edited by
            #5

            Meri kya aukaat ki guru logo ke chana ka Jhad par chadao. It gave me breather, believe me.Right now experimenting with the issue. :-D

            1 Reply Last reply
            0
            • S SiddharthAtw

              Bulls eye boss, in identifying the problem. Really U are great. I am trying it. Will get back to you. One point I want to clarify USES_CONVERSION is not included in Index part of MSDN. Nor OLE2A

              P Offline
              P Offline
              Prakash Nadar
              wrote on last edited by
              #6

              include atlconv.h for uses_conversion stuff also you can refer this link for futher understanding USES_CONVERSION[^] its not a complete doc but its good to understand and about the link in MSDN try searching it, i guess its in of the knowledge base article.


              Still Alive!!! Thank you God.

              1 Reply Last reply
              0
              • P Prakash Nadar

                SiddharthAtw wrote: Really U are great humm, ab chane ke jhad pe mat chada. ;)


                Still Alive!!! Thank you God.

                M Offline
                M Offline
                Monty2
                wrote on last edited by
                #7

                Mr.Prakash wrote: humm, ab chane ke jhad pe mat chada jhad chana chane ka jhad chakkar ke hai :~ :cool: C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg

                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