我正在尝试使用 pInvoke,但在模拟器和设备上调用都失败了。我是 .NET 的新手(我是 C++ 开发人员),我不明白 JIT/框架如何找不到那个 DLL/方法/等。
我还需要做些什么才能让它工作吗?
在查看类似问题时,似乎我可能需要也可能不需要将 DLL 添加到解决方案或 CAB 中 - 但我从哪里获得该文件。
设备上的操作系统肯定有 user32.dll 吗?而且 Windows 7 版本不可能是正确安装在设备上的版本,不是吗?
编辑
这些中的任何一个都失败了:
[DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport("coredll.dll", EntryPoint = "SipShowIM")]
public static extern bool SipShowIMP(int code);
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();