Kód: Vybrať všetko
int main(int argc, char *argv[])
{
HRESULT hres;
CLSID clsid;
IDispatch *excelApp;
CLSIDFromProgID(L"Excel.Application", &clsid);
// Start Excel as a COM server in a separate process
hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&excelApp);
if(FAILED(hres)) {
char strMsg[MAX_PATH];
switch(hres)
{
case REGDB_E_CLASSNOTREG:
strcpy(strMsg, "CLSID is not properly registered");
break;
case E_NOINTERFACE:
strcpy(strMsg, "Either the object pointed to by ppv does not support the interface identified by riid,or the QueryInterface operation on the class object returned E_NOINTERFACE");
break;
case REGDB_E_READREGDB:
strcpy(strMsg, "Error reading the registration database.");
break;
case CO_E_DLLNOTFOUND:
strcpy(strMsg, "In-process DLL or handler DLL not found (depends on context)");
break;
case CO_E_APPNOTFOUND:
strcpy(strMsg, "EXE not found (CLSCTX_LOCAL_SERVER only).");
break;
case E_ACCESSDENIED:
strcpy(strMsg, "General access failure (returned from LoadLib/CreateProcess).");
break;
case CO_E_ERRORINDLL:
strcpy(strMsg, "EXE has error in image.");
break;
case CO_E_APPDIDNTREG:
strcpy(strMsg, "EXE was launched, but it didn't register class object (may or may not have shut down).");
break;
default:
sprintf(strMsg, "0x%X (%d)", hres, hres);
strcat(strMsg, " Unknown error");
}
MessageBox(NULL, strMsg,
"ERROR",
MB_SETFOREGROUND);
system("PAUSE");
return EXIT_FAILURE;
}
excelApp->Release();
system("PAUSE");
return EXIT_SUCCESS;
}Kód: Vybrať všetko
CoInitialize( NULL );Kód: Vybrať všetko
CoUninitialize();to znamena ze ma kniznica zly format?