Sign in to follow this  
Followers 0
Jamie

DllCall Frustrations!

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



difficult to help you without the .dll and the specification of the parameter and the return Value :">

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Jamie

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

How can i read a .dll anyway???

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

CALLBACK?

LAr.

Hi Larry,

I don't know what that does - the DLL was written for me. Does it look wrong to you ?

Jamie.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0