[Dev-C++] CoCreateInstance(..) errors
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Mark A. <am...@ho...> - 2005-08-11 17:39:27
|
Hi Steve,
I'm using your suggestion, but it has no effect.
I still get an error from CoCreateInstance: 0x800401F0
It is CO_E_NOTINITIALIZED
'Failed to connect to server'
Surfing the internet results in hints that it may have something to do with
'MsiInstaller', 'Events'.
'Exchange Server 5.5 Service Pack 2 (SP2)', 'CoInitialize has not been
called'.
I tried using OleInitialize(..) or CoInitializeEx(..) but these crash!
I've now found the solution!
I use CoInitialize(NULL) in stead of CoInitializeEx(..)
Thanks for your help by the way :)
greetings,
Mark Ament
----- Original Message -----
From: "Steve Higham" <st...@sj...>
To: "Mark Ament" <am...@ho...>
Cc: <dev...@li...>
Sent: Thursday, August 11, 2005 7:05 PM
Subject: Re: [Dev-C++] Windows, COM, CoCreateInstance and OleInitialize
> Mark Ament wrote:
>
>> Hi there!
>> I was trying all possibilities of DEV-C++ and I was pretty excited about
>> it.
>> But I've encountered a problem.
>> In the Windows-operating-systems it is pretty important to use components
>> (COM).
>> I've made a "windows application" project and added the following code:
>> ----------------------------------------
>> const CLSID CLSID_Printing =
>> {0x76A73923,0xD88C,0x11D6,{0xB5,0x51,0xEB,0xCE,0x0B,0x59,0xDA,0x72}};
>> const IID IID_IUnknown =
>> {0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
>> const IID IID_IClassFactory
>> ={0x00000001,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
>> const CLSID CLSID_MySimpleObj
>> ={0x14C0CBCC,0x8E68,0x4BB0,{0xB4,0x49,0x2D,0x9D,0xFB,0x80,0x9A,0x16}};
>> const IID IID_IMySimpleObj
>> ={0x14C0CBCD,0x8E68,0x4BB0,{0xB4,0x49,0x2D,0x9D,0xFB,0x80,0x9A,0x16}};
>> interface IMySimpleObj : public IUnknown {
>> virtual HRESULT msg()=0;
>> };
>> int WINAPI WinMain (HINSTANCE hThisInstance,
>> HINSTANCE hPrevInstance,
>> LPSTR lpszArgument,
>> int nFunsterStil) {
>> MessageBox(0,"Test Start..","Project2",0);
>> //OleInitialize(0); //<-Creates a crash!
>> IUnknown * schaap;
>> schaap = NULL;
>> HRESULT hr;
>> hr =
>> CoCreateInstance(CLSID_MySimpleObj,0,CLSCTX_INPROC,IID_IUnknown,(void**)&schaap);
>> if (schaap!=NULL) {
>> MessageBox(0,"Test CoCreateInstance Worked!","Project2",0);
>> schaap->Release();
>> schaap = NULL;
>> }
>> //OleUninitialize();
>> MessageBox(0,"Test Done..","Project2",0);
>> //HERE THE REST OF THE WinMain-Code!
>> }
>>
>> ----------------------------------------
>> Secondly: in the menu 'Project' -> 'Project Options' --tab->
>> Parameters --button-> Add Library or Object
>> I've added the OLE32.LIB from Microsoft Visual C++ 5.0.
>> The problem is that CoCreateInstance never succeeds in creating an
>> object!
>> So I also tried to do a "OleInitialize(0)", but this one always results
>> in crashing!
>> I hope this problem can be solved to meet the important requirement of
>> using COM in DEV-C++ !
>> greetings,
>> Mark Ament
>
> Hi Mark,
>
> I'm using COM without any problems.
>
> I'm using the libraries that came with Dev-Cpp - Try using
> Dev-Cpp\lib\libole32.a. This should work fine.
>
> Regards,
>
> Steve
>
> --
>
> Steve Higham
>
> › st...@sj... <mailto:st...@sj...>
>
>
|