-2
我做在Microsoft Visual C#應用程序2010年C#:獲取程序啓動與Windows
我想這個應用程序在用戶啓動他們的計算機啓動。在桌面上顯示一個簡短的屏幕,然後最小化到任務欄。
我搜索了Google,找不到解釋它的地方,我可以理解。
我將不勝感激任何幫助,你們可以提供!
感謝
我做在Microsoft Visual C#應用程序2010年C#:獲取程序啓動與Windows
我想這個應用程序在用戶啓動他們的計算機啓動。在桌面上顯示一個簡短的屏幕,然後最小化到任務欄。
我搜索了Google,找不到解釋它的地方,我可以理解。
我將不勝感激任何幫助,你們可以提供!
感謝
您必須使用using Microsoft.Win32;
命名空間,那麼你可以使用註冊表工作。
試試這個:
// The path to the key where Windows looks for startup applications
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
// Add the value in the registry so that the application runs at startup
rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());
// Remove the value from the registry so that the application doesn't start
rkApp.DeleteValue("MyApp", false);
// Check to see the current state (running at startup or not)
if (rkApp.GetValue("MyApp") == null)
{
// The value doesn't exist, the application is not set to run at startup
chkRun.Checked = false;
}
else
{
// The value exists, the application is set to run at startup
chkRun.Checked = true;
}
我討厭潛伏在「運行」鍵中的程序。 – Steve
你不能弄清楚哪一部分呢?讓它自動啓動?讓它在桌面上顯示一個簡短的屏幕,或將它縮小到任務欄? – aquinas
只需在用戶的啓動文件夾中創建一個快捷方式即可。無論如何,只有用戶登錄後,才能在桌面上運行應用程序,並且任務欄在該點之前都不可用。 –
另外,你使用winforms,WPF或其他? – coolmine