0

我对 DeSmuME 的流程进行了基本测试MoveWindow(handle, 0, 0, 1280, 720, true),结果根本没有变化,我至少预计它的 X/Y 位置会变为 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();
  }
}
4

0 回答 0