Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. CocreateInstance fails

CocreateInstance fails

Scheduled Pinned Locked Moved COM
help
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shailesh Ha
    wrote on last edited by
    #1

    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

    P S 3 Replies Last reply
    0
    • S Shailesh Ha

      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

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      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 calling CoCreateInstance?

      Prasad Notifier using ATL | Operator new[],delete[][^]

      S 1 Reply Last reply
      0
      • S Shailesh Ha

        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

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        Your code is hard to read. What is the HRESULT returned? Try entering "hr, hr" in your debugger watch window, assuming the variable containing the HRESULT returned from CoCreateInstance is named "hr". If it was named "MyHr" you'd use the following string: "MyHr, hr".

        Steve

        S 1 Reply Last reply
        0
        • P prasad_som

          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 calling CoCreateInstance?

          Prasad Notifier using ATL | Operator new[],delete[][^]

          S Offline
          S Offline
          Shailesh Ha
          wrote on last edited by
          #4

          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 } }

          P 1 Reply Last reply
          0
          • S Shailesh Ha

            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 } }

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            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[][^]

            S 1 Reply Last reply
            0
            • P prasad_som

              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[][^]

              S Offline
              S Offline
              Shailesh Ha
              wrote on last edited by
              #6

              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

              P 1 Reply Last reply
              0
              • S Shailesh Ha

                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

                P Offline
                P Offline
                prasad_som
                wrote on last edited by
                #7

                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[][^]

                1 Reply Last reply
                0
                • S Stephen Hewitt

                  Your code is hard to read. What is the HRESULT returned? Try entering "hr, hr" in your debugger watch window, assuming the variable containing the HRESULT returned from CoCreateInstance is named "hr". If it was named "MyHr" you'd use the following string: "MyHr, hr".

                  Steve

                  S Offline
                  S Offline
                  Shailesh Ha
                  wrote on last edited by
                  #8

                  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

                  S 1 Reply Last reply
                  0
                  • S Shailesh Ha

                    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

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • S Shailesh Ha

                      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

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #10

                      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[][^]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups