Hello, all I tested a python script using win32com and VC++, but I have some problem to use interfaces from my python code to VC++.
-mypython code- 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 win32com.server.register.UseCommandLine(ShowMeDoDemo) 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 a posted message from bbs regarding “Typelib python COM Server” so, I wrote a .IDL file in hand as the instruction. import "oaidl.idl"; import "ocidl.idl"; [ //below uuid is for type library COMTESTLib uuid(12AECA5C-C50A-4f01-8CFB-CE5FC9FE16C1), version(1.0), helpstring("showMeDoDemo Typelib") ] library ShowmeDoLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); //dispinterface IShowMeDoDemo; [ object, // below uuid is for Interface uuid(5104D21B-5756-4ABA-8632-B386C283CCC3), dual, helpstring("IClient Interface"), pointer_default(unique) ] //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 uuid(5BA13EC0-8FCC-4d1b-ABED-AE52B2C8DBE3), 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 wrong? Why can't I access interfaces of my python code from VC++? 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. Best, Ji
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32