diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index db44309fcc..e79a57b0d5 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -192,6 +192,7 @@ "PowerToys.ProjectsSnapshotTool.exe", "PowerToys.ProjectsLauncher.exe", "PowerToys.ProjectsEditor.exe", + "PowerToys.ProjectsEditor.dll", "PowerToys.ProjectsModuleInterface.dll", "WinUI3Apps\\PowerToys.RegistryPreviewExt.dll", diff --git a/src/modules/Projects/Assets/Projects.ico b/src/modules/Projects/Assets/Projects.ico new file mode 100644 index 0000000000..ba3cb543c7 Binary files /dev/null and b/src/modules/Projects/Assets/Projects.ico differ diff --git a/src/modules/Projects/ProjectsEditor/ProjectsEditor.csproj b/src/modules/Projects/ProjectsEditor/ProjectsEditor.csproj index 9aecdb4f8d..c780c67f69 100644 --- a/src/modules/Projects/ProjectsEditor/ProjectsEditor.csproj +++ b/src/modules/Projects/ProjectsEditor/ProjectsEditor.csproj @@ -1,4 +1,5 @@  + PowerToys.ProjectsEditor PowerToys Projects Editor @@ -60,6 +61,15 @@ false true + + tlbimp + 0 + 1 + 50a7e9b0-70ef-11d1-b75a-00a0c90564fe + 0 + false + true + diff --git a/src/modules/Projects/ProjectsEditor/Utils/ProjectIcon.cs b/src/modules/Projects/ProjectsEditor/Utils/ProjectIcon.cs index ca752d3075..90ef07bad7 100644 --- a/src/modules/Projects/ProjectsEditor/Utils/ProjectIcon.cs +++ b/src/modules/Projects/ProjectsEditor/Utils/ProjectIcon.cs @@ -84,7 +84,12 @@ namespace ProjectsEditor.Utils public static void SaveIcon(Bitmap icon, string path) { - FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate); + if (Path.Exists(path)) + { + File.Delete(path); + } + + FileStream fileStream = new FileStream(path, FileMode.CreateNew); using (var memoryStream = new MemoryStream()) { icon.Save(memoryStream, ImageFormat.Png); diff --git a/src/modules/Projects/ProjectsEditor/ViewModels/MainViewModel.cs b/src/modules/Projects/ProjectsEditor/ViewModels/MainViewModel.cs index 5bf30c53f0..f62866fde5 100644 --- a/src/modules/Projects/ProjectsEditor/ViewModels/MainViewModel.cs +++ b/src/modules/Projects/ProjectsEditor/ViewModels/MainViewModel.cs @@ -159,20 +159,36 @@ namespace ProjectsEditor.ViewModels private void CreateShortcut(Project project) { string basePath = AppDomain.CurrentDomain.BaseDirectory; - string shortcutAddress = FolderUtils.Desktop() + $"\\{project.Name}.lnk"; - string shortcutIconFilename = FolderUtils.Temp() + $"\\{project.Name}.ico"; + string shortcutAddress = Path.Combine(FolderUtils.Desktop(), project.Name + ".lnk"); + string shortcutIconFilename = Path.Combine(FolderUtils.Temp(), project.Id + ".ico"); Bitmap icon = ProjectIcon.DrawIcon(ProjectIcon.IconTextFromProjectName(project.Name)); ProjectIcon.SaveIcon(icon, shortcutIconFilename); - IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); - IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutAddress); - shortcut.Description = $"Project Launcher {project.Id}"; - shortcut.TargetPath = Path.Combine(basePath, "PowerToys.ProjectsLauncher.exe"); - shortcut.Arguments = project.Id; - shortcut.WorkingDirectory = basePath; - shortcut.IconLocation = shortcutIconFilename; - shortcut.Save(); + try + { + // Workaround to be able to create a shortcut with unicode filename + File.WriteAllBytes(shortcutAddress, Array.Empty()); + + // Create a ShellLinkObject that references the .lnk file + Shell32.Shell shl = new Shell32.Shell(); + Shell32.Folder dir = shl.NameSpace(FolderUtils.Desktop()); + Shell32.FolderItem itm = dir.Items().Item($"{project.Name}.lnk"); + Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink; + + // Set the .lnk file properties + lnk.Description = $"Project Launcher {project.Id}"; + lnk.Path = Path.Combine(basePath, "PowerToys.ProjectsLauncher.exe"); + lnk.Arguments = project.Id.ToString(); + lnk.WorkingDirectory = basePath; + lnk.SetIconLocation(shortcutIconFilename, 0); + + lnk.Save(shortcutAddress); + } + catch (Exception ex) + { + Logger.LogError($"Shortcut creation error: {ex.Message}"); + } } public void SaveProjectName(Project project) diff --git a/src/modules/Projects/ProjectsLauncher/ProjectLauncherResource.rc b/src/modules/Projects/ProjectsLauncher/ProjectLauncherResource.rc new file mode 100644 index 0000000000..bba3ac02f5 Binary files /dev/null and b/src/modules/Projects/ProjectsLauncher/ProjectLauncherResource.rc differ diff --git a/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj b/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj index 9fbed3d83a..caffb353b2 100644 --- a/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj +++ b/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj @@ -132,6 +132,7 @@ + @@ -147,6 +148,9 @@ {6955446d-23f7-4023-9bb3-8657f904af99} + + + diff --git a/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj.filters b/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj.filters index 9fd107711a..57c17bd3ac 100644 --- a/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj.filters +++ b/src/modules/Projects/ProjectsLauncher/ProjectsLauncher.vcxproj.filters @@ -21,6 +21,9 @@ Header Files + + Header Files + @@ -34,6 +37,11 @@ - + + + + + Resource Files + \ No newline at end of file diff --git a/src/modules/Projects/ProjectsLauncher/resource.h b/src/modules/Projects/ProjectsLauncher/resource.h new file mode 100644 index 0000000000..f72a23ed41 --- /dev/null +++ b/src/modules/Projects/ProjectsLauncher/resource.h @@ -0,0 +1,13 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ProjectLauncherResource.rc + +////////////////////////////// +// Non-localizable + +#define FILE_DESCRIPTION "PowerToys Projects Launcher" +#define INTERNAL_NAME "PowerToys.ProjectsLauncher" +#define ORIGINAL_FILENAME "PowerToys.ProjectsLauncher.exe" + +// Non-localizable +////////////////////////////// diff --git a/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.rc b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.rc new file mode 100644 index 0000000000..bba3ac02f5 Binary files /dev/null and b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.rc differ diff --git a/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj index e00c96e36b..7c42c829df 100644 --- a/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj +++ b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj @@ -134,6 +134,7 @@ + @@ -149,6 +150,9 @@ {6955446d-23f7-4023-9bb3-8657f904af99} + + + diff --git a/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj.filters b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj.filters index d01693ad5e..8f8b7d9f26 100644 --- a/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj.filters +++ b/src/modules/Projects/ProjectsSnapshotTool/ProjectsSnapshotTool.vcxproj.filters @@ -24,6 +24,9 @@ Header Files + + Header Files + @@ -40,6 +43,11 @@ - + + + + + Resource Files + \ No newline at end of file diff --git a/src/modules/Projects/ProjectsSnapshotTool/resource.h b/src/modules/Projects/ProjectsSnapshotTool/resource.h new file mode 100644 index 0000000000..713a32b79d --- /dev/null +++ b/src/modules/Projects/ProjectsSnapshotTool/resource.h @@ -0,0 +1,13 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ProjectsSnapshotTool.rc + +////////////////////////////// +// Non-localizable + +#define FILE_DESCRIPTION "PowerToys Projects Snapshot Tool" +#define INTERNAL_NAME "PowerToys.ProjectsSnapshotTool" +#define ORIGINAL_FILENAME "PowerToys.ProjectsSnapshotTool.exe" + +// Non-localizable +////////////////////////////// diff --git a/src/modules/Projects/projects-common/WindowUtils.h b/src/modules/Projects/projects-common/WindowUtils.h index 59a6b243d8..3cc4c1f85e 100644 --- a/src/modules/Projects/projects-common/WindowUtils.h +++ b/src/modules/Projects/projects-common/WindowUtils.h @@ -22,9 +22,9 @@ namespace WindowUtils const char SplashClassName[] = "MsoSplash"; const wchar_t CoreWindow[] = L"WINDOWS.UI.CORE.COREWINDOW"; const wchar_t SearchUI[] = L"SEARCHUI.EXE"; - const wchar_t ProjectsSnapshotTool[] = L"PROJECTSSNAPSHOTTOOL"; - const wchar_t ProjectsEditor[] = L"PROJECTSEDITOR"; - const wchar_t ProjectsLauncher[] = L"PROJECTSLAUNCHER"; + const wchar_t ProjectsSnapshotTool[] = L"POWERTOYS.PROJECTSSNAPSHOTTOOL"; + const wchar_t ProjectsEditor[] = L"POWERTOYS.PROJECTSEDITOR"; + const wchar_t ProjectsLauncher[] = L"POWERTOYS.PROJECTSLAUNCHER"; } inline bool IsRoot(HWND window) noexcept