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. how to pass Cstring to vb dll fuction in vc++

how to pass Cstring to vb dll fuction in vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
3 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 friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.

    S C 2 Replies Last reply
    0
    • U User 3650979

      hi friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      You need to pass this as a BSTR (or possibly a BSTR encapsulated in a VARIANT). Open the VB DLL in the OLE/COM Object Viewer (use the File->View TypeLib... command) to see what parameter type the VB DLL is expecting to see for this call.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

      1 Reply Last reply
      0
      • U User 3650979

        hi friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        You cannot pass a CString's instance, you've to pass a BSTR. Anyway, the

        Member 3653751 wrote:

        t->f1(str);

        call seems wrong (what is _clsdll type?) :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        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