PyXR

c:\python24\lib\site-packages\win32 \ com \ server \ localserver.py



0001 # LocalServer .EXE support for Python.
0002 #
0003 # This is designed to be used as a _script_ file by pythonw.exe
0004 #
0005 # In some cases, you could also use Python.exe, which will create
0006 # a console window useful for debugging.
0007 #
0008 # NOTE: When NOT running in any sort of debugging mode,
0009 # 'print' statements may fail, as sys.stdout is not valid!!!
0010 
0011 #
0012 # Usage:
0013 #  wpython.exe LocalServer.py clsid [, clsid]
0014 import sys
0015 sys.coinit_flags = 2
0016 import pythoncom
0017 import win32api
0018 from win32com.server import factory
0019 
0020 usage = """\
0021 Invalid command line arguments
0022 
0023 This program provides LocalServer COM support
0024 for Python COM objects.
0025 
0026 It is typically run automatically by COM, passing as arguments
0027 The ProgID or CLSID of the Python Server(s) to be hosted
0028 """
0029 
0030 def serve(clsids):
0031         infos = factory.RegisterClassFactories(clsids)
0032 
0033         pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())        
0034         pythoncom.CoResumeClassObjects()
0035 
0036         pythoncom.PumpMessages()
0037         
0038         factory.RevokeClassFactories( infos )
0039         
0040         pythoncom.CoUninitialize()
0041         
0042 def main():
0043         if len(sys.argv)==1:
0044                 win32api.MessageBox(0, usage, "Python COM Server")
0045                 sys.exit(1)
0046         serve(sys.argv[1:])
0047 
0048 if __name__=='__main__':
0049         main()
0050 

Generated by PyXR 0.9.4
SourceForge.net Logo