|
楼主 |
发表于 2007-9-3 23:54:56
|
显示全部楼层
回复: 1-376578754- How to connect SW with a floating license via OLE Automati
Dear Yanhua,
Please see below for the answers to your queries:
-->Visual Basic 6.0 Standalone and Add-in Applications:
Your project can either attach to a running instance of the SolidWorks software by calling the Visual Basic GetObject method or open a new instance of the SolidWorks software by calling the Visual Basic CreateObject method. Lines of code similar to the following must appear in your project.
Sub main()
Dim swApp as SldWorks.SldWorks
' Attach to running instance of SolidWorks software
Set swApp = GetObject(, "SldWorks.Application")
swApp.ExitApp
Set swApp = Nothing
End Sub
- or -
Sub main()
Dim swApp as SldWorks.SldWorks
' Open new instance of SolidWorks software
Set swApp = CreateObject("SldWorks.Application")
swApp.ExitApp
Set swApp = Nothing
End Sub
-->Visual C++ Standalone and Add-in Applications:
To create an instance of the SolidWorks software, your executable project should contain lines of code similar to the following:
//Import the SolidWorks type library
#import "sldworks.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
int _tmain(int argc, _TCHAR* argv[])
{
//Initialize COM
CoInitialize(NULL);
//Use ATL smart pointers
CComPtr<ISldWorks> swApp;
//Create an instance of SolidWorks
HRESULT hres = swApp.CoCreateInstance(__uuidof(SldWorks), NULL, CLSCTX_LOCAL_SERVER);
swApp->ExitApp();
swApp = NULL;
CoUninitialize();
return 0;
}
I hope this helps.
Thanks,
Pabitra |
|