Jump to content

Calling DllCall() from a wrapper function?


Recommended Posts

would there be a way to create a function that takes all the parameters you would use for DllCall() and then it calls DllCall() with those parameters? I ask because DllCall() takes a variable # of parameters so I'm not sure how that works.

Link to post
Share on other sites

You would need to do something like this:

DllCall("user32.dll", "int", "MessageBox", _
        "hwnd", 0, _ ; Handle to the parent window
        "str", "Some text", _ ; The text of the message box
        "str", "Some title", _ ; The title of the message box
        "int", 0) ; Flags for the message box.


;wrapper
_DllCall("user32.dll", "int", "MessageBox", _
        "hwnd", 0, _ ; Handle to the parent window
        "str", "Some text", _ ; The text of the message box
        "str", "Some title", _ ; The title of the message box
        "int", 0) ; Flags for the message box.



Func _DllCall($dll, $returnType, $function, $vT1 = 0, $vP1 = 0, $vT2 = 0, $vP2 = 0, $vT3 = 0, $vP3 = 0, $vT4 = 0, $vP4 = 0)
    Switch @NumParams
        Case (3)
            Return DllCall($dll, $returnType, $function)
        Case (3 + 2)
            Return DllCall($dll, $returnType, $function, $vT1, $vP1)
        Case (3 + 4)
            Return DllCall($dll, $returnType, $function, $vT1, $vP1, $vT2, $vP2)
        Case (3 + 6)
            Return DllCall($dll, $returnType, $function, $vT1, $vP1, $vT2, $vP2, $vT3, $vP3)
        Case (3 + 8)
            Return DllCall($dll, $returnType, $function, $vT1, $vP1, $vT2, $vP2, $vT3, $vP3, $vT4, $vP4)
        Case Else
    EndSwitch
EndFunc   ;==>_DllCall

Saludos

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

    No registered users viewing this page.

×
×
  • Create New...