VB code to tell if SolidWorks is installed on a computer
VB code to tell if SolidWorks is installed on a computer
(OP)
Hey Folks,
Just a real quick one here. I'm just finishing off an app for a customer and realized that I forgot to do one bit of checking at startup. That being - is SW actually installed (a pre-requisite)?
Anyhow I am just wondering if anyone has a couple lines of code to share w/ me (and the rest of the board) that accomplishes this. I suppose I could just run a search for "sldworks.exe" on the drive(s) but that just seems a bit inelegant. Better than just letting the app crash but I'm hoping there's something that's a step up from that.
SW2007, VB.Net 2005
Thanks,
Just a real quick one here. I'm just finishing off an app for a customer and realized that I forgot to do one bit of checking at startup. That being - is SW actually installed (a pre-requisite)?
Anyhow I am just wondering if anyone has a couple lines of code to share w/ me (and the rest of the board) that accomplishes this. I suppose I could just run a search for "sldworks.exe" on the drive(s) but that just seems a bit inelegant. Better than just letting the app crash but I'm hoping there's something that's a step up from that.
SW2007, VB.Net 2005
Thanks,
Chris Gervais
Application Engineer
CSWP, CSWST






RE: VB code to tell if SolidWorks is installed on a computer
- Check to see if certain SW DLL's are registered
- Check if ANY SolidWorks keys are in registry
- Check registry to find where main SW executable is, then verify that the file exists
Otherwise, try starting SW, then see if you object containing the SW app is "Nothing" or not.I have some VB6 registry tools available on my website. Since you are working in VB.NET, I don't know if they will be much use.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: VB code to tell if SolidWorks is installed on a computer
CODE
'If SolidWorks is Currently Open Object will get initialized.
Set swApp = getObject(, "SldWorks.Application")
'If SolidWorks not open then error occured
If (Err.Number <> 0) Then
Err.Clear
'If SolidWorks is installed on machine it will start.
Set swApp = CreateObject("SldWorks.Application")
'If SolidWorks not installed on machine then error occured
If (Err.Number <> 0) Then
Err.Clear
MsgBox "SolidWorks not installed on this machine. Routine ending.", vbCritical, "Missing SolidWorks Application"
End If
End If
On Error GoTo 0
Enjoy,
Ken
RE: VB code to tell if SolidWorks is installed on a computer
http://support.microsoft.com/kb/821775
RE: VB code to tell if SolidWorks is installed on a computer
Best regards,
Chris Gervais
Application Engineer
CSWP, CSWST
RE: VB code to tell if SolidWorks is installed on a computer
Enjoy,
Ken