ehi*_*ler 5 winapi go windows-runtime winrt-xaml uwp
syscall在Go中使用如何在Windows 10中调用UWP API?我已经看过并尝试了很多win32示例,但是当我尝试使用System.WindowsRuntime.dll它时是不行的; 具体来说,我收到:
panic: Failed to load System.WindowsRuntime.dll: The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)
(这是在运行时,二进制内置正常)
我尝试用标准go build和同时构建两者
go build -ldflags="-H windows"
Run Code Online (Sandbox Code Playgroud)
示例代码:
var(
windowsRuntime = syscall.NewLazyDLL("System.WindowsRuntime.dll")
getDiskFreeSpace = windowsRuntime.NewProc("GetDiskFreeSpace")
)
Run Code Online (Sandbox Code Playgroud)
注意:尝试了其他变体:
windowsRuntime = syscall.NewLazyDLL("System.Runtime.WindowsRuntime.dll")
Run Code Online (Sandbox Code Playgroud)
&
windowsRuntime = syscall.NewLazyDLL("WindowsRuntime.dll")
Run Code Online (Sandbox Code Playgroud)
任何人都可以得到这个运行或有任何建议吗?一如既往,非常感谢!!
我不知道你在哪里找到“System.WindowsRuntime.dll”,因为据我所知,它不存在(除非你手动创建了一个名为该DLL的DLL)。
至于System.Runtime.WindowsRuntime.dll:它是.NET Framework的一部分,而不是Windows的一部分,并且它是一个托管DLL。您无法使用 syscall.NewLazyDLL 加载此类 DLL。更重要的是,该 DLL 并不真正包含任何 Windows API - 只是 .NET 能够使用它们的粘合剂。
您可能正在combase.dll 中寻找类似RoGetActivationFactory 的函数。