How to get SolidWork exe path programmatically

22 Sep

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 “SolidWorks Folder”!

I therefore created a snippet to troubleshoot this, and the code is like this:

SolidWorksPath_D0 SolidWorksPath_D

Download VisualStudio 2010 Project here.


Posted by on September 22, 2010 in CAD, Dotnet/C#


2 responses to “How to get SolidWork exe path programmatically

  1. xinyustudio

    September 24, 2010 at 11:39 am

    Using Reflector tools, one can see below implementation from official SolidWorks developers:

    private string GetSWPath()
    string name = (string) Registry.ClassesRoot.OpenSubKey(“SldWorks.Application”).OpenSubKey(“CLSID”).GetValue(“”);
    return (string) Registry.ClassesRoot.OpenSubKey(“CLSID”).OpenSubKey(name).OpenSubKey(“LocalServer32”).GetValue(“”);

    One of the limiations of this code is that it only returns one of the installed SolidWorks version, but not all.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: