我想运行一个网页,当用户登录到他们的用户帐户..。在我的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