基本信息
源码名称:C# 创建虚拟桌面和原桌面切换 示例源码
源码大小:0.07M
文件格式:.rar
开发语言:C#
更新时间:2018-02-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using CSharpWin; using System.Diagnostics; namespace VirtualDesktopDemo { public partial class Form1 : Form { private VirtualDesktop _vDesktop; public Form1() { InitializeComponent(); _vDesktop = new VirtualDesktop("CSharpWin"); _vDesktop.CreateProcess("explorer.exe");//启动桌面浏览器。 _vDesktop.CreateProcess("ctfmon.exe");//启动输入法。 linkLabel1.Click = delegate(object sender, EventArgs e) { Process.Start("www.csharpwin.com"); }; } [DllImport("user32.dll")] public static extern bool RegisterHotKey( IntPtr wnd, int id, MODKEY mode, Keys vk); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr wnd, int id); public enum MODKEY { MOD_ALT = 0x0001, MOD_CONTROL = 0x0002, MOD_SHIFT = 0x0004, MOD_WIN = 0x0008, } protected override void OnLoad(EventArgs e) { base.OnLoad(e); RegisterHotKey(Handle, 0x10000, MODKEY.MOD_CONTROL, Keys.D1); RegisterHotKey(Handle, 0x10001, MODKEY.MOD_CONTROL, Keys.D2); } protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0x0312) { switch (m.WParam.ToInt32()) { case 0x10000: _vDesktop.Show();//切换到虚拟桌面 break; case 0x10001: VirtualDesktop.Default.Show();//切换到默认桌面 break; } } } protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); if (!e.Cancel) { UnregisterHotKey(Handle, 0x10000); UnregisterHotKey(Handle, 0x10001); if (_vDesktop != null) { _vDesktop.Close(); } } } } }