Golan: using Windows 10 API / UWP / System.WindowsRuntime?

Using syscall in Go, how can I call the UWP API in Windows 10? I saw and tried many win32 examples, but when I tried to use System.WindowsRuntime.dll , it was not-go; in particular, I received:

 panic: Failed to load System.WindowsRuntime.dll: The specified module could not be found. 

(this was a runtime binary constructed fine)

I tried to create both standard go build and

 go build -ldflags="-H windows" 

code example:

 var( windowsRuntime = syscall.NewLazyDLL("System.WindowsRuntime.dll") getDiskFreeSpace = windowsRuntime.NewProc("GetDiskFreeSpace") ) 

Note. Other options:

 windowsRuntime = syscall.NewLazyDLL("System.Runtime.WindowsRuntime.dll") 

&

 windowsRuntime = syscall.NewLazyDLL("WindowsRuntime.dll") 

Has anyone been able to get this job or have any advice on this? As always, very grateful !!

+5
source share
1 answer

I have no idea where you found "System.WindowsRuntime.dll" because, as far as I can tell, it does not exist (unless you manually created a DLL with the name).

Regarding System.Runtime.WindowsRuntime.dll: it is part of the .NET Framework, not Windows, and it is a managed DLL. You cannot load such DLL files using syscall.NewLazyDLL. What else, that the DLL does not actually contain any Windows APIs - just glue for .NET the ability to work with them.

You are probably looking for functions such as RoGetActivationFactory in the combase.dll file.

0
source

Source: https://habr.com/ru/post/1265829/


All Articles