1、在桌面空白处右击鼠标键,选择最下方的“个性化”按钮。
2、点击选择左侧的“任务栏”按钮。
3、进入任务设置窗口界面,找到其中的“在桌面模式下自动隐藏任务栏”字样。
4、找到该字样下方的“开关”按钮。
5、然后点击打开。
6、此时的任务栏已经被隐藏了。
给一个比较万能方法,其实调用 cmd 、ipconfig命令
private void GetIP6()2 {
3 Process cmd = new Process()
4 cmd.StartInfo.FileName = "ipconfig.exe"//设置程序名
5 cmd.StartInfo.Arguments = "/all" //参数
6 //重定向标准输出
7 cmd.StartInfo.RedirectStandardOutput = true
8 cmd.StartInfo.RedirectStandardInput = true
9 cmd.StartInfo.UseShellExecute = false
10 cmd.StartInfo.CreateNoWindow = true//不显示窗口(控制台程序是黑屏)
11 //cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden//暂时不明白什么意思
12 /*
13 收集一下 有备无患
14 关于:ProcessWindowStyle.Hidden隐藏后如何再显示?
15 hwndWin32Host = Win32Native.FindWindow(null, win32Exinfo.windowsName)
16 Win32Native.ShowWindow(hwndWin32Host, 1) //先FindWindow找到窗口后再ShowWindow
17 */
18 cmd.Start()
19 string info = cmd.StandardOutput.ReadToEnd()
20 cmd.WaitForExit()
21 cmd.Close()
22 textBox1.AppendText(info)
23 }
你看看你的嵌入函数对不对
using Systemusing System.Windows.Forms
using System.Runtime.InteropServices
namespace ShowInDesk
{
public partial class Form1 : Form
{
IntPtr hDesktop
public const int GW_CHILD = 5
public Form1()
{
InitializeComponent()
this.hDesktop = GetDesktopHandle(DesktopLayer.Progman)
EmbedDesktop(this, this.Handle, this.hDesktop)
//isMouseDown = false
}
public IntPtr GetDesktopHandle(DesktopLayer layer)
{
//hWnd = new HandleRef()
HandleRef hWnd
IntPtr hDesktop = new IntPtr()
switch (layer)
{
case DesktopLayer.Progman:
hDesktop = Win32Support.FindWindow("Progman", null)//第一层桌面
break
case DesktopLayer.SHELLDLL:
hDesktop = Win32Support.FindWindow("Progman", null)//第一层桌面
hWnd = new HandleRef(this, hDesktop)
hDesktop = Win32Support.GetWindow(hWnd, GW_CHILD)//第2层桌面
break
case DesktopLayer.FolderView:
hDesktop = Win32Support.FindWindow("Progman", null)//第一层桌面
hWnd = new HandleRef(this, hDesktop)
hDesktop = Win32Support.GetWindow(hWnd, GW_CHILD)//第2层桌面
hWnd = new HandleRef(this, hDesktop)
hDesktop = Win32Support.GetWindow(hWnd, GW_CHILD)//第3层桌面
break
}
return hDesktop
}
public void EmbedDesktop(Object embeddedWindow, IntPtr childWindow, IntPtr parentWindow)
{
Form window = (Form)embeddedWindow
HandleRef HWND_BOTTOM = new HandleRef(embeddedWindow, new IntPtr(1))
const int SWP_FRAMECHANGED = 0x0020//发送窗口大小改变消息
Win32Support.SetParent(childWindow, parentWindow)
Win32Support.SetWindowPos(new HandleRef(window, childWindow), HWND_BOTTOM, 300, 300, window.Width, window.Height, SWP_FRAMECHANGED)
}
}
}
namespace ShowInDesk
{
class Win32Support
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string className, string windowName)
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetWindow(HandleRef hWnd, int nCmd)
[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr child, IntPtr parent)
[DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags)
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags)
[DllImport("user32.dll")]
public static extern int ReleaseDC(IntPtr window, IntPtr handle)
}
}
namespace ShowInDesk
{
public enum DesktopLayer
{
Progman = 0,
SHELLDLL = 1,
FolderView = 2
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)