--- /dev/null
+! Copyright (C) 2016 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax kernel windows.kernel32 ;
+IN: windows.ole32
+
+HELP: create-guid
+{ $values
+ { "GUID" GUID }
+}
+{ $description "Generate a new random " { $link GUID } " value." } ;
-USING: kernel tools.test windows.ole32 alien.c-types
-classes.struct specialized-arrays windows.kernel32
-windows.com.syntax ;
+USING: alien.c-types classes.struct kernel math sequences
+specialized-arrays
+specialized-arrays.instances.alien.c-types.uchar tools.test
+windows.com.syntax windows.kernel32 windows.ole32 ;
SPECIALIZED-ARRAY: uchar
IN: windows.ole32.tests
[ "{01234567-89ab-cdef-0123-456789abcdef}" ]
[ "{01234567-89ab-cdef-0123-456789abcdef}" string>guid guid>string ]
unit-test
+
+{ 0 } [ 10 [ create-guid ] replicate duplicates length ] unit-test
TYPEDEF: REFGUID REFCLSID
FUNCTION: HRESULT CoCreateInstance ( REFGUID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFGUID riid, LPUNKNOWN out_ppv )
+FUNCTION: HRESULT CoCreateGuid ( GUID* pguid )
FUNCTION: BOOL IsEqualGUID ( REFGUID rguid1, REFGUID rguid2 )
FUNCTION: int StringFromGUID2 ( REFGUID rguid, LPOLESTR lpsz, int cchMax )
FUNCTION: HRESULT CLSIDFromString ( LPOLESTR lpsz, REFGUID out_rguid )
CONSTANT: GUID-STRING-LENGTH
$[ "{01234567-89ab-cdef-0123-456789abcdef}" length ]
+: create-guid ( -- GUID )
+ GUID <struct> dup CoCreateGuid check-ole32-error ;
+
: string>guid ( string -- guid )
"{-}" split harvest
[ first3 [ hex> ] tri@ ]