Wednesday, May 23, 2012

can not generate necessary file when compile IDL file in visual studio 2010

i'm learning about COM through an internet tutorial(http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567/Step-by-Step-COM-Tutorial.htm). The first thing is creating a IDL file and compile it to create another 5 files. The detail is after:




  1. Open VS2010

  2. Create Win32 DLL project name AddObj

  3. Add IAdd.idl file with the content




    import "unknwn.idl";



    [
    object,
    uuid(1221db62-f3d8-11d4-825d-00104b3646c0),
    helpstring("interface IAdd is used for implementing a super-fast addition Algorithm")
    ]



    interface IAdd : IUnknown
    {
    HRESULT SetFirstNumber(long nX1);



    HRESULT SetSecondNumber(long nX2);
    HRESULT DoTheAddition([out,retval] long *pBuffer);
    };



    [
    uuid(3ff1aab8-f3d8-11d4-825d-00104b3646c0),
    helpstring("Interfaces for Code Guru algorithm implementations .")
    ]
    library CodeGuruMathLib
    {
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");



    interface IAdd;
    }





After that, follow the tutorial, if i compile IAdd.idl file, it will generate:



--IAdd.h Contains the C++ style interface declarations.



--dlldata.c Contains code for proxy DLL. Useful when invoking the object on a different process/computer.



--IAdd.tlb Binary file , with a well defined format that completely describes our interface IAdd along with all it's methods. This file is to be distributed to all the clients of our COM component.



--IAdd_p.c Contains marshalling code for proxy DLL. Useful while invoking the object on a different process/computer.



--IAdd_i.c Contains the interface IIDs



but when i compile IAdd by right click it and choose compile in shortcut menu, there is no file being generate. But when open view class, i can see IAdd interface with some method.



I also try it by compile it manually by download midl.exe from internet and run in command line but it failed.



I fine a lot of material by google and all said that i can compile idl file by visual studio but i try many time, on my both computer but no file being generate after i compile idl file. I also install new Win7, new visual studio 2010 ultimate but nothing change.





No comments:

Post a Comment