license string查看工具可从微软网站下载:http://support.microsoft.com/kb/151771/zh-cn
创建控件的代码如下,更详细的内容可参见我的博文:http://blog.csdn.net/zztoll/article/details/23035873
WCHAR pwchLicenseKey[] = //此处的license Key是示例,不是Spread COM的
{
0x0043, 0x006F, 0x0070, 0x0079, 0x0072, 0x0069,
0x0067, 0x0068, 0x0074, 0x0020, 0x0028, 0x0063,
0x0029, 0x0020, 0x0031, 0x0039, 0x0039, 0x0034,
0x0020
};
HRESULT hr;
IDispatch* pObj;
CLSID clsid = { 0xDE52502E, 0xF837, 0x492B, { 0xAE, 0x14, 0xA1, 0x82, 0x53, 0x1A, 0xFA, 0xF4}};
BSTR bstrLicense = ::SysAllocStringLen(pwchLicenseKey, sizeof(pwchLicenseKey)/sizeof(WCHAR));
LPCLASSFACTORY2 pClassFactory2;
if (SUCCEEDED(hr = CoGetClassObject(clsid, CLSCTX_SERVER, NULL, IID_IClassFactory2, (void**)&pClassFactory2)))
{
hr = pClassFactory2->CreateInstanceLic(NULL, NULL, IID_IDispatch, bstrLicense, (void**) &pObj);
pClassFactory2->Release();
if(FAILED(hr))
return;
wxAutomationObject *sp = new wxAutomationObject;
sp->SetDispatchPtr(pObj);
wxActiveXContainer* containter = new wxActiveXContainer(this,IID_IDispatch,pObj);
} |