VB DLL in Visual C++

Anis
09-25-2002, 03:10 AM
How to call Visual Basic DLL into Visual C++?.

Thanks for any help.

Regards,
Anis

B_old
09-25-2002, 02:23 PM
Hmm. I don't know.
But why would you like to do that anyway.
I would really understand it the other way round...
Well, whatever, sorry that I could not help.
Good luck.

usetheforce2
09-25-2002, 02:35 PM
Good start (http://support.microsoft.com/default.aspx?scid=/servicedesks/webcasts/wc052401/wcblurb052401.asp)


Truefully i'de be interested in a solution to this prob. I'm not sure how difficult C++ and COM is...

Anis
09-25-2002, 11:37 PM
B_old: I have a VB DLL and i need to use some function in Visual C++. Thats the only reason i want to do this.

usetheforce2: I have been cracking my Head, but i really can't call the functions in VB DLL. Thanks usetheforce2, i will try the link and let you know. Although, in morning i decided to make a component in VC++, but i should better give a try to your link.

Anis
09-27-2002, 03:40 AM
I have give up. Making the DLL itself in Visual C++ now. :(

B_old
09-27-2002, 05:27 AM
why are you unhappy about that?

Anis
09-27-2002, 05:29 AM
Simple Because i developed something in VB, and now i have to redo it in Visual C++.

B_old
09-27-2002, 07:47 AM
Oh, so you wrote the VB-dll.
[I am not sure that I understand the problem in the first place.]
Good luck with rewriting the software, should be easy for you though!

reboot
09-27-2002, 07:50 AM
You have to become a COM God to call vb dlls from c. :)

(And no, I don't have any idea how to go about it)

Anis
09-27-2002, 07:51 AM
Originally posted by B_old
Oh, so you wrote the VB-dll.
[I am not sure that I understand the problem in the first place.]
Good luck with rewriting the software, should be easy for you though!


Its not the whole software. Just a small component, shouldn't be a problem.

Anis
09-27-2002, 07:52 AM
Originally posted by reboot
You have to become a COM God to call vb dlls from c. :)


Even i couldn't find one GOD. :D

OnErr0r
09-28-2002, 04:27 PM
Here is a "simple" example of calling a COM (ActiveX) DLL in VC++ that was created in VB. The DLL just has a single method which opens a msgbox.

Make SURE you register the VB dll FIRST. Then just open the C++ exe in \Release or \Debug or compile one yourself.

usetheforce2
09-28-2002, 04:44 PM
OnErrOr, how do you get the unique identifier from a compiled dll if its even possible... Say i wanted to access an ADO object, how would i get the GUID for a specific interface?

thanks, Regan

OnErr0r
09-28-2002, 04:47 PM
Either from the CLSID in the registry, or using OLE View (VC++ tools). bbl, I'm going Salmon fishing :)

OnErr0r
09-28-2002, 04:48 PM
That's HKCR\CLSID (Search for ADO) ADODB.Command comes up first.

usetheforce2
09-28-2002, 05:38 PM
thx :)

Anis
09-29-2002, 04:10 AM
Originally posted by OnErr0r
Here is a "simple" example of calling a COM (ActiveX) DLL in VC++ that was created in VB. The DLL just has a single method which opens a msgbox.

Make SURE you register the VB dll FIRST. Then just open the C++ exe in \Release or \Debug or compile one yourself.

Thanks. I will look at it. :)

Anis
09-29-2002, 09:37 AM
OnErr0r,
Thanks for your help. It works fine, until i use your DLL. If i recompile the VB DLL with no changes once, its not wokring. Any clue?

OnErr0r
09-29-2002, 11:53 AM
If you don't have binary compatibility checked then you'll get a new CLSID when you recompile. You'll need to change the VC code to your new CLSID. See what I told usetheforce2.

dam
10-02-2002, 07:15 AM
I don't know how to register the VB Dll.
Can somebody help me.

Thanks

reboot
10-02-2002, 07:27 AM
regsvr32 blah.dll

syncro
11-01-2002, 02:45 AM
Hi there,:rolleyes:

I tried your example and it work, no 2 hoots about it. Now Im trying to do the same way with my own VB Dll. Problem is when i use the MIDL.EXE to convert my *.idl files to .f,.c it gives me and error :

command line error MIDL1001 : cannot open input file objidl.idl

Now i made sure the file "objidl.idl" is in the /bin folder. I can open it in Notepad or VC no problems. Whats happening?

Is there any other tool to convert IDL files to .c,.h ?

BTW, u can register the VB Dll using Regsvr32 <filename> from the command line.

Cheers!!

OnErr0r
11-01-2002, 12:28 PM
oops, I didn't see page 2 when I sent my initial response.

I think you need a reference to that .idl.

checking...

syncro
11-03-2002, 10:00 AM
Elo again!

Thanks for the reply but....Sorry, i dont know how to referrence an .idl file. Shouldn't it be done when i install VC++ with typical settings?...What am i missing here?

I even tried the OLE Viewer "Save As" option and tried to save as a ".h" file. It gave me an error : "MIDL Error 2"..... I checked the MIDL ver is 5.0.1802.1.

Thanks!!

FYI : i tried these steps at several other PCs and they all had the same error. So far tried on 3 Win2K and 1 Win98 PC.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum