数据库在目标机器中已建立。
我用Vs自动的打包工具打包的,在IE地址栏中输入可以实现。
我看了一些材料说是建立安装程序类,对于这个我想知道,安装程序类是在安装的时候自动调用的么
目前我在程序中应该追加什么操作可以实现上述功能,好像比带数据库的简单多了,可是我还是没实现初学c#,还请勿见笑!!
类中代码如下:
public static void Main()
{
string address = @"http://Localhost/SMHS/QJ/Login.aspx";
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string logoPath = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName + "\\SMHS.ICO";
FileInfo fi = new FileInfo(path+"\\My Web ShortCut.url"); using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine("[InternetShortcut]");
sw.WriteLine("URL=" + address);
sw.WriteLine("IconIndex=0");
sw.WriteLine("IconFile=" + logoPath);
}
}
我只是更改了address,icon,那个FileInfo fi = new FileInfopath+"\\My Web ShortCut.url")什么意思?
我用Vs自动的打包工具打包的,在IE地址栏中输入可以实现。
我看了一些材料说是建立安装程序类,对于这个我想知道,安装程序类是在安装的时候自动调用的么
目前我在程序中应该追加什么操作可以实现上述功能,好像比带数据库的简单多了,可是我还是没实现初学c#,还请勿见笑!!
类中代码如下:
public static void Main()
{
string address = @"http://Localhost/SMHS/QJ/Login.aspx";
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string logoPath = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName + "\\SMHS.ICO";
FileInfo fi = new FileInfo(path+"\\My Web ShortCut.url"); using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine("[InternetShortcut]");
sw.WriteLine("URL=" + address);
sw.WriteLine("IconIndex=0");
sw.WriteLine("IconFile=" + logoPath);
}
}
我只是更改了address,icon,那个FileInfo fi = new FileInfopath+"\\My Web ShortCut.url")什么意思?
首先添加以下引用:COM下Windows Script Host Object Model,然后可以通过以下方法创建快捷方式。using System.Runtime.InteropServices;using IWshRuntimeLibrary;string app = "http://localhost/TrainManage/Default.aspx";string location1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\培训教学教务管理系统.url";string location2 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\培训教学教务管理系统.url";
string location3 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs) + "\\培训教学教务管理系统.url";try
{
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();// Define the shortcut file
IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save();
shortcut = shell.CreateShortcut(location2) as IWshURLShortcut; shortcut.TargetPath = app;
// Save it
shortcut.Save();
shortcut = shell.CreateShortcut(location3) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save();
}
catch{}