<div>Here is my sample COM server and py2exe setup file</div>
<div> </div>
<div><strong>testCOM.py</strong></div>
<div> </div>
<div><font color="#3366ff">import win32com.client<br>import os.path<br>import shutil<br>from win32api import Sleep<br>import string<br>import os<br>import sys<br>import pythoncom</font></div>
<div><font color="#3366ff"> <br>class FirstEx:</font></div>
<div> </div>
<div><font color="#3366ff"> _reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"<br> pythoncom.frozen = 1<br> if hasattr(sys, 'importers'):<br> # In the py2exe-packed version, specify the
module.class<br> # to use. In the python script version, python is able<br> # to figure it out itself.<br> _reg_class_spec_ = "__main__.FirstEx"<br> _reg_desc_ = "My first COM server"
<br> _reg_progid_ = "SAMPLE.Lib" <br> _public_methods_ = ['init', 'Version']<br> _public_attrs_ = ['softspace', 'noCalls']<br> _readonly_attrs_ = ['noCalls']
<br> _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER</font></div>
<div>
<p><br><font color="#3366ff"> def __init__(self):<br> self.softspace = 1<br> self.noCalls = 0<br> </font></p>
<p><font color="#3366ff"> def Version(self):<br> self.noCalls = self.noCalls + 1</font></p>
<p><font color="#3366ff"> # insert "softspace" number of spaces<br> return "Version: 0.0.1" <br> <br> <br>if __name__=='__main__':<br> import sys<br> if hasattr(sys, 'importers'):
<br> # running as packed executable.<br> if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]:<br> # --register and --unregister work as usual<br> import win32com.server.register
<br> win32com.server.register.UseCommandLine(FirstEx)<br> else:<br> # start the server.<br> from win32com.server import localserver<br> localserver.main()<br> else:<br>
import win32com.server.register<br> win32com.server.register.UseCommandLine(FirstEx)</font></p>
<p> Here is my setup file:</p>
<p><font color="#3366ff">#Start here <br>from distutils.core import setup <br>import py2exe </font></p>
<p><font color="#3366ff">setup(options = {"py2exe": {"compressed": 1,<br> "optimize": 2,<br> "ascii": 1,<br> "bundle_files": 1}},
<br> zipfile = None,<br> com_server = ["win32com.servers.interp"],<br> console = ["testCOM.py"]) <br>#End here</font><br></p>
<p>Here is my VB code:</p>
<p><font color="#3366ff">Sub subRoutine()<br>Dim connection As Object<br>Dim returnvalue1 As String<br>Dim returnvalue2 As String<br>Dim flag3 As Boolean</font></p>
<p><font color="#3366ff">Set connection = CreateObject("SAMPLE.Lib")<br>returnvalue1 = connection.Version()<br>MsgBox (returnvalue1)<br>End Sub<br></font></p>
<p><font color="#000000">The non exe version of the COM server ie. directlly running the testCOM.py registers the library properly and </font></p>
<p><font color="#000000">in the VB application, the message box displays the version as 0.0.1.</font></p>
<p><font color="#000000">But, after I create the EXE file using the setup.py file and run it, it registers the library.</font></p>
<p><font color="#000000">When I run the VB application, it hangs at the line</font></p>
<p><font color="#000000"><strong>Set connection = CreateObject("SAMPLE.Lib")</strong></font></p>
<p><font color="#000000">and displays. " ACTIVEX cannot create the object"</font></p>
<p><font color="#000000">Any suggestions please....</font></p>
<p> <br></p></div>
<div><span class="gmail_quote">On 1/8/08, <b class="gmail_sendername">Tejovathi P</b> <<a href="mailto:tejovathi.p@gmail.com">tejovathi.p@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>I am trying to create the obj in VB in the same manner, ie</div>
<div> </div>
<div>Set Obj = CreateObject("<font face="Verdana" size="2">sample.lib")</font></div>
<div><font face="Verdana" size="2">Strangely, the non exe version of the COM server works fine and I am able to access the public functions in VB application.</font></div>
<div><font face="Verdana" size="2"></font> </div>
<div><font face="Verdana" size="2">Problem comes with the EXE version of the COM server, VB application jus hangs while executing, </font></div><span class="q">
<div><font face="Verdana" size="2">
<p style="TEXT-INDENT: 0.5in"><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Set obj = CreateObject("sample.lib")</span></font></p></font></div>
<div><br><br> </div></span>
<div><span class="e" id="q_11758fc4a2852836_2">
<div><span class="gmail_quote">On 1/8/08, <b class="gmail_sendername">Pramod P G</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:pramodpg@aztecsoft.com" target="_blank">pramodpg@aztecsoft.com
</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana">Hi,</span></font></p>
<p><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana">Try out this statement</span></font></p>
<p><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana"> </span></font></p>
<p><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana">This might help U </span></font><font face="Wingdings" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Wingdings">
J</span></font><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana"> </span></font></p>
<p><font face="Verdana" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana"> </span></font></p>
<p style="TEXT-INDENT: 0.5in"><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Set obj = CreateObject("sample.lib")</span></font></p>
<p><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> </span></font></p>
<p><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Thanks and regards,</span></font></p>
<p><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Pramod P G</span></font></p>
<p><font face="Arial" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> </span></font></p>
<div>
<div style="TEXT-ALIGN: center" align="center"><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">
<hr align="center" width="100%" size="2">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</span></font></b><font face="Tahoma" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-win32-bounces@python.org" target="_blank">
python-win32-bounces@python.org</a> [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-win32-bounces@python.org" target="_blank">python-win32-bounces@python.org</a>] <b><span style="FONT-WEIGHT: bold">
On Behalf Of </span></b>Tejovathi P<br><b><span style="FONT-WEIGHT: bold">Sent:</span></b> Tuesday, January 08, 2008 3:57 PM<br><b><span style="FONT-WEIGHT: bold">To:</span></b> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-win32@python.org" target="_blank">
python-win32@python.org</a><br><b><span style="FONT-WEIGHT: bold">Subject:</span></b> [python-win32] Regarding COM server and exe</span></font></p></div>
<div><span>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Hi All,</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">I have a Python COM server. I need to deploy it on various sytems. When I run the COM server from</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">python its showing an output " Registered : sample.lib"</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">If I try to use the COM obj from a VB client like:</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">obj = CreateObject("sample.lib")</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Its working fine without any errors</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Now I am trying to convert this COM server to an exe through py2exe and after I run the exe, I am</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">getting the same output " Registered : sample.lib"</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">But If I try to use the COM obj from a VB client like</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">obj = CreateObject("sample.lib")</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">A console pops up saying " Registered : sample.lib" and VB application hangs there.</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Its throwing a VB error that "ActiveX object cannot be created......etc etc"</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Any suggestions please.......</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Regards,</span></font></p></div>
<div>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">Tejovathi</span></font></p></div></span></div></div></div>
<table>
<tbody>
<tr>
<td bgcolor="#ffffff"><font color="#000000"><br>The information contained in, or attached to, this e-mail, contains confidential information and is intended solely for the use of the individual or entity to whom they are addressed and is subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email.
<br><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.aztecsoft.com/" target="_blank">www.aztecsoft.com</a><br></font></td></tr></tbody></table></blockquote></div><br></span></div></blockquote>
</div><br>