четверг, 3 февраля 2011 г.

AutoIT UUID generation

I looked for a function to generate UUID for testing purposes.
So looking around the Google found this solution.
MsgBox ( 0, @ScriptName, _WinAPI_CreateGUID() )
 
Func _WinAPI_CreateGUID()
Local Const $tagGUID = "int Data1;short Data2;short Data3;byte Data4[8]"
Local $tData = DllStructCreate('wchar[39]')
Local $tGUID = DllStructCreate($tagGUID)
Local $Return
$Return = DllCall('ole32.dll', 'uint', 'CoCreateGuid', 'ptr', DllStructGetPtr($tGUID))
If @error Then Return SetError(1, 1, 0)
If $Return[0] Then Return SetError(1, $Return[0], 0)

$Return = DllCall('ole32.dll', 'int', 'StringFromGUID2', 'ptr', DllStructGetPtr($tGUID), 'ptr', DllStructGetPtr($tData), 'int', 39)
If (@error) Or (Not $Return[0]) Then Return SetError(1, 1, 0)
Return DllStructGetData($tData, 1)
EndFunc ;==>_WinAPI_CreateGUID


Комментариев нет:

Отправить комментарий