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 import VB Dll into VC++ Program and How to use functions from VB dll??

How to import VB Dll into VC++ Program and How to use functions from VB dll??

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studiotutorial
25 Posts 5 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 savitri

    Hi Sandip, I used like this but i am getting errors..I am writting like this: ::CoInitialize(NULL); //note this change after taking out the no_namespace macro //if there is no namespace then also the progid has to be __uuidof(VbDll::CVbDll) like this SampleDll::_FunctionClass sample; HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll) //not just CVbDll //sample.AddRef(); BSTR server,usr,pwd,Temp,Temp3; BOOL bstr; Temp=SysAllocString(L"21\8\2008"); str=Temp; MessageBox(str); Temp3=SysAllocString(L"21\7\2008"); str=Temp3; MessageBox(str); server=SysAllocString(L"savitri"); str=server; MessageBox(str); usr=SysAllocString(L"root"); str=usr; MessageBox(str); pwd=SysAllocString(L"base"); str=pwd; MessageBox(str); BOOL bstrMyString;//=TRUE; //check for the instance bstrMyString=sample.ProcessingInformation(&Temp,&Temp3,&server,&usr,&pwd); str.Format("%d\n", bstrMyString); MessageBox(str, "MyString aus VB", MB_OK); sample.Release(); ::CoUninitialize(); It is giving errors... 1. C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(194) : error C2259: '_FunctionClass' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' 2.C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(194) : error C2259: '_FunctionClass' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' 3.C:\Program Files\Microsoft Visual Studio\My Projects\UseVbDll\UseVbDllDlg.cpp(195) : error C2039: 'CreateInstance' : is not a member of '_FunctionClass' c:\program files\microsoft visual studio\my projects\usevbdll\debug\sampledll.tlh(34) : see declaration of '_FunctionClass' My Dll is like this // c:\program files\microsoft visual studio\my projects\usevbdll\debug\SampleDll.tlh // // C++ source equivalent of Win32 type library C:\Program Files\Microsoft Visual Studio\My Projects\BoolDate\SampleDll.dll // compiler-generated file created 08/22/08 at 17:31:22 - DO NOT EDIT! #pragma once #pragma pack(push, 8) #include namespace SampleDll { struct __declspec(uuid("a3105692-d6d7-41e0-8d8c-f4ab326fa2f4")) /* dual interface */ _FunctionClass; struct /*

    S Offline
    S Offline
    SandipG
    wrote on last edited by
    #21

    savitri wrote:

    HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll)

    Dont pass _FunctinClass use SampleDll::FunctionClass. Also You are using SampleDll::_FunctionClass sample; Here you need use SampleDll::_FunctionClassPtr sample; Just check my post again. BTW Use Code block button below posting area for code blocks it is very difficult to read your code otherwise.

    Regards, Sandip.

    modified on Friday, August 22, 2008 8:17 AM

    S 1 Reply Last reply
    0
    • S SandipG

      Did you check my post above Import[^] I think you cant use LoadLibrary(). I have given sample code in post above.

      Regards, Sandip.

      S Offline
      S Offline
      savitri
      wrote on last edited by
      #22

      Hii.. I am doing as you told me in previous post.please check your mail once or check my reply to your post import.please tell me thanks, savitri

      S 1 Reply Last reply
      0
      • S savitri

        Hii.. I am doing as you told me in previous post.please check your mail once or check my reply to your post import.please tell me thanks, savitri

        S Offline
        S Offline
        SandipG
        wrote on last edited by
        #23

        Please follow the same thread above. I have replied to you pointing out the errors. Please check.

        Regards, Sandip.

        1 Reply Last reply
        0
        • S SandipG

          savitri wrote:

          HRESULT hr=sample.CreateInstance(__uuidof(SampleDll::_FunctionClass)); //here the progid is VbDll::CVbDll)

          Dont pass _FunctinClass use SampleDll::FunctionClass. Also You are using SampleDll::_FunctionClass sample; Here you need use SampleDll::_FunctionClassPtr sample; Just check my post again. BTW Use Code block button below posting area for code blocks it is very difficult to read your code otherwise.

          Regards, Sandip.

          modified on Friday, August 22, 2008 8:17 AM

          S Offline
          S Offline
          savitri
          wrote on last edited by
          #24

          Hii I did as u told but no change in it..i am fed of this dll.. thanks for response, savitri

          S 1 Reply Last reply
          0
          • S savitri

            Hii I did as u told but no change in it..i am fed of this dll.. thanks for response, savitri

            S Offline
            S Offline
            SandipG
            wrote on last edited by
            #25

            I don't know it should work All the best :)

            Regards, Sandip.

            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