Re: [Dev-C++] Windows, COM, CoCreateInstance and OleInitialize
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Steve H. <st...@sj...> - 2005-08-11 17:06:03
|
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...>
|