solidworks object

I have a database (pdm type app.) that fisrtly tries to create the solidworks object to see if SW is installed or not (done thro vb6)

- set swapp=createobject("solidworks.application")

The trouble is that it can also create an object for the solidworks viewer. The only difference i can see is that Sw returns 0.0.0 revision and the viewer returns 0.0 revision.

Anybody got a better routine for determining what type of solidworks is running?

many thanks nigel

Reply to
Bates, Nigel
Loading thread data ...

You could read registry information (e.g., stuff in HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Security )

Regards, Brenda

Reply to
Brenda D. Bosley

Nigel,

To create the SolidWorks application object in VB6, I believe you need to use the following:

Set swApp = CreateObject("SldWorks.Application")

Below you had "SolidWorks.Application"

Also, the SolidWorks Viewer's API is disabled. The code above should not create a pointer to the SW Viewer.

I believe the you can check the Error number in the Err object in VB6 to determine is the SW object was successfully created. I don't remember the exact code to do this but I have seen this done before.

As I was writing this message, I tested your code "SolidWorks.Application". This also works. Hmmm.... I never remember this to be the call to create a SW object. Can anyone explain why both of these work??? Maybe it is because I have both SW2003 and SW2004 installed on my computer???

Thanks,

Steve

Reply to
Steve Stojanovski

Interesting... I tried it with declaring swApp as a specific type of SldWorks.SldWorks, and I got a type mismatch on the CreateObject("SolidWorks.Application") If I just used Dim swApp As Object, then there was no error, but I didn't get anything coming up either (as I don't have the SW Viewer installed on this computer). Is the "SolidWorks.Application" specifically used to refer to the viewer? ... but Nigel and Steve, did you say that you were able to use it to bring up regular SW? I'm not getting that result (tested while referencing the SW2003 sldworks.tlb).

-- Brenda

-----------------------------------------------

Reply to
Brenda D. Bosley

It was using the ("SldWorks.Application") line, and on a machine with only the viewer installed sRevNum = swApp.RevisionNumber does seem to work

ps is it easy to read the reg info?

-----Original Message----- From: Brenda D. Bosley [mailto: snipped-for-privacy@yahoo.com] Posted At: 04 December 2003 19:37 Posted To: solidworks Conversation: solidworks object Subject: Re: solidworks object

You could read registry information (e.g., stuff in HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Security )

Regards, Brenda

Reply to
Bates, Nigel

You can do so (read reg info) by making use of the Win API call RegQueryValueEx. Declare it, and then you can make use of it. You should be able to find more detailed explanation of the parameters on msdn.microsoft.com:

Public Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long

I was thinking you could read something that would be unique to SolidWorks, such as the serial number. On further consideration, though, this would tell you if "real" SolidWorks is installed. It wouldn't necessarily identify if that's the session you've attached to. So maybe this doesn't do much to address your question after all. The SW Viewer API is officially not supported, to the extent that it exists. I'm not really sure what would make a reliable distinction. Perhaps a call to an API that you've determined is definitely NOT supported in SW Viewer?

on error resume next err.clear 'Make your distinctive API call here. 'If it generates an error then you know you've got viewer instead of true SW if err 0 then msgbox "Hey, this isn't SolidWorks!"

--Brenda

Reply to
Brenda D. Bosley

Brenda,

OK, I tested again and this is what worked for me in VB6 and SW VBA:

Set swApp = CreateObject("SldWorks.Application")

this didn't worked in VB6 or SW VBA:

Set swApp = CreateObject("SolidWorks.application")

In my previous post I was mistaken.

As far as the SW Viewer is concerned, the API support tips on the Solidworks Subscription service webpages states that the API for the Sw Viewer is disabled.

Steve

Reply to
Steve Stojanovski

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.