|
1 |
| -using Microsoft.Win32; |
| 1 | +using Microsoft.Win32; |
2 | 2 | using System;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.IO;
|
@@ -78,6 +78,8 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
|
78 | 78 | projectName = projectPath;
|
79 | 79 | }
|
80 | 80 |
|
| 81 | + //Console.WriteLine("valueName="+ valueName+" , projectName =" + projectName); |
| 82 | + |
81 | 83 | // get last modified date from folder
|
82 | 84 | DateTime? lastUpdated = folderExists ? Tools.GetLastModifiedTime(projectPath) : null;
|
83 | 85 |
|
@@ -136,15 +138,69 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
|
136 | 138 | p.folderExists = folderExists;
|
137 | 139 |
|
138 | 140 | // if want to hide project and folder path for screenshot
|
139 |
| - //p.Title = "Hidden Project"; |
140 |
| - //p.Path = "C:/Hidden Path/"; |
| 141 | + //p.Title = "Example Project "; |
| 142 | + //p.Path = "C:/Projects/ExamplePath/MyProj"; |
141 | 143 |
|
142 | 144 | projectsFound.Add(p);
|
143 | 145 | } // valid key
|
144 | 146 | } // each key
|
145 | 147 | } // for each registry root
|
146 | 148 |
|
| 149 | + // NOTE sometimes projects are in wrong order, seems to be related to messing up your unity registry, the keys are received in created order (so if you had removed/modified them manually, it might return wrong order instead of 0 - 40) |
| 150 | + |
147 | 151 | return projectsFound;
|
148 | 152 | } // Scan()
|
| 153 | + |
| 154 | + public static bool RemoveRecentProject(string projectPathToRemove) |
| 155 | + { |
| 156 | + var hklm = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64); |
| 157 | + |
| 158 | + // check each version path |
| 159 | + for (int i = 0, len = registryPathsToCheck.Length; i < len; i++) |
| 160 | + { |
| 161 | + RegistryKey key = hklm.OpenSubKey(registryPathsToCheck[i], true); |
| 162 | + |
| 163 | + if (key == null) |
| 164 | + { |
| 165 | + continue; |
| 166 | + } |
| 167 | + else |
| 168 | + { |
| 169 | + //Console.WriteLine("Null registry key at " + registryPathsToCheck[i]); |
| 170 | + } |
| 171 | + |
| 172 | + // parse recent project paths |
| 173 | + foreach (var valueName in key.GetValueNames()) |
| 174 | + { |
| 175 | + if (valueName.IndexOf("RecentlyUsedProjectPaths-") == 0) |
| 176 | + { |
| 177 | + string projectPath = ""; |
| 178 | + // check if binary or not |
| 179 | + var valueKind = key.GetValueKind(valueName); |
| 180 | + if (valueKind == RegistryValueKind.Binary) |
| 181 | + { |
| 182 | + byte[] projectPathBytes = (byte[])key.GetValue(valueName); |
| 183 | + projectPath = Encoding.UTF8.GetString(projectPathBytes, 0, projectPathBytes.Length - 1); |
| 184 | + } |
| 185 | + else // should be string then |
| 186 | + { |
| 187 | + projectPath = (string)key.GetValue(valueName); |
| 188 | + } |
| 189 | + |
| 190 | + // if our project folder, remove registry item |
| 191 | + if (projectPath == projectPathToRemove) |
| 192 | + { |
| 193 | + Console.WriteLine("Deleted registery item: " + valueName + " projectPath=" + projectPath); |
| 194 | + key.DeleteValue(valueName); |
| 195 | + return true; |
| 196 | + } |
| 197 | + |
| 198 | + } // valid key |
| 199 | + } // each key |
| 200 | + } // for each registry root |
| 201 | + return false; |
| 202 | + } // RemoveRecentProject() |
| 203 | + |
149 | 204 | } // class
|
150 | 205 | } // namespace
|
| 206 | + |
0 commit comments