![]() |
1-376578754- How to connect SW with a floating license via OLE Automation?
1-376578754- How to connect SW with a floating license via OLE Automation?
Hi, If SW is running in the foreground and is visible, are there other OLE functions or ways to catch and connect SW? (My current way is that of m_pSldWorks.CreateDispatch(_T("SldWorks.Application"));) Sometimes my customers need network to connect SW with a floating license. Yanhua |
回复: 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 |
所有的时间均为北京时间。 现在的时间是 04:38 AM. |