CocreateInstance fails
-
Hi, Problem is that A call to CocreateInstance fails ....hence the requested interface pointer shown is NULL ...hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_Control, reinterpret_cast(&m_pControl) ); ABOVE the IID_Control is showing as NULL... Any solutions , Kindly let me know regards Shailesh
-
Hi, Problem is that A call to CocreateInstance fails ....hence the requested interface pointer shown is NULL ...hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_Control, reinterpret_cast(&m_pControl) ); ABOVE the IID_Control is showing as NULL... Any solutions , Kindly let me know regards Shailesh
Shailesh Halankar wrote:
ABOVE the IID_Control is showing as NULL...
I think, you wants to say,
m_pControl
is NULL. Can you show complete code ? Have you used::CoInitialize(NULL)
before callingCoCreateInstance
?Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, Problem is that A call to CocreateInstance fails ....hence the requested interface pointer shown is NULL ...hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_Control, reinterpret_cast(&m_pControl) ); ABOVE the IID_Control is showing as NULL... Any solutions , Kindly let me know regards Shailesh
Your code is hard to read. What is the
HRESULT
returned? Try entering "hr, hr" in your debugger watch window, assuming the variable containing theHRESULT
returned fromCoCreateInstance
is named "hr
". If it was named "MyHr
" you'd use the following string: "MyHr, hr".Steve
-
Shailesh Halankar wrote:
ABOVE the IID_Control is showing as NULL...
I think, you wants to say,
m_pControl
is NULL. Can you show complete code ? Have you used::CoInitialize(NULL)
before callingCoCreateInstance
?Prasad Notifier using ATL | Operator new[],delete[][^]
Hello ur right m_pControl is NULL ..hence error.. I can giv u some more of the code ... HRESULT hrStatus = CLSIDFromProgID( TEXT("What ever prog ID"), &clsControl ); if( SUCCEEDED(hrStatus) ) { // // Create the object and initialize it. // hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) ); if( SUCCEEDED(hrStatus) ) { // some code } }
-
Hello ur right m_pControl is NULL ..hence error.. I can giv u some more of the code ... HRESULT hrStatus = CLSIDFromProgID( TEXT("What ever prog ID"), &clsControl ); if( SUCCEEDED(hrStatus) ) { // // Create the object and initialize it. // hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) ); if( SUCCEEDED(hrStatus) ) { // some code } }
Shailesh Halankar wrote:
HRESULT hrStatus = CLSIDFromProgID( TEXT("What ever prog ID"), &clsControl ); if( SUCCEEDED(hrStatus) )
I think you are getting class id here. Call, ::Coinitialize(NULL) before it.
Shailesh Halankar wrote:
hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) );
What is value of hrstatus here?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Shailesh Halankar wrote:
HRESULT hrStatus = CLSIDFromProgID( TEXT("What ever prog ID"), &clsControl ); if( SUCCEEDED(hrStatus) )
I think you are getting class id here. Call, ::Coinitialize(NULL) before it.
Shailesh Halankar wrote:
hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) );
What is value of hrstatus here?
Prasad Notifier using ATL | Operator new[],delete[][^]
Hi Prasad I cant use coinitialize function ..gives linker error..i think its coz its not a VC++ apllication that i m working on . Its a Embeded VC++ application that i m working on. regards Shailesh
-
Hi Prasad I cant use coinitialize function ..gives linker error..i think its coz its not a VC++ apllication that i m working on . Its a Embeded VC++ application that i m working on. regards Shailesh
Shailesh Halankar wrote:
..gives linker error
You need to link
Ole232.lib
.Shailesh Halankar wrote:
i think its coz its not a VC++ apllication that i m working on . Its a Embeded VC++ application that i m working on.
Doesn't matter. BTW, you haven't answered my second question , about value of hresult.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Your code is hard to read. What is the
HRESULT
returned? Try entering "hr, hr" in your debugger watch window, assuming the variable containing theHRESULT
returned fromCoCreateInstance
is named "hr
". If it was named "MyHr
" you'd use the following string: "MyHr, hr".Steve
my code ..is somewat like this HRESULT hrStatus = CLSIDFromProgID( TEXT("some"), &clsControl ); if( SUCCEEDED(hrStatus) ) { // // Create the object and initialize it. // hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) ); if( SUCCEEDED(hrStatus) ) { //some code } } regards Shailesh
-
my code ..is somewat like this HRESULT hrStatus = CLSIDFromProgID( TEXT("some"), &clsControl ); if( SUCCEEDED(hrStatus) ) { // // Create the object and initialize it. // hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_IControl, reinterpret_cast(&m_pControl) ); if( SUCCEEDED(hrStatus) ) { //some code } } regards Shailesh
Put a break point directly after the
CoCreateInstance
call you're having problems with. When the break point is hit add the following to the watch window: "hrStatus, hr". If all goes well your debugger will tell you what the problem is.Steve
-
Hi, Problem is that A call to CocreateInstance fails ....hence the requested interface pointer shown is NULL ...hrStatus = CoCreateInstance( clsControl, NULL, CLSCTX_INPROC_SERVER, IID_Control, reinterpret_cast(&m_pControl) ); ABOVE the IID_Control is showing as NULL... Any solutions , Kindly let me know regards Shailesh
Hi Shailesh, What happens to your problem ? Its always good practice to reply, whether you problem has been solved or not. It helps other to add this problem to their knowledege. And reply further if not solved.
Prasad Notifier using ATL | Operator new[],delete[][^]