这是我的代码:
#import "C:\...\.....\....tlb"
using namespace std;
int main()
{
HRESULT hr = CoInitialize(NULL);
_ApplicationPtr myApp("InDesign.Application");
DocumentPtr myDoc = myApp->ActiveDocument;
SwatchesPtr mySwatches = myDoc->Swatches;
cout << "Number of Swatch: " << mySwatches->Count << endl; // count = 10
SwatchPtr first_swatch = mySwatches->Item[1L];
SwatchPtr second_swatch = mySwatches->Item[2L];
cout << first_swatch->Name; // correctly
cout << second_swatch->Name; // crash
cin.get();
return 0;
}
为什么我无法访问这些元素?计数是10.任何想法?
行SwatchPtr second_swatch = mySwatches->Item[2L];
编译,但它是空的。
访问second_swatch->Name
时出错: