SetWindowPos c# 一个这个问题的错误
SetWindowPosc#usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSyste...
SetWindowPos c#using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
int left;
int top;
int right;
int bottom;
}
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32")]
public static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long uFlags);
static void Main(string[] args)
{
IntPtr ptrWnd = GetForegroundWindow();
IntPtr hwnd = ptrWnd; // 窗口句柄
RECT rc;
RECT rc1;
GetWindowRect(hwnd, out rc);
GetClientRect(hwnd, out rc1);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, 0);
}
}
}
一运行就就跳出了,给看看
检测到 PInvokeStackImbalance
Message: 对 PInvoke 函数“ConsoleApplication1!ConsoleApplication1.Program::SetWindowPos”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。 展开
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
int left;
int top;
int right;
int bottom;
}
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32")]
public static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long uFlags);
static void Main(string[] args)
{
IntPtr ptrWnd = GetForegroundWindow();
IntPtr hwnd = ptrWnd; // 窗口句柄
RECT rc;
RECT rc1;
GetWindowRect(hwnd, out rc);
GetClientRect(hwnd, out rc1);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, 0);
}
}
}
一运行就就跳出了,给看看
检测到 PInvokeStackImbalance
Message: 对 PInvoke 函数“ConsoleApplication1!ConsoleApplication1.Program::SetWindowPos”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询