Der Linux-Teil basiert auf einem Tipp von freak, hierzu ist dann die uuid-dev
(unter Ubuntu, ansonsten heißt die evtl. leicht anders) zu installieren.
Funktioniert unter Windows und Linux, x86, x64, unicode oder ascii.
Erweiterung für MacOS sollte möglich sein, ich habe aber keinerlei Zugang
zu solchen Geräten.
Code: Alles auswählen
CompilerIf Defined(GUID, #PB_Structure) = #False
Structure GUID
Data1.l
Data2.w
Data3.w
Data4.b[8]
EndStructure
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; requires uuid-dev
ImportC "-luuid"
uuid_generate(*out.GUID)
uuid_unparse_upper(*uu.GUID, *out)
EndImport
CompilerEndIf
Procedure.s MakeGUID()
Protected guid.GUID, result.s
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
result = Space(36)
uuid_generate(@guid)
uuid_unparse_upper(@guid, @result)
result = "{" + PeekS(@result, -1, #PB_Ascii) + "}"
CompilerCase #PB_OS_Windows
Protected lpsz.s{76}
If CoCreateGuid_(@guid) = #S_OK
result = PeekS(@lpsz, StringFromGUID2_(guid, @lpsz, 76), #PB_Unicode)
EndIf
CompilerDefault
CompilerEndSelect
ProcedureReturn result
EndProcedure
Debug MakeGUID()
Thomas