I'm trying to read values from the windows property system, specifically the System.Identity.UniqueID (Ref: https://learn.microsoft.com/en-us/windows/win32/properties/props-system-identity-uniqueid). Is there a way to read this from Go ? either natively, or through C-Go?
3 Answers
The most simple way to read from Property System APIs in Go is to build a dll written in c++, as this requires using COM (and Go definitions for COM are often incomplete/have issues). Microsoft provides a sample project for reading and writing the values to and from files here.
If you want to implement it in pure Go take a look at go-wca and its CaptureSharedEventDriven sample. This library implements the IPropertyStore interface and some of its dependencies in GO although the example is using it to get the device friendly name from the Property Store (you will need to implement the WinAPI calls if you want to read it from files).

- 236
- 1
- 1
The Go project denisbrodbeck/machineid proposes to use machineid
in id_windows.g
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Cryptography`, registry.QUERY_VALUE|registry.WOW64_64KEY)
That is because of issue #2
They suggested the assembly: System.Identity.UniqueID
I know of this thread, but I've never managed to get hold of that specific value. Information on google is +very+ sparse.
I've tried to fetch that value with C#, but never found the specific assembly to get that variable from
So System.Identity.UniqueID
does not seem easily readable.
You might have to combine other unique Windows properties, as in here.

- 1,262,500
- 529
- 4,410
- 5,250
-
I have already seen the package, and my search for the System.Identity.UniqueID started there. Looks like its an unicorn that no one can find :) – Tchinmai Jul 29 '20 at 20:26
-
1
I have no Windows machine, so I can't provide working example, but I suppose that you can take a look at RegOpenKeyEx and example of its usage at https://golang.hotexamples.com/examples/syscall/-/RegOpenKeyEx/golang-regopenkeyex-function-examples.html#0x086674b6787cae709f7567bc2c682e747cd85debf2a6db841413704af324bee9-50,,104,

- 1,967
- 14
- 14