title: Com server build using Python on 64-bit Windows 7 machine
body: <blockquote>
    <p>Original post is here:
    <a href="http://mail.python.org/pipermail/python-win32/2010-December/011011.html" rel="nofollow">http://mail.python.org/pipermail/python-win32/2010-December/011011.html</a></p>
    
    <p>I am using:</p>
    
    <ul>
    <li>OS: 64 bit Windows 7 Professional</li>
    <li>Python: python-2.7.1.amd64</li>
    <li>Python win32 extensions: pywin32-214.win-amd64-py2.7</li>
    <li>Py2exe: py2exe-0.6.9.win64-py2.7.amd64</li>
    </ul>
  </blockquote>
  
  <p>I am trying to build icon overlay for Windows. It has worked fine on 32 bit
  Windows but not working on 64 bit Windows 7.</p>
  
  <p>Here are the Python modules I have created for testing:</p>
  
  <ol>
  <li><p>test_icon_overlay.py: ( <a href="http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0002.obj" rel="nofollow">http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0002.obj</a> ) com server created in Python for icon overlay which
  adds check mark overlay icon(C:\icons\test.ico) on "C:\icons" folder</p></li>
  <li><p>setup_VI.py: ( <a href="http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj" rel="nofollow">http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0003.obj</a> ) setup file which creates test_icon_overlay.dll for
  distribution.</p></li>
  <li>icons.zip: ( <a href="http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0001.zip" rel="nofollow">http://mail.python.org/pipermail/python-win32/attachments/20101229/bb8c78a4/attachment-0001.zip</a> ) for testing you should extract icons.zip inside C:\</li>
  </ol>
  
  <p>Icon overlay appears on <code>C:\icons</code> folder when I execute <code>python
  test_icon_overlay.py</code> on Windows command prompt and restarts <code>explorer.exe</code>.
  But its not working with the dll file created using <code>setup_VI.py</code></p>
  
  <p>I have created dll file using <code>python setup_VI.py py2exe</code> and then tried to
  register it using <code>regsvr32 test_icon_overlay.dll</code>. Registration fails with
  windows error message <code>Error 0x80040201 while registering shell extension</code>.</p>
  
  <p>Then I turned on logger in <code>Python27/Lib/site-packages/py2exe/boot_com_servers.py</code> and here is the traceback which I am getting in <code>comerror.txt</code> on <code>regsvr32
  test_icon_overlay.dll</code></p>
  
  <pre><code>PATH is ['C:\\root\\avalon\\module\\sync\\python\\src\\dist\\library.zip']
  Traceback (most recent call last):
    File "boot_com_servers.py", line 37, in &lt;module&gt;
  pywintypes.error: (126, 'GetModuleFileName', 'The specified module could not
  be found.')
  Traceback (most recent call last):
    File "&lt;string&gt;", line 1, in &lt;module&gt;
  NameError: name 'DllRegisterServer' is not defined
  </code></pre>
  
  <p>Looks like there might be a problem with <code>win32api.GetModuleFileName(sys.frozendllhandle)</code> or with the dll build on 64-bit Windows 7.</p>
  
  <p>Also, I saw that installation of <code>pywin32-214.win-amd64-py2.7</code> on 64-bit Windows 7 finish with the error message: <a href="http://mail.python.org/pipermail/python-win32/attachments/20101231/816a2063/attachment-0001.png" rel="nofollow">Snapshot</a></p>
  
  <pre><code>close failed in file object destructor:
  sys.excepthook is missing
  lost sys.stderr
  </code></pre>
  
  <p>Is there anything which I am doing wrong? Any help on this is highly
  appreciated.</p>