From 95d9356edef73a1ad5b04e62b7aef6b77697a226 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 05 九月 2024 10:13:30 +0800 Subject: [PATCH] 1 --- TEWin/FrmWin.cs | 19 ++++++++++++++++--- TEWin/TEWin.csproj | 9 +++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/TEWin/FrmWin.cs b/TEWin/FrmWin.cs index 704a0c8..7b6c236 100644 --- a/TEWin/FrmWin.cs +++ b/TEWin/FrmWin.cs @@ -792,7 +792,7 @@ { SaveLocation(); this.SG.Command.Execute(1019, 0); // Capture Tree State - SG.Command.Execute(1003, null); // this.SG.Project.Save(); + SG.Command.Execute(1003, 0); // this.SG.Project.Save(); } private void SaveAs(string flyPath) @@ -828,8 +828,9 @@ if (this.fly.Equals(flyPath)) return; if (File.Exists(flyPath)) File.Delete(flyPath); - string cmd = string.Format("mklink \"{0}\" \"{1}\"", flyPath, this.fly); - ExecCmd(new List<string> { cmd }); + //string cmd = string.Format("mklink \"{0}\" \"{1}\"", flyPath, this.fly); + //ExecCmd(new List<string> { cmd }); + CreateShortcut(flyPath, this.fly); } catch (Exception ex) { @@ -879,6 +880,18 @@ return Path.Combine(appData, tePathName, "TerraExplorer"); } + + public static void CreateShortcut(string shortcutPath, string targetPath, string description = null, string iconLocation = null) + { + var shell = new IWshRuntimeLibrary.WshShell(); + var shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutPath + ".lnk"); // 鍒涘缓蹇嵎鏂瑰紡瀵硅薄 + shortcut.TargetPath = targetPath; // 鎸囧畾鐩爣璺緞 + shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath); // 璁剧疆璧峰浣嶇疆 + shortcut.WindowStyle = 1; // 璁剧疆杩愯鏂瑰紡锛岄粯璁や负甯歌绐楀彛 + shortcut.Description = description; // 璁剧疆澶囨敞 + shortcut.IconLocation = string.IsNullOrWhiteSpace(iconLocation) ? targetPath : iconLocation; // 璁剧疆鍥炬爣璺緞 + shortcut.Save(); // 淇濆瓨蹇嵎鏂瑰紡 + } #endregion } } diff --git a/TEWin/TEWin.csproj b/TEWin/TEWin.csproj index 36a32bb..4544b29 100644 --- a/TEWin/TEWin.csproj +++ b/TEWin/TEWin.csproj @@ -251,6 +251,15 @@ <WrapperTool>aximp</WrapperTool> <Isolated>False</Isolated> </COMReference> + <COMReference Include="IWshRuntimeLibrary"> + <Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid> + <VersionMajor>1</VersionMajor> + <VersionMinor>0</VersionMinor> + <Lcid>0</Lcid> + <WrapperTool>tlbimp</WrapperTool> + <Isolated>False</Isolated> + <EmbedInteropTypes>True</EmbedInteropTypes> + </COMReference> <COMReference Include="stdole"> <Guid>{00020430-0000-0000-C000-000000000046}</Guid> <VersionMajor>2</VersionMajor> -- Gitblit v1.9.3