+ Reply to Thread
Results 1 to 2 of 2

Thread: COM client fails to compile with error C2065: undeclared identifier?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    23

    COM client fails to compile with error C2065: undeclared identifier?

    I have following COM client program.

    It fails on compilation with below error:

    Error C2065: 'IMyFirstCOMInterface' : undeclared identifier

    Following is my code:

    Code:
    #import "D:\\MyFirstCOM.dll"
    	
    void MyFunction()
    {
          CoInitialize(NULL) ;
    
          IMyFirstCOMInterface* pMyFirstCOMInterface = NULL ;
    
         CoUninitialize() ;
    }

    What is the reason?

  2. #2
    Approach 1:

    Use below code:

    Code:
    #import "D:\\MyFirstCOM.dll" no_namespace
    	
    void MyFunction()
    {
          CoInitialize(NULL) ;
    
          IMyFirstCOMInterface* pMyFirstCOMInterface = NULL ;
    
         CoUninitialize() ;
    }
    Approach 2:

    Use your namespace to qualify the interface name.

    Code:
    #import "D:\\MyFirstCOM.dll"
    	
    void MyFunction()
    {
          CoInitialize(NULL) ;
    
          MySomethingLib::IMyFirstCOMInterface* pMyFirstCOMInterface = NULL ;
    
         CoUninitialize() ;
    }
    hope this helps.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts