Results 1 to 6 of 6

Thread: How to use tlb file into Visual C++?

  1. #1
    Join Date
    Apr 2011
    Posts
    62

    How to use tlb file into Visual C++?

    All the users of this particular forum has helped me out to fix the matter of mine. Well I am using the server application Com dll and I am having the client application through the VC ++. Let me know what should I use if I wanted to use the .h or _i.c files on the VC++ application so that I can have the access to the functionality of the COM dll. Let me know how can I have the above mentioned functionality. Any help on this particular matter would be highly appreciated. Thanks a lot in advance.

  2. #2
    Join Date
    May 2009
    Posts
    529

    Re: How to use tlb file into Visual C++?

    In order to get the requirement of yours I am suggesting that you should use the #import directive in to the application which you are supposed to do on the application of yours.
    Code:
    #import "MyCOMFile.tlb"
    The above mentioned statement would create two separate files into the debug or release folder which is having an extension of .tlh and .tli. all these files can be used to define the com interface and smart pointer typedef declarations with the call CoCreateInstance for you can handle the reference-count automatically in the application.

  3. #3
    Join Date
    May 2009
    Posts
    543

    Re: How to use tlb file into Visual C++?

    Using the .tlb file into the C++ is not straightforward at as you do into the VB. However you can use the following code which would demo how can you use the type libraries into the VC++.
    Code:
    #import "MyPath\MyTypeLib.tlb" rename_namespace("SmthLooksMeNice") using namespace SmthLooksMeNice;
    #include <objbase.h>
     
    int main()
    {
    CoInitialize(NULL);
     
    
    // Assume your COM object is named MyComObjectName
    // and there is an interface IMyComObject.
    // #import generated a smart pointer over that interface.
    IMyComObjectPtr pObject(_uuidof(MyComObjectName));
     
    BSTR temp = pObject->SomeProp;
    pObject->DoSmth();
    //...
    CoUninitialize();
    return 0;
    }
    I am hoing that the coding example which i have mentioned over here would be useful to get the requirement of yours.

  4. #4
    Join Date
    May 2009
    Posts
    511

    Re: How to use tlb file into Visual C++?

    Well the TLB file is used to describe the all the data of the COM server. However there would be no code into the TLB file. You need to register the COM server that is either exe dile or dll file into the executable module of the application which you are developing currently. Also make sure that you are importing the base class prior than you should use import the tlb file on the application of yours. So you should consider the thing which i have mentioned over here.

  5. #5
    Join Date
    May 2009
    Posts
    637

    Re: How to use tlb file into Visual C++?

    You should use the smart-pointer typedef is the name of the interface concatenated with Ptr. In case the If00 is the interface then the smart pointer type is the IF00ptr. As we have assume that the If00 is the interface the I recommend that the client code would like the below one.
    Code:
    #import "MyCOMFile.tlb" no_namespace
    
    void main()
    {
         CoInitialize(NULL);
         try
         {
             IFooPtr pFoo(__uuidof(Foo));
             pFoo->Method();
         }
         CoUnintialize();
    }
    So you should use get the idea from the thing which I have mentioned over here I am hoping that it would be useful to you.

  6. #6
    Join Date
    Apr 2009
    Posts
    488

    Re: How to use tlb file into Visual C++?

    Well looking at the matter which you have mentioned over here I am suggesting following thing which you can use to get the requirement of yours. I you can specify the prog ID and see whether it isn working or not. Well i am suggesting the following command which you can use as Prog Id I am hoping that it would be useful you.
    Code:
    #import "progid:Outlook.Application" named_guids
    So try the same and let me know about the result.

Similar Threads

  1. What is File Handling in Visual Basic 6.0?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 27-12-2010, 05:54 AM
  2. Visual C + + 2010 asking for dll file
    By Maximiliano2 in forum Software Development
    Replies: 3
    Last Post: 01-12-2010, 05:27 AM
  3. How to create an .exe file in visual basic
    By kasha_i in forum Software Development
    Replies: 3
    Last Post: 21-04-2009, 11:53 PM
  4. DeviceEmulator050419.msi file in Visual Studio .NET
    By Preetish in forum Software Development
    Replies: 3
    Last Post: 04-03-2009, 08:29 AM
  5. Reading .CSV file in Visual Basic
    By iMacRicky in forum Software Development
    Replies: 4
    Last Post: 15-01-2009, 06:18 PM

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
  •  
Page generated in 1,727,251,509.87360 seconds with 17 queries