Jump to content

Recommended Posts

Posted (edited)

I'm completely new to DLL calls and tried to mess around with the examples in the helpfile, to no avail.

The DLL I want to use can be called with this VB code:

Declare Function StartLog Lib "kbLog32" (ByVal hWnd As Long, ByVal lpFuncAddress As Long) As Long

And the callback:

Sub CallBack(ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long)

Is it possible to convert this to AutoIT? Here's what I came up with. (it doesn't work)

; Create callback function
$handle = DLLCallbackRegister ("_logit", "long", "hwnd;ptr")     

; Call StartLog
DllCall(@DesktopDir&"\kbLog32.dll", "long", "StartLog", 0, DllCallbackGetPtr ($handle))

; Delete callback function
DllCallbackFree($handle)

; Callback Procedure
Func _logit($hWnd, $lParam)
    MsgBox(0, $hWnd, $lParam,)
    Exit
EndFunc

So the DllCall runs the dll, sends the results to DLLCallbackRegister which then sends it to my _logit Func?

Edited by Das Ami
Posted

You need to provide types for the parameters, and you seem to have mixed up the callback and the exported function.

Try something like:

; Create callback function
$handle = DLLCallbackRegister ("_logit", "long", "long;long;long")   

; Call StartLog
DllCall(@DesktopDir&"\kbLog32.dll", "long", "StartLog", "hwnd",0,"ptr", DllCallbackGetPtr ($handle))

; Delete callback function
DllCallbackFree($handle)

; Callback Procedure
Func _logit($msg,$lparam,$wparam)
    MsgBox(0, $msg, $lParam,)
    Return 0
EndFunc

:)

Broken link? PM me and I'll send you the file!

Posted

Thanks a lot monoceres, I think I understand most of the input structure now. :)

I got another question though. StartLog should constantly send it's output to my function which it does not do yet.

Something must be keeping the Dll from communicating with the logit function it seems. Any ideas?

I attached my testing code with the Dll and the helpfile in case you have the time to take a quick look at it.

dllcall.rar

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...