I'm trying to create a standalone Solidworks application (I want my c++ program to create new geometry in Solidworks, running in the background). I'm using msvc++ express 2010.
I have tried to implement the following code suggested here
//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);
//My Code here
//Shut down SolidWorks
swApp->ExitApp();
// Release COM reference
swApp = NULL;
//Uninitialize COM
CoUninitialize();
return 0;
}
It doesn't complain about the import statements for the libraries but it won't build due to the following errors:
1>main.cpp(19): error C2065: 'CComPtr' : undeclared identifier
1>main.cpp(19): error C2275: 'ISldWorks' : illegal use of this type as an expression
1> c:\users\nolan\documents\c++\solidworks_test\solidworks_test\debug\sldworks.tlh(7515) : see declaration of 'ISldWorks'
1>main.cpp(19): error C2065: 'swApp' : undeclared identifier
1>main.cpp(22): error C2065: 'swApp' : undeclared identifier
1>main.cpp(22): error C2228: left of '.CoCreateInstance' must have class/struct/union
1> type is ''unknown-type''
1>main.cpp(26): error C2065: 'swApp' : undeclared identifier
1>main.cpp(26): error C2227: left of '->ExitApp' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>main.cpp(29): error C2065: 'swApp' : undeclared identifier
Obviously I am missing something, but I can't figure out what that is. I feel like it has something to do with ATL but I'm not sure... Please help.
Thanks
EDIT:
Ok I've downloaded the windows development kit 8.0 and all the files are there. I've statically linked to ATL in the property pages, I've also tried linking the library files in the directory: C:\Program Files\Windows Kits\8.0\Lib\Atl
But those header files are nowhere to be found... please help.