Browse Source

1

样式分支
fyf 1 year ago
parent
commit
006a24f850
2 changed files with 34 additions and 1 deletions
  1. +1
    -0
      BPASmart.MenuLoad/App.xaml.cs
  2. +33
    -1
      BeDesignerSCADA/Helper/SystemHelper.cs

+ 1
- 0
BPASmart.MenuLoad/App.xaml.cs View File

@@ -47,6 +47,7 @@ namespace BPASmart.MenuLoad
this.Dispatcher.Invoke(() => {
if (File.Exists(_path))
{
SystemHelperNew.GetInstance.CreateDesktopShortcut("BeDesignerSCADA.exe");
SystemHelperNew.GetInstance.CreateDesktopShortcut();
run.LoadingData(_path);
run.Show();


+ 33
- 1
BeDesignerSCADA/Helper/SystemHelper.cs View File

@@ -44,7 +44,6 @@ namespace BeDesignerSCADA.Helper
if (System.IO.File.Exists(deskTop + GetApplicationName + ".lnk")) //
{
return true;
//System.IO.File.Delete(deskTop + FileName + ".lnk");//删除原来的桌面快捷键方式
}
WshShell shell = new WshShell();
//快捷键方式创建的位置、名称
@@ -66,6 +65,39 @@ namespace BeDesignerSCADA.Helper
}
}

public bool CreateDesktopShortcut(string Name)
{
//1、在COM对象中找到 Windows Script Host Object Model
//2、添加引用 using IWshRuntimeLibrary;
string deskTop = string.Empty;
try
{
deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\";
if (System.IO.File.Exists(deskTop + Name + ".lnk")) //
{
return true;
}
WshShell shell = new WshShell();
//快捷键方式创建的位置、名称
IWshShortcut shortcut = shell.CreateShortcut(deskTop + Name + ".lnk") as IWshShortcut;
shortcut.TargetPath = GetApplicationPath; //目标文件
//该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
shortcut.Description = Name; //描述
//shortcut.IconLocation = exePath + "\\logo.ico"; //快捷方式图标
shortcut.Arguments = "";
//shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键
shortcut.Save(); //必须调用保存快捷才成创建成功
return true;
}
catch (Exception ex)
{
return false;
}
}


/// <summary>
/// 设置开机自启动
/// </summary>


Loading…
Cancel
Save