スタンドアロンの Solidworks アプリケーションを作成しようとしています (バックグラウンドで実行されている Solidworks で新しいジオメトリを作成する C++ プログラムが必要です)。msvc++ Express 2010 を使用しています。
ここで提案されている次のコードを実装しようとしました
//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;
}
ライブラリの import ステートメントについて文句を言うことはありませんが、次のエラーのためにビルドされません。
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
明らかに何かが欠けていますが、それが何であるかわかりません。ATL と何か関係があるように感じますが、よくわかりません... 助けてください。
ありがとう
編集:
OK、Windows 開発キット 8.0 をダウンロードしました。すべてのファイルがあります。プロパティ ページで ATL に静的にリンクしました。また、ディレクトリ内のライブラリ ファイルをリンクしようとしました。C:\Program Files\Windows Kits\8.0\Lib\Atl
しかし、それらのヘッダー ファイルはどこにもありません...助けてください。