VB6 Project to VC6
-
Hi all I have a VB project that I wish to port to VC. The VB project makes use of a dll file, for which I do not have a .lib or .h file. is there any way I can do what I am trying to do? Sorry if this is a dumn question! Cheers Mike
-
Hi all I have a VB project that I wish to port to VC. The VB project makes use of a dll file, for which I do not have a .lib or .h file. is there any way I can do what I am trying to do? Sorry if this is a dumn question! Cheers Mike
Assuming you have the VB source code, you will just need to convert the dll function declarations to C++ declarations.
-
Assuming you have the VB source code, you will just need to convert the dll function declarations to C++ declarations.
Thanks for taking the time to help! Previously when I have done a similar thing to this, I have had an associated header and lib file. I would normally go to Projects, settings, and add "MyLib.lib" to object\library modules. Is there another way of adding the dll to the project? Again thanks for any help Mike
-
Thanks for taking the time to help! Previously when I have done a similar thing to this, I have had an associated header and lib file. I would normally go to Projects, settings, and add "MyLib.lib" to object\library modules. Is there another way of adding the dll to the project? Again thanks for any help Mike
Well, since you don't have a .lib file for the dll, I don't see that you need to add it to the project, per se. In order to call the functions in the dll you'll have to use
LoadLibrary
, andGetProcAddress
. Are you familiar with those two functions? -
Well, since you don't have a .lib file for the dll, I don't see that you need to add it to the project, per se. In order to call the functions in the dll you'll have to use
LoadLibrary
, andGetProcAddress
. Are you familiar with those two functions?no - just looking them up!
-
no - just looking them up!
well, Im part of the way there! I have tried this: HINSTANCE hDLL = NULL; FARPROC DLLFunc; hDLL = LoadLibrary("MyDLL.dll"); if(hDLL) { DLLFunc = GetProcAddress(hDLL,"MyFunction"); FreeLibrary(hDLL); } I get a handle to the dll, but GetProcAddress fails. I have tried this with a different dll, and this appeared to work, so may be there is something unusual with MyDLL.dll - is there a way of finding out what functions are in the dll? The VB program declares a variable as well - "Dim WithEvents obj As CVeronixCtl" how would this be handled? Thanks again for your time and patience! Mike
-
well, Im part of the way there! I have tried this: HINSTANCE hDLL = NULL; FARPROC DLLFunc; hDLL = LoadLibrary("MyDLL.dll"); if(hDLL) { DLLFunc = GetProcAddress(hDLL,"MyFunction"); FreeLibrary(hDLL); } I get a handle to the dll, but GetProcAddress fails. I have tried this with a different dll, and this appeared to work, so may be there is something unusual with MyDLL.dll - is there a way of finding out what functions are in the dll? The VB program declares a variable as well - "Dim WithEvents obj As CVeronixCtl" how would this be handled? Thanks again for your time and patience! Mike
The spelling of the function name in GetProcAddress must be exact. You can also try calling GetLastError like this:
DWORD Error = 0;
DLLFunc = GetProcAddress(hDLL, "MyFunction" );
if ( ! DLLFunc )
Error = GetLastError();This will tell you the reason that the call failed. You can find out the exported functions inside the DLL, by using the program Dumpbin that comes with the SDK. dumpbin /EXPORTS MyDll.dll