04
2012
04

C# 实现直接从程序返回桌面

如何用PROCESS类的START()公共方法执行SCF文件实现直接从程序界面返回到桌面,效果同用系统右键单击

显示桌面按钮相同

实现直接从程序返回桌面的MyDesktop.scf

如下:

[shell]
command=2
IcoFile=Explorer.exe,3
[Taskbar]
Command=ToggleDesktop
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace 显示桌面
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

//右键双击返回桌面同样返回桌面
private void 返回桌面ToolStripMenuItem_Click(object sender, EventArgs e)
{
//
System.Diagnostics.Process Myprocess;
try
{
Myprocess = new System.Diagnostics.Process();
//打开MyDesktop.scf
Myprocess.StartInfo.FileName = "MyDesktop.scf";
Myprocess.StartInfo.Verb = "Open";
Myprocess.Start();

}
catch (Exception ex)
{
//程序出错时提示信息
MessageBox.Show(ex.Message,"信息提示!",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}

private void Form1_Load(object sender, EventArgs e)
{
//窗口起始状态
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
//窗体完全透明,这个可要可不要。.
this.Opacity = 0;
//不显示在任务栏
this.ShowInTaskbar = false;
}
}
}
« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。