File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 1010 ole32 = syscall .NewLazyDLL ("ole32.dll" )
1111
1212 CLSIDFromProgID = ole32 .NewProc ("CLSIDFromProgID" )
13+ CoCreateGuid = ole32 .NewProc ("CoCreateGuid" )
1314 CoCreateInstance = ole32 .NewProc ("CoCreateInstance" )
1415 CoInitializeEx = ole32 .NewProc ("CoInitializeEx" )
1516 CoTaskMemAlloc = ole32 .NewProc ("CoTaskMemAlloc" )
Original file line number Diff line number Diff line change @@ -44,6 +44,22 @@ func CLSIDFromProgID(progId string) (co.CLSID, error) {
4444 }
4545}
4646
47+ // [CoCreateGuid] function.
48+ //
49+ // This function creates a globally unique 128-bit integer.
50+ //
51+ // [CoCreateGuid]: https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateguid
52+ func CoCreateGuid () win.GUID {
53+ var guid win.GUID
54+ ret , _ , _ := syscall .SyscallN (proc .CoCreateGuid .Addr (),
55+ uintptr (unsafe .Pointer (& guid )))
56+ if hr := errco .ERROR (ret ); hr == errco .S_OK {
57+ return guid
58+ } else {
59+ panic (hr )
60+ }
61+ }
62+
4763// [CoCreateInstance] function.
4864//
4965// Creates a COM object from its CLSID + IID. The iUnkOuter is usually nil.
You can’t perform that action at this time.
0 commit comments