namespace XXX
{
public partial class Form1 : Form
{
internal class User32
{
public const int SE_SHUTDOWN_PRIVILEGE = 0x13;
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
}
public Form1()
{
InitializeComponent();
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width - 50, 250);
try
{
if (Environment.OSVersion.Version.Major < 6)
{
base.SendToBack();
IntPtr hWndNewParent = User32.FindWindow("Progman", null);
User32.SetParent(base.Handle, hWndNewParent);
}
else
{
User32.SetWindowPos(base.Handle, 1, 0, 0, 0, 0, User32.SE_SHUTDOWN_PRIVILEGE);
}
}
catch
{
}
}
}
}
将程序钉在桌面上
最新推荐文章于 2023-03-02 13:24:11 发布