Sign in to follow this  
Followers 0
pdaughe

UuidCreateSequential Function

5 posts in this topic

There have been several threads discussing how to UNIQUELY identify a user's computer. The MAC address is often brought up.

The UuidCreateSequential provides a "better" identifier (http://msdn.microsoft.com/en-us/library/aa379322(VS.85).aspx)

Msdn UuidCreateSequential Function

The function resides in Rpcrt4.dll, included in all Windows operating system 2000 and above, including Vista.

I'm just not experienced enough to see how to translate the syntax shown on Msdn to an AutoIt DLL call.

I'd like to use the function and expect it would be of interest to many others.

Your help would be appreciated.

Thanks,

Paul

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

I'm hoping that someone who knows how to do this sees this:

Local $Uuid_Ptr = DllStructCreate ("ptr")

Local $Result = DllCall ("Rpcrt4.dll", "ptr", "UuidCreateSequential", "ptr", DllStructGetPtr ($Uuid_Ptr))

MsgBox (0, "", "Result[0] = " & $Result[0] & @CRLF & "Result[1] = " & $Result[1])

The above code does not "fail", but that doesn't mean it works either.

Is the correct answer in $Result[1]??

I've just never quite understood how to "read" Msdn. It says the function "returns a value". The AutoIt doc says $Result[1] contains a parameter that the function modified?

Can someone tell me if the "answer" is in $Result[1]?

$Result[1] is always the same value. Still doesn't mean I'm interpretting this correctly...

Edited by pdaughe

Share this post


Link to post
Share on other sites

You gotta make a UUID struct (http://msdn.microsoft.com/en-us/library/aa379358(VS.85).aspx) and pass it as the pointer. Like so:

Global $tagUUID = "ulong Data1;ushort Data2;ushort Data3;ubyte Data4[8]"
Global $hUUID, $aResult, $sUUID

$hUUID = DllStructCreate($tagUUID)
$aResult = DllCall("Rpcrt4.dll", "int", "UuidCreateSequential", "ptr", DllStructGetPtr($hUUID))
If $aResult[0] = 0 Then
    $sUUID = Hex(DllStructGetData($hUUID, "Data1")) & "-" & Hex(DllStructGetData($hUUID, "Data2"), 4) & "-" & _
        Hex(DllStructGetData($hUUID, "Data3"), 4) & "-" & Hex(DllStructGetData($hUUID, "Data4", 1), 2) & _
        Hex(DllStructGetData($hUUID, "Data4", 2), 2) & "-" & Hex(DllStructGetData($hUUID, "Data4", 3), 2) & _
        Hex(DllStructGetData($hUUID, "Data4", 4), 2) & Hex(DllStructGetData($hUUID, "Data4", 5), 2) & _
        Hex(DllStructGetData($hUUID, "Data4", 6), 2) & Hex(DllStructGetData($hUUID, "Data4", 7), 2) & _
        Hex(DllStructGetData($hUUID, "Data4", 8), 2)
    MsgBox(0, "UUID", $sUUID)
EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Isn't this function only to create the UUID for the running instance of the app... I was under the assumption it changed on every running instance.

I would think that you would need to retrieve the systems UUID ,and if it didn't have a set UUID, to set the UUID for the system so it didn't change. (Only if you were looking at distinguishing between unique PCs)

Edit:

I'll add this...

I've often looked for an "easy/simple" method (API call) to retrieve the systems UUID without the use of WMI ... though I've found methods, none have been easily implemented.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks zorphnog -- I wouldn't have gotten that one. Appreciate it very much.

SmOke_N -- well now that I run zorphnog's code, I see that you are right. It does change. I was so focused on the fact that it was globally unique and trying to get the DLLCall that I, well -- strike out, that's one way to learn!

(he feels just a tad-bit foolish) :) :)

Thanks very much you guys for your help.

Paul

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