Jump to content
Sign in to follow this  

CallDll problems

Recommended Posts


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?



Share this post

Link to post
Share on other sites

$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)

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

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.


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.