I'm using Visual Studio 2005. I have a simple Win 32 console app that I'm trying to explicitly call a 3rd party dll from.
I can call the dll if I save my file that calls the dll as a "C" program. However, it does not work if I try to save it as a "CPP" file. I need to save it as a cpp file. I have two questions:
First, is it possible to save the file in C and than call the function in a CPP program. The second question shows what I've tried along with the error I'm getting:
I've placed the dll and the library in my system 32 folder. Here's what I have:
When I try to compile, I get the following error:
// test1.cpp : Defines the entry point for the console application.
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\BIOWDLL.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "GetSrcBIOWIN");
/* Define the Function in the DLL for reuse. This is just prototyping
the dll's function. A mock of it. Use "stdcall" for maximum compatibility.
typedef int (__stdcall * pICFUNC)(char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*);
MyFunction = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = MyFunction("test","test2",EstLin,EstNon,EstUlt,EstPrim,UltTime,PrimTime,EstMitiLin,EstMitiNon,DetailResults,numLines,ErrorMess);
/* Release the Dll */
/* The return val from the dll */
int _tmain(int argc, _TCHAR* argv)
c:\documents and settings\epajn\my documents\visual studio 2005\projects\test1\test1\test1.cpp(42) : error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char ' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://c:\Documents and Settings\epajn\My Documents\Visual Studio 2005\Projects\test1\test1\Debug\BuildLog.htm"
test1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've been struggling with this for way too long. I will be extremely grateful for any pointers.