
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Microsoft.Win32;
using IWshRuntimeLibrary;
namespace Iwp.IwpMain
{
static class MainClass
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string startpath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\旅游ERP系统\\旅行社机票管理系统.appref-ms";
//开机自启动 "C:\Documents and Settings\Administrator\「开始」菜单\程序\旅游ERP系统\旅行社机票管理系统.appref-ms"
////RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
////string sRtn = key.GetValue("myprog", "notexist").ToString();
////if (sRtn == "notexist")
////{
//// key.SetValue("myprog", startpath);
////}
////else
////{
//// if (sRtn != startpath)
//// key.SetValue("myprog", startpath);
////}
//创建快捷方式
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\旅游ERP系统222.lnk");
shortcut.TargetPath = startpath;
shortcut.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\旅游ERP系统";
shortcut.WindowStyle = 2;
////shortcut.Arguments = "/p XMAPGL /nologo"; //指向目标运行的参数
shortcut.Description = "旅游ERP系统";
shortcut.IconLocation = System.Environment.CurrentDirectory + "\\" + "icon.ico"; //System.Environment.SystemDirectory + "\\" + "shell32.dll, 163";
shortcut.Save();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//fMain mainfrm = new fMain();
//myform.CustomerForm = mainfrm;
Boolean createdNew;
System.Threading.Mutex m = new System.Threading.Mutex(true, "myprog", out createdNew);
if (createdNew)
{
Application.Run(new Form1());
m.ReleaseMutex();
}
else
{
MessageBox.Show("本程序只允许同时运行一个!");
}
}
}
using System.Collections.Generic;
using System.Windows.Forms;
using Microsoft.Win32;
using IWshRuntimeLibrary;
namespace Iwp.IwpMain
{
static class MainClass
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string startpath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\旅游ERP系统\\旅行社机票管理系统.appref-ms";
//开机自启动 "C:\Documents and Settings\Administrator\「开始」菜单\程序\旅游ERP系统\旅行社机票管理系统.appref-ms"
////RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
////string sRtn = key.GetValue("myprog", "notexist").ToString();
////if (sRtn == "notexist")
////{
//// key.SetValue("myprog", startpath);
////}
////else
////{
//// if (sRtn != startpath)
//// key.SetValue("myprog", startpath);
////}
//创建快捷方式
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\旅游ERP系统222.lnk");
shortcut.TargetPath = startpath;
shortcut.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\旅游ERP系统";
shortcut.WindowStyle = 2;
////shortcut.Arguments = "/p XMAPGL /nologo"; //指向目标运行的参数
shortcut.Description = "旅游ERP系统";
shortcut.IconLocation = System.Environment.CurrentDirectory + "\\" + "icon.ico"; //System.Environment.SystemDirectory + "\\" + "shell32.dll, 163";
shortcut.Save();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//fMain mainfrm = new fMain();
//myform.CustomerForm = mainfrm;
Boolean createdNew;
System.Threading.Mutex m = new System.Threading.Mutex(true, "myprog", out createdNew);
if (createdNew)
{
Application.Run(new Form1());
m.ReleaseMutex();
}
else
{
MessageBox.Show("本程序只允许同时运行一个!");
}
}
}
需要注意的细节:string startpath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\旅游ERP系统\\旅行社机票管理系统.appref-ms";
这里必需在启动pc机器开始>程序中存在的,否则创建快捷方式后指向无效。。。。
需要的dll :
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端