' http://www.tramontana.co.hu/wix/download.php?file=uuidgen.c&type=text/xc
#Include "windows.bi"
#Include "win/uuids.bi"
#Include "win/ole2.bi"
Declare Function main (ByVal argc As Integer, ByVal argv As ZString Ptr Ptr) As Integer
End main( __FB_ARGC__, __FB_ARGV__ )
Private Function main(ByVal argc As Integer, ByVal argv As ZString Ptr Ptr) As Integer
Dim guid As GUID
Dim wstrGUID As LPOLESTR
Dim strGUID As ZString * 260
Dim As Integer count
If (argc <> 2)Then
Open Err For Input As #1
Print #1,"SYNTAX: UUIDGEN <number-of-GUIDs-to-generate>"
Close #1
Return 1
EndIf
count = CInt(*argv[1])
While (count > 0)
CoCreateGuid (@guid)
If(StringFromCLSID (@guid, @wstrGUID) = S_OK) THEN
WideCharToMultiByte (CP_ACP, 0, Cast(WString Ptr,wstrGUID), -1, strGUID, MAX_PATH, NULL, NULL)
Print strGUID
EndIf
CoTaskMemFree(@wstrGUID)
count -= 1
Wend
Return 0
End Function
' http://www.tramontana.co.hu/wix/download.php?file=uuidgen.c&type=text/xc
#Include "windows.bi"
#Include "win/uuids.bi"
#Include "win/ole2.bi"
Declare Function main (ByVal argc As Integer, ByVal argv As ZString Ptr Ptr) As Integer
End main( __FB_ARGC__, __FB_ARGV__ )
Private Function main(ByVal argc As Integer, ByVal argv As ZString Ptr Ptr) As Integer
Dim guid As GUID
Dim wstrGUID As LPOLESTR
Dim strGUID As ZString * 260
Dim As Integer count
If (argc <> 2)Then
Open Err For Input As #1
Print #1,"SYNTAX: UUIDGEN <number-of-GUIDs-to-generate>"
Close #1
Return 1
EndIf
count = CInt(*argv[1])
While (count > 0)
CoCreateGuid (@guid)
If(StringFromCLSID (@guid, @wstrGUID) = S_OK) THEN
WideCharToMultiByte (CP_ACP, 0, Cast(WString Ptr,wstrGUID), -1, strGUID, MAX_PATH, NULL, NULL)
Print strGUID
EndIf
CoTaskMemFree(@wstrGUID)
count -= 1
Wend
Return 0
End Function
You need a GUID for most installers because it's needed to register programs in the Registry so you can uninstall them using Add& Remove Programs. See http://en.wikipedia.org/wiki/Guid
dim s as string
dim t as double
t = timer
for i as ulong = 0 to 80000000
s = "{8421CBA2-6730-4A72-AB1D-7E53556BBA96}"
s = mid(s, 2, len(s) - 2)
's = trim(s, Any "{}")
next
t = timer - t
print t
sleep
end
If you want it optimized, work on the binary representation after CoCreateGuid (@guid), and don't convert it to string, and then take convert it back again.
dim s as string
dim t as double
t = timer
for i as ulong = 0 to 80000000
s = "{8421CBA2-6730-4A72-AB1D-7E53556BBA96}"
s = mid(s, 2, len(s) - 2)
's = trim(s, Any "{}")
next
t = timer - t
print t
sleep
end
;)
LOL, Munair, fair enough. I'll use the less intuitive syntax the next time I need to save those 4 seconds on 80 million iterations should such a real world example ever present itself.