Sign in to follow this  
Followers 0
JoshAssing

CallDll problems

3 posts in this topic

I have a dll that a client wants me to write a small script for; so I thought it would be a good time to learn to use AutoIT with DLL's.

$cDriveSN = DllCall(".\\GetDiskSerial.dll", "str", "GetSerialNumber", "int", 0, "str", "00000");

The 1st parameter is the drive # to fetch the serial # for.

The 2nd parameter is just the "registration code" to "unlock" the dll.

$cDriveSN is always empty.

What have I done wrong?

Thanks

-josh

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$cDriveSN = DllCall(".\\GetDiskSerial.dll", "str", "GetSerialNumber", "int", 0, "str", "00000")
Switch @ERROR
    Case 1
        ConsoleWrite("Unable to use the DLL file" & @CRLF)
    Case 2
        ConsoleWrite("Unknown return type", & @CRLF)
    Case 3
        ConsoleWrite("Function not found in the DLL file" & @CRLF)
EndSwitch

If IsArray($cDriveSN) Then
    For $X = 0 to Ubound($cDriveSN)-1
        ConsoleWrite("[" & $X & "]: " & $cDriveSN[$X] & @CRLF)
    Next
Else
    ConsoleWrite("$cDriveSN is not an array" & @CRLF)
EndIf

Edited by weaponx

Share this post


Link to post
Share on other sites

Thanks for being gentle... I had just figured out my bonehead mistake -- I wasn't using the return value as an array "RTFM".. d'oh..

Thank you for your time.

-josh

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