Supports: Win9x, WINNT, WIN2K and WINXP
Requires: System Plugin
Archive: http://nsis.sourceforge.net/archive/...74&instances=0
;Call CreateGUID
;Pop $0 ;contains GUID
Function CreateGUID
Push $R0
Push $R1
Push $R2
Push $R3
Push $R4
;allocate space for character array
System::Alloc 15
;get pointer to new space
Pop $R1
;call the CoCreateGuid api in the ole32.dll
System::Call 'ole32::CoCreateGuid(i R1) i .R2'
;if 0 then continue
IntCmp $R2 0 0 lbl_done
;set counter to 0
StrCpy $R3 0
lbl_loop:
;increment counter
IntOp $R3 $R3 + 1
;if less than 16 then continue
IntCmp $R3 16 lbl_done 0 lbl_done
;retrieve item in character array
System::Call "*$R1(&t$R3-1, &i1 .R2)"
;convert to hex
IntFmt $R4 "%X" $R2
StrCpy $R4 "00$R4"
StrLen $R2 $R4
IntOp $R2 $R2 - 2
StrCpy $R4 $R4 2 $R2
StrCpy $R0 "$R0$R4"
Goto lbl_loop
lbl_done:
;cleanup
System::Free $R1
;format guid
StrCpy $R1 $R0
StrCpy $R0 ""
StrCpy $R2 $R1 8
StrCpy $R0 "$R0$R2-"
StrCpy $R2 $R1 4 8
StrCpy $R0 "$R0$R2-"
StrCpy $R2 $R1 4 12
StrCpy $R0 "$R0$R2-"
StrCpy $R2 $R1 4 16
StrCpy $R0 "$R0$R2-"
StrCpy $R2 $R1 12 20
StrCpy $R0 "$R0$R2"
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd