I've used the following function to call other DLLs, but for some reason I can't get this one to work correctly. It compiles, but
errors out when I try to run it. I think it has to do with the function name. The instructions name the function as
GetSrcBIOWIN. However, when I use Quick View Plus to view the
dll's properties, its named _GetSrcBIOWIN@52.
I don't know if the @ symbol in the function name is messing things up. Here's my function, any help is greatly appreciated:
/* 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 */
Make sure you test the return values from LoadLibrary and GetProcAddress to ensure they are non-NULL. If either is NULL, use GetLastError to get more information.
>>but errors out<<
This does not help us to help you. Please state what these errors are and what compiler you are using.
This question should probably have been directed to the windows board.
This just means the method is named GetSrcBIOWIN and takes 52 bytes of parameters ( 13 char pointers in your case I guess ).
Other than that, you will need to check the return values. If that succeeds, you will need to check your documentation, if it's really 13 char*'s or maybe something else that is 52 bytes combined. If it's really 13 char pointers, you will need to make sure that the values you pass are valid for the function ( most functions crash on NULL or otherwise invalid pointers for example ). If all methods succeed, if all input is valid for this function, you need to consult the manufacturer of said dll. Send him a piece of his documentation and your code and ask for support.
btw: Google returned zero hits for GetSrcBIOWIN, what kind of function is that ? Seems to be pretty... undocumented :)
Thanks everyone for your help.
What I mean by errors out is the program freezes and I'm asked if I want to send Microsoft an error report. I run the debugger and that freezes up as well, so I don't get any specific errors.
I'm using VIsual C++ 4.0. Nvoigt is correct, there is little documentation. I will check the return values. Additionally, here's part of the readme file that came with the dll. Maby it will give insight into what I'm doing wrong:
__declspec ( dllexport )int WINAPI GetSrcBIOWIN (PSTR cSmilePass,
PSTR cChemical, PSTR EstLin, PSTR EstNon, PSTR EstUlt, PSTR EstPrim,
PSTR UltTime, PSTR PrimTime, PSTR EstMitiLin, PSTR EstMitiNon,
PSTR DetailResults, PSTR numLines, PSTR ErrorMess)
Arguments with the same names as the KOWDLL.DLL are exactly the same.
This function returns: 0 for no errors
-1 for if a SMILES error occurs
NOTE ... this function receives three variables from the calling
(1) cSmilePass - the SMILES notation
(2) cChemical - the user chemical name or identifier
Other argument variables:
(3) EstLin - estimated Linear Model biodegradation probability
(probability of biodegrading fast or not)