Visual C++ 6.0 Standalone and Add-in Applications
Standalone Applications (.exe files)
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
//Import the SolidWorks constant type library
#import "swconst.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);
.
. // Your
code
.
//Shut down SolidWorks
swApp->ExitApp();
//Release COM reference
swApp = NULL;
//Uninitialize COM
CoUninitialize();
return 0;
}
Add-in Applications (.dll files)
You can create a Visual C++ 6.0 DLL add-in using the Visual
Studio 6 ATL Object Wizard
included in the SolidWorks
API SDK. See ATL
Object Wizard (Visual C++ 6) for details.
Visual C++ applications have the option of using a COM or Dispatch interface.
See COM vs. Dispatch for
details.
NOTE: For COM DLL add-ins, success
or failure on import/export is returned by the add-in through the HRESULT.