超级版主
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
|
回复: 1-376578754- How to connect SW with a floating license via OLE Automation?
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
__________________
借用达朗贝尔的名言:前进吧,你会得到信心!
[url="http://www.dimcax.com"]几何尺寸与公差标准[/url]
|