我正在尝试访问 Kubuntu Linux 上某些 user32 函数的 Wine 实现。我安装了 Wine 1.1.31 软件包。当尝试在 MonoDevelop 中运行这个简单的测试程序时,我得到一个System.EntryPointNotFoundException
.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace PinvokeTesting
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine(GetKeyState((int)Keys.A));
}
[DllImport("user32")]
private static extern short GetKeyState(int vKey);
}
}
这是输出:
未处理的异常:System.EntryPointNotFoundException:GetKeyState at (wrapper managed-to-native) PinvokeTesting.MainClass:GetKeyState (int) at PinvokeTesting.MainClass.Main (System.String[] args) [0x00000] in .../Main.cs :11
该功能应该在那里,但它没有找到它。有任何想法吗?我做了很多搜索,没有找到任何有用的东西。关于这些问题的文档似乎相当稀疏(或者我正在寻找错误的东西)。
编辑:我没有尝试将 P/Invoke 与 Winforms 结合使用,Wine 中还有一些其他功能需要 P/Invoke 来使用。我只是想让 Mono P/Invoke to Wine 工作。