gpt4 book ai didi

c# - 相当于 OS X 上的 user32.dll

转载 作者:太空狗 更新时间:2023-10-29 21:37:14 26 4
gpt4 key购买 nike

我正在编写一个库,它使用了 Windows user32.dll 库中的一些函数,但我正在用 Mono 编译它以查看它在 OS X 上的表现。不幸的是,由于显而易见的原因,它找不到 user32.dll 库。

但我的问题是……在 OS X 上是否有我可以使用的类似库?我正在寻找以下功能。

[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);

我认为安装 WINE 会有所帮助,但我希望尽可能避免安装它。使用 Ruby win32 包装器也是一种选择?

最佳答案

来自 the Mono website :

If you are calling something that is provided by your platform (usually the win32 API), you will have to find a way to accomplish the same functionality on all your target platforms. This could mean replacing your unmanaged call with a managed equivalent, or it can mean detecting what platform you are running on and calling the Win32/*nix/OSX/etc. equivalent.

(http://pinvoke.net can sometimes help you find the managed equivalent to Win32 API calls.)

If you are calling into your own native library, then it depends on the cross-platform capabilities of your library. If your native library will work on all your target platforms, then your application should be fine. If not, you can make your native library cross-platform compatible, do the operation in managed code, or work around it by detecting what platform you are running on.

他们还链接到 Interop with Native Libraries 上的页面.

浏览pinvoke ,一个结果是 GetForegroundWindow 引用 mwinapi -- 乍一看,这看起来不可移植,因此您可能找不到托管解决方案。

关于c# - 相当于 OS X 上的 user32.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1314645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com