【发布时间】:2018-11-20 20:20:24
【问题描述】:
我已经导入了 SetWindowPos 和 GetForegroundWindow:
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, UInt32 uFlags);
我尝试过使用它们,虽然 GetForegroundWindow 确实返回了一个有效值,但 SetWindowPos 没有做任何事情:
IntPtr hWID = GetForegroundWindow();
SetWindowPos(hWID, IntPtr.Zero, 50, 500, 800, 800, 0x0004);
我需要设置一些功能吗?还是我忘记了权限?
似乎将相同的代码块插入 .NET 项目会产生想要的结果。有没有办法在 UWP 中实现这一点,还是我必须在 .NET 中做到这一点?
【问题讨论】:
标签: uwp dllimport setwindowpos