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. C / C++ / MFC
  4. COM unable to obtain interface -

COM unable to obtain interface -

Scheduled Pinned Locked Moved C / C++ / MFC
comsysadminhelp
5 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.
  • A Offline
    A Offline
    act_x
    wrote on last edited by
    #1

    I have some COM client code that I am trying to write

    IAdd \*pAdd = NULL ; 
    IClassFactory \*pClassFactory= NULL  ; 
    IUnknown \*pUnknown = NULL ; 
    
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED)))
    {
    	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
    	//res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd);
    
    	 res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory );
    	if(res == E\_NOINTERFACE )
    	{
    		int x = 1; 
    	}
    	else if(res == E\_INVALIDARG)
    	{
    		int r = GetLastError() ; 
    	}
    }
    

    I can get this to retrive a valid pointer for pUnknown

    	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
    

    However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated

    Engineering is the effort !

    T CPalliniC 2 Replies Last reply
    0
    • A act_x

      I have some COM client code that I am trying to write

      IAdd \*pAdd = NULL ; 
      IClassFactory \*pClassFactory= NULL  ; 
      IUnknown \*pUnknown = NULL ; 
      
      if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED)))
      {
      	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
      	//res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd);
      
      	 res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory );
      	if(res == E\_NOINTERFACE )
      	{
      		int x = 1; 
      	}
      	else if(res == E\_INVALIDARG)
      	{
      		int r = GetLastError() ; 
      	}
      }
      

      I can get this to retrive a valid pointer for pUnknown

      	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
      

      However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated

      Engineering is the effort !

      T Offline
      T Offline
      Tarmo Kalda
      wrote on last edited by
      #2

      You can use pUnknown->QueryInterface(.. , IAdd, ....) Tarmo.

      1 Reply Last reply
      0
      • A act_x

        I have some COM client code that I am trying to write

        IAdd \*pAdd = NULL ; 
        IClassFactory \*pClassFactory= NULL  ; 
        IUnknown \*pUnknown = NULL ; 
        
        if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED)))
        {
        	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
        	//res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd);
        
        	 res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory );
        	if(res == E\_NOINTERFACE )
        	{
        		int x = 1; 
        	}
        	else if(res == E\_INVALIDARG)
        	{
        		int r = GetLastError() ; 
        	}
        }
        

        I can get this to retrive a valid pointer for pUnknown

        	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
        

        However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated

        Engineering is the effort !

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        What is the error you get?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        In testa che avete, signor di Ceprano?

        A 1 Reply Last reply
        0
        • CPalliniC CPallini

          What is the error you get?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          A Offline
          A Offline
          act_x
          wrote on last edited by
          #4

          I was able to modify my client code to do this

          if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
          {

          	HRESULT  res = CoGetClassObject(g\_MycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)&pClassFactory );
          
          	if(SUCCEEDED(res))
          	{
          		// res  = pUnknown->QueryInterface(IID\_IAdd,(void \*\*)&pAdd);
          		res = pClassFactory->CreateInstance(0,IID\_IAdd , (void \*\*)&pAdd);
          		pClassFactory->Release(); 
          	}
          	else if(res == E\_NOINTERFACE )
          	{
          		int x = 1; 
          	}
          	else if(res == E\_INVALIDARG)
          	{
          		int r = GetLastError() ; 
          	}
          	CoUninitialize(); 
          }
          

          The call to

          HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );

          succeeds providing a pointer to IClassFactory However this line

          res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);

          returns the following error

          #define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)

          Engineering is the effort !

          CPalliniC 1 Reply Last reply
          0
          • A act_x

            I was able to modify my client code to do this

            if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
            {

            	HRESULT  res = CoGetClassObject(g\_MycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)&pClassFactory );
            
            	if(SUCCEEDED(res))
            	{
            		// res  = pUnknown->QueryInterface(IID\_IAdd,(void \*\*)&pAdd);
            		res = pClassFactory->CreateInstance(0,IID\_IAdd , (void \*\*)&pAdd);
            		pClassFactory->Release(); 
            	}
            	else if(res == E\_NOINTERFACE )
            	{
            		int x = 1; 
            	}
            	else if(res == E\_INVALIDARG)
            	{
            		int r = GetLastError() ; 
            	}
            	CoUninitialize(); 
            }
            

            The call to

            HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );

            succeeds providing a pointer to IClassFactory However this line

            res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);

            returns the following error

            #define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)

            Engineering is the effort !

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            It states the class you're asking for is not registered. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            In testa che avete, signor di Ceprano?

            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