小编Dav*_*ral的帖子

调整其他窗口或应用程序的大小c#

我正在尝试使用c#将窗口调整为1280x720的分辨率.我该怎么做?我在堆栈中尝试了很多代码,我得到的最接近的结果是:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [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("notepad");
            foreach (Process p in processes)
            {
                IntPtr handle = …
Run Code Online (Sandbox Code Playgroud)

c# windows

4
推荐指数
1
解决办法
2245
查看次数

标签 统计

c# ×1

windows ×1