我想運行一個網頁,當用戶登錄到他們的用戶帳戶..。在我的C#應用程序..如何在Windows登錄時打開網頁?
string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
我想運行一個網頁,當用戶登錄到他們的用戶帳戶..。在我的C#應用程序..如何在Windows登錄時打開網頁?
string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
您可以創建一個批處理文件,並安排其運行時,每次用戶登錄。
該批處理文件將只有一行。
start <url>
例如
start http://www.google.ca
這個腳本會在用戶的默認Web瀏覽器打開<網址>。
private void CreateUrlShortcut(string linkName, string linkUrl)
{
string dir = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
using (StreamWriter writer = new StreamWriter(dir + "\\" + linkName + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.Flush();
}
}
卡爾上述funaction如下:
CreateUrlShortcut("google link", "http://www.google.ca/");
我不知道我明白了一切。但是,這裏有一個代碼示例,一旦用戶登錄,將打開存儲在應用程序中的(*。Html)網頁。
bool isLoged = //...
//Get the absolute path of the application
DirectoryInfo myPathWork = new DirectoryInfo(Environment.CurrentDirectory);
//if the use is loged
if(isLoged)
{
//Open web page stored in the directory of the application with the default web browser.
Process.Start(myPathWork.FullName+"myWebPage.html");
}
那麼,什麼問題?你能詳細說一下嗎? – Dietz 2013-04-29 06:15:57
@ChristianDietz有沒有問題我wana轉到www.google.ca當用戶登錄到Windows ... – IceDawg 2013-04-29 06:20:59