Sign in to follow this  
Followers 0
weaponx

$tagGUID

4 posts in this topic

#1 ·  Posted (edited)

The MSDN Shows this for a GUID structure:

typedef struct _GUID {
 DWORD Data1;
   WORD Data2;
   WORD Data3;
   BYTE Data4[8];
 } GUID;

The AutoIt implementation:

$tagGUID = "int Data1;short Data2;short Data3;byte Data4[8]"

This reference shows "Word" as an unsigned datatype but "short" is signed in AutoIt.

http://msdn.microsoft.com/en-us/library/aa505945.aspx

Shouldn't "short" be "ushort" in $tagGUID?

Edited by weaponx

Share this post


Link to post
Share on other sites



As long as it's the same width of data, it'll work, but I can't say for sure what might happen.

Share this post


Link to post
Share on other sites

Technically, yes, it should be ushort but in reality it doesn't matter. The size is correct, which is the most important thing.

Share this post


Link to post
Share on other sites

Right :P when converting to hex, the result is still the same. ( You can even, like me, change the byte[8] to ushort; byte[6], so it's easier to convert it to the default GUID-Style :P )

;===============================================================================
;
; Function Name:   _CreateGUID
; Description::    Creates a GUID
; Parameter(s):    
; Requirement(s):  
; Return Value(s): 
; Author(s):       Prog@ndy
;
;===============================================================================
;

Func _CreateGUID()
    Local Const $tagGUID = "DWORD Data1; ushort Data2; ushort Data3; ushort Data4; BYTE Data5[6]"
    Local Const $tagGUID2 = "int Data1; short Data2; short Data3; short Data4; BYTE Data5[6]"
    Local $GUID = DllStructCreate($tagGUID)
    Local $ret = DllCall("OLE32.dll","long","CoCreateGuid","ptr",DllStructGetPtr($GUID))
    If @error Then
        Return SetError(1,0,"")
    ElseIf $ret[0] <> 0 Then
        Return SetError($ret[0],0,"")
    EndIf
        $GUID2 = DllStructCreate($tagGUID2,DllStructGetPtr($GUID))
    Local $string2 = "{" & Hex(DllStructGetData($GUID2,"Data1"),8) & "-" & _
        Hex(DllStructGetData($GUID2,"Data2"),4) & "-" & _
        Hex(DllStructGetData($GUID2,"Data3"),4) & "-" & _
        Hex(DllStructGetData($GUID2,"Data4"),4) & "-" & _
        Hex(DllStructGetData($GUID2,"Data5"),12) & "}"
    Local $string = "{" & Hex(DllStructGetData($GUID,"Data1"),8) & "-" & _
        Hex(DllStructGetData($GUID,"Data2"),4) & "-" & _
        Hex(DllStructGetData($GUID,"Data3"),4) & "-" & _
        Hex(DllStructGetData($GUID,"Data4"),4) & "-" & _
        Hex(DllStructGetData($GUID,"Data5"),12) & "}"
        MsgBox(0, '', $string & @CRLF & $string2)
    Return $string
EndFunc
_CreateGUID()

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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