Ok, so I found a solution. It may not be the most elegant, but it works.
Unfortunately, the ATL object file libraries in the WDK do not help, as the header files are nowhere to be found.
So after more digging I found out that the full version of Visual Studio (not Express) allows you to use the ATL library. I got lucky as it turns out because Microsoft gives full versions of visual studio out to students (see the Dreamspark webpage), and I happen to be a student. :)
So after downloading, installing, and installing any service packs (I just had one) there was just one more step I needed to take to get it to work:
I navigated to Property Pages -> C/C++ -> General I included the directory where the .tlb files can be found (In my case C:\Program Files\SolidWorks Corp\SolidWorks)
Then I ran the following code:
//main.cpp
#include <afxwin.h>
#include <iostream>
#import "sldworks.tlb"
void main()
{
//Initialize COM
CoInitialize(NULL);
//Use ATL smart pointers
CComPtr<SldWorks::ISldWorks> swApp;
//Create an instance of SolidWorks
HRESULT hres = swApp.CoCreateInstance(__uuidof(SldWorks), NULL, CLSCTX_LOCAL_SERVER);
//Make the instance visible to the user
swApp->put_Visible(VARIANT_TRUE);
std::cin.get();
//Shut down SolidWorks
swApp->ExitApp();
// Release COM reference
swApp = NULL;
//Uninitialize COM
CoUninitialize();
}
And that was that. Solidworks opens when the program is run (the additional put_Visible
function allows the user to see the window), and closes without complaining when the user presses enter in the console window.