I tested a python script using win32com and py2exe.


import pythoncom

IID_IShowMeDoDemo = pythoncom.MakeIID("{5104D21B-5756-4ABA-8632-B386C283CCC3}")

_reg_clsid_ = "{12AECA5C-C50A-4f01-8CFB-CE5FC9FE16C1}"

_reg_libname = "ShowMeDoDemo Typelib"


class ShowMeDoDemo:

    _public_methods_ = ['SFactorial','SHello']

    _reg_progid_ = "ShowMeDo.Demo1"

    _reg_clsid_ = "{5BA13EC0-8FCC-4d1b-ABED-AE52B2C8DBE3}"   

    def SHello(self):

        "say Hello"

        return "Hello World"

    def SFactorial(self,n):

        "calculate n!"

        result = 1

        for value in range(2,n+1):

            result = result * value

        return result


if __name__ == "__main__":

    print "Registering COM server..."

import win32com.server.register



and I succeed Registering of this COM object and found its information with OLE/VIEW – named ShowMeDo.Demo1 under python COM Server folder(object classes)

I read the posted message from bbs regarding “Typelib python COM Server” and I wrote a .IDL file in hand as the instruction.


import "oaidl.idl";

import "ocidl.idl";


//below uuid is for type library COMTESTLib



        helpstring("showMeDoDemo Typelib")


library ShowmeDoLib




        //dispinterface IShowMeDoDemo;



             // below uuid is for Interface



             helpstring("IClient Interface"),



       //methods of Client class

       //interface IShowMeDoDemo : IDispatch

       interface IShowMeDoDemo : IUnknown



             import "UNKNWN.IDL";

             //[out] BSTR cmd

                [id(1100), helpstring("method Hello")] HRESULT SHello([out, retval] BSTR* message);

             //([in] BSTR cmd);

                [id(1101), helpstring("method Factorial")] HRESULT SFactorial([in] int fn, [retval,out] int* rfn);



       //below uuid is CLISD of Search.dll


            helpstring("ShowMeDoDemo Class")


       // class of Search.dll

       coclass ShowMeDoDemo


       // interfaces of class Client generated by Search.dll

             [default] interface IShowMeDoDemo;




Then I executed “MILD” in VC98 and got some files names “xx.h” and “xx_i.c” and tlb etc.

So, I generated a VC++ project to call the instance with those.

Even I succeed to compile but when I execute the result, it shows “interface error” which called by hr==E_NOINSTANCE after queryinterface().


Do I miss anything or did something worng?

Is there any way to call and use the “xxx.dll” file in python to VC. I’d like to use my python methods with only “dll” in C/C++

(Not Extending python code to C since my purpose is providing my module to VC user without exposing my code)


I expect any advice or a breakthrough from you all. I really appreciate with your attention and help.