For some reasons, I need to get the path where SolidWorks are installed. Note that:
- Uses may not always installl SolidWorks to the default locations.
- Multiple SolidWorks versions may coexist;
In order to do this programmatically, one can refer to the registry for details.
In this case, I have installed SolidWorks 2008 and SolidWorks 2010, and these infiormation can be accessed at “HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\SolidWorks <xxxx> \Setup”, where <xxxx>=2010, 2009 or whatever the version installed.
So the trick is to search all the registry keys and subkeys under the path “HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\”, and get all the values whose value name is
The psedo code might be:
string ValueToFind=“SolidWorks Folder”;
List<RegistryKey> AllKeys= GetRegistryKeysWithValueNames(ValueToFind);
foreach(rKey in AllKeys)
Unforturenately, such code does NOT work!
The reason is that the value name displayed in the Regedit.exe is not the actual name returned by code, and if you call SomeKey.GetValueNames(), you will see the value name of interest is actually "SolidWorks Location", instead of
I therefore created a snippet to troubleshoot this, and the code is like this:
Download VisualStudio 2010 Project here.