-
October 14th, 2010, 03:35 PM
#1
‘CoInitialize has not been called’
DATATABLE * myObj;
void __fastcall TfmMain::btnExportClick(TObject *Sender)
{
myObj->Export(NULL);
}
void DATATABLE::Export(void* pParam) {
Variant my_excel ;
my_excel=CreateOleObject("Excel.Application");
…
}
Export() member function works fine at above case. but it takes long time and frozes interface.
So i tried to do this way:
void __fastcall TfmMain::btnExportClick(TObject *Sender)
{
unsigned ThreadId;
DATATABLE *thisParam= myObj;
HANDLE hndE;
hndE=(HANDLE)_beginthreadex(NULL, 0, myObj ->Export2,thisParam,0, &ThreadId);
…
}
unsigned __stdcall DATATABLE::Export2(void* pParam)
{
DATATABLE *thisParam= reinterpret_cast< DATATABLE *>(pParam);
thisParam->Export(NULL);
}
However, I got error at the line CreateOleObject("Excel.Application");
Project MyProj.exe raised exception class EOleSysError with message ‘CoInitialize has not been called’
Why? and how to fix it?
i use Borland compiler.
Thanks
-
October 14th, 2010, 04:06 PM
#2
Re: ‘CoInitialize has not been called’
Well, I never used Borland compiler... Isn't it possible to call CoInitialize in your project?
Victor Nijegorodov
-
November 8th, 2010, 12:58 PM
#3
Re: ‘CoInitialize has not been called’
CreateOleObject is a COM function and you need to call CoInitialize before using COM functions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|