Jump to content

DllCall Code Generator


toasterking
 Share

Recommended Posts

Thanks. Works fine for easy DLL calls and is good for beginners. If there are more difficult DLL functions with pointer to structs then it will not work anymore, but it's a good start.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Can't argue with that, I'm sure this will be very useful to a lot of people.

Since your screenshot and link refer to "GetDiskFreeSpace", you probably should start with that in the appropriate input field rather than MessagBox.

Good work.

EDIT:

After trying your linked example "GetDiskFreeSpace" I turned my attentions to "GetDiskFreeSpaceEx" and seen that the PULARGE_INTEGER type is not supported in your early script, I believe it is "uint64*" in AutoIt.

I'm sure there will be more to add if you continue to support the tool.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

J1,

Thanks for your compliments!

Since your screenshot and link refer to "GetDiskFreeSpace", you probably should start with that in the appropriate input field rather than MessagBox.

 

I agree.  I didn't actually mean to leave MessageBoxW as the default field value there.  I was using that for testing and forgot to remove it.  Fixed.

After trying your linked example "GetDiskFreeSpace" I turned my attentions to "GetDiskFreeSpaceEx" and seen that the PULARGE_INTEGER type is not supported in your early script, I believe it is "uint64*" in AutoIt.

 

 

You are correct.  I somehow missed PULARGE_INTEGER, ULARGE_INTEGER, and LARGE_INTEGER in the conversion function.  I added them.  If you enter an unknown MSDN type now, it prompts for the correct AutoIt type in case you are smarter than it is.

Edit:  GetDiskFreeSpaceEx works for me now.

Edited by toasterking
Link to comment
Share on other sites

Thanks. Works fine for easy DLL calls and is good for beginners. If there are more difficult DLL functions with pointer to structs then it will not work anymore, but it's a good start.

 

Thanks!  It is not complete and it may never be.  But I wanted to put it out there in the hopes that it can benefit someone as-is.

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

Looks good for DllCall beginners =)

Thanks!

But instand of 1000 cases in _ConvertType, why you dont work with arrays?

Mostly for speed.  It's habit; I make optimizations when I see them.  Try this example code.  The same lookup operation takes 3 times as long with an array as with a Switch statement.

My times:
Lookup1 time: 5993.06858483286 ms
Lookup2 time: 15289.7226984924 ms

Global $aLookup[15][2] = [[1,"one"], _
                         [2,"two"], _
                         [3,"three"], _
                         [4,"four"], _
                         [5,"five"], _
                         [6,"six"], _
                         [7,"seven"], _
                         [8,"eight"], _
                         [9,"nine"], _
                         [10,"ten"], _
                         [11,"eleven"], _
                         [12,"twelve"], _
                         [13,"thirteen"], _
                         [14,"fourteen"], _
                         [15,"fifteen"]]

Local $tTest = TimerInit()
For $i = 1 To 1000000
    _Lookup1("fifteen")
Next
ConsoleWrite("Lookup1 time: " & TimerDiff($tTest) & " ms" & @CRLF)

$tTest = TimerInit()
For $i = 1 To 1000000
    _Lookup2("fifteen")
Next
ConsoleWrite("Lookup2 time: " & TimerDiff($tTest) & " ms" & @CRLF)

Func _Lookup1($sName)
    Switch $sName
        Case "one"
            Return 1
        Case "two"
            Return 2
        Case "three"
            Return 3
        Case "four"
            Return 4
        Case "five"
            Return 5
        Case "six"
            Return 6
        Case "seven"
            Return 7
        Case "eight"
            Return 8
        Case "nine"
            Return 9
        Case "ten"
            Return 10
        Case "eleven"
            Return 11
        Case "twelve"
            Return 12
        Case "thirteen"
            Return 13
        Case "fourteen"
            Return 14
        Case "fifteen"
            Return 15
        Case Else
            Return 0
    EndSwitch
EndFunc

Func _Lookup2($sName)
    For $i = 1 To UBound($aLookup) - 1
        If $sName = $aLookup[$i][1] Then Return $aLookup[$i][0]
    Next
    Return 0
EndFunc

If you prefer arrays for readability, you're welcome to rewrite it. :)

 

Link to comment
Share on other sites

I posted something about DllCall in the C# section. Care to take a look.  It is too complex for me and I cant find the corresponding values in the lookup.  I cant do it :(

Honestly, I probably don't know any more than you.  I stopped when I reached the limit of what this code generator can do because that was all I've needed so far.  If the code generator can't solve it and it's not covered on pages 1 to 8 of the linked PDF, I probably can't do it either.  Good luck, though!

Link to comment
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
 Share

×
×
  • Create New...