Jamie Posted February 14, 2006 Share Posted February 14, 2006 Hi, I'm having a lot of trouble calling a DLL someone wrote for me. I've included the code below. Basically, the DLL appears to open up ok - but @error is always set to '1' when I call DllCall for the function I need to invoke. The definition of the function in the DLL is: int _getChecksum( HWND hwnd, int x, int y, int width, int height, int color); My code is as follows: $windowName="Admin"; If WinExists($windowName) Then If Not WinActive($windowName) Then WinActivate($windowName) EndIf $dll = DllOpen("PixChecksum.dll"); If $dll >= 0 Then $hwnd = WinGetHandle($windowName); $checksum = DllCall( $dll, "int", "_getChecksum", "hwnd", $hwnd, "int", 4, "int", 4, "int", 4, "int", 4, "int", 255); If @error == 1 Then msgbox(0, 'Error', 'Failed to call function'); Else MsgBox(0, 'Success', 'Result: ' & $checksum); EndIf DllClose($dll); Else MsgBox(0, 'Error', 'Could not open DLL'); EndIf EndIf Am I doing anything obviously wrong here ? I've been over and over the code and just cannot see an error with my call... Any help would be gratefully received! Thanks, Jamie. Link to comment Share on other sites More sharing options...
jpm Posted February 14, 2006 Share Posted February 14, 2006 difficult to help you without the .dll and the specification of the parameter and the return Value :"> Link to comment Share on other sites More sharing options...
Jamie Posted February 14, 2006 Author Share Posted February 14, 2006 (edited) difficult to help you without the .dll and the specification of the parameter and the return Value :">The params are as posted above:int _getChecksum( HWND hwnd, int x, int y, int width, int height, int color);The DLL is attached.Thanks for the response.Jamie.PixChecksum.zip Edited February 14, 2006 by Jamie Link to comment Share on other sites More sharing options...
Jamie Posted February 14, 2006 Author Share Posted February 14, 2006 More info... I tried adding a dummy 'test' function that is really cut down - and that fails to call also. The line calling the function is: $checksum = DllCall( $dll, "int", "testCall", "int", 5 ); The function definition in C++ looks like this: #ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif EXPORT int CALLBACK testCall( int ); EXPORT int CALLBACK testCall( int myInt ) { return myInt * 2; } Does this shed any further light ? Regards, Jamie. Link to comment Share on other sites More sharing options...
poisonkiller Posted February 14, 2006 Share Posted February 14, 2006 How can i read a .dll anyway??? Link to comment Share on other sites More sharing options...
Jamie Posted February 14, 2006 Author Share Posted February 14, 2006 How can i read a .dll anyway???I put the C++ source in a previous post for the DLL ?Or do are you referring to the call - if so, I *think* the base post should do the job - but it doesn't - so I'm hoping someone here might be able to spot what's going wrong here...Cheers,Jamie. Link to comment Share on other sites More sharing options...
Jamie Posted February 14, 2006 Author Share Posted February 14, 2006 CALLBACK?LAr.Hi Larry,I don't know what that does - the DLL was written for me. Does it look wrong to you ?Jamie. Link to comment Share on other sites More sharing options...
Jamie Posted February 14, 2006 Author Share Posted February 14, 2006 Hi Larry,I don't know what that does - the DLL was written for me. Does it look wrong to you ?Jamie.Hmmm...Thanks Larry. I took the CALLBACK out and it works fine!Thanks a load!Jamie. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now