//引入API函數
[DllImportAttribute("user32.dll")]
public static extern int FindWindow(string ClassName,string WindowName);
[DllImport("user32.dll")]
public static extern int ShowWindow(int handle, int cmdShow);
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);
private const int SW_HIDE=0;//API參數表示隱藏窗口
private const int SW_SHOW=5;//API參數表示用當前的大小和位置顯示窗口
public static void 彈出光驅()
{
mciSendString("set CDAudio door open", null, 127, 0);
}
public static void 關閉光驅()
{
mciSendString("set CDAudio door closed", null, 127, 0);
}
public static void 打開C盤()
{
Process.Start("c:""");
}
public static void 打開D盤()
{
Process.Start("d:""");
}
public static void 打開E盤()
{
Process.Start("e:""");
}
public static void 打開F盤()
{
Process.Start("f:""");
}
public static void 打開指定盤(string hardpath)
{
Process.Start(hardpath);
}
public static void 打開Word()
{
Process.Start(@"C:"Program Files"Microsoft Office"OFFICE11"winword.exe");
}
public static void 打開Excel()
{
Process.Start(@"C:"Program Files"Microsoft Office"OFFICE11"excel.exe");
}
public static void 打開Access()
{
Process.Start(@"C:"Program Files"Microsoft Office"OFFICE11"msaccess.exe");
}
public static void 打開PowerPoint()
{
Process.Start(@"C:"Program Files"Microsoft Office"OFFICE11"powerpnt.exe");
}
public static void 打開OutLook()
{
Process.Start(@"C:"Program Files"Microsoft Office"OFFICE11"outlook.exe");
}
public static void 打開記事本()