我正在对DeSmuME的过程进行基本测试MoveWindow(handle, 0, 0, 1280, 720, true)
,它根本没有任何变化,我至少希望它的X / Y pos变为0(屏幕的左上角),但是没有,什么也没有根本不奇怪的是,它能很好地处理手柄,RECT结构也能在其上工作,它还能很好地处理位置。
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect);
[DllImport("user32.dll", SetLastError = true)]
static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int Width, int Height, bool Repaint);
static void Main(string[] args) {
Process[] processes = Process.GetProcessesByName("DeSmuME_X432R_x64");
foreach (Process p in processes) {
IntPtr handle = p.MainWindowHandle;
RECT Rect = new RECT();
if (GetWindowRect(handle, ref Rect)) {
MoveWindow(handle, 0, 0, 1280, 720, true);
}
Console.WriteLine(Rect.right);
Console.ReadLine();
}
}