[python-win32] com server running in taskbar

Janez Jere janez.jere at void.si
Thu Apr 8 18:54:56 EDT 2004


Hello com masters,

I want to know if it is possible to implement a com server, which will
not just start automatically via pythonw, but will be part of larger
application. For example:
there should be a gui application macro.py (like
win32\demos\win32gui_taskbar.py), which among other things serves com
objects (SanMacro).

I implemented simple com server, which is working fine except:
 - it is terminated when last reference of SanMacro is released
 - it is not working as taskbar app

is it possible to make a server a taskbar app, which will not terminate
after last instance of SanMacto will be deleted?

Thanks in advance

Janez
###################
# this is com server: macro.py
import pythoncom

cnt = 0 # common resource

class SanMacro:
    _public_methods_ = [ 'execScript' ]
    _reg_clsctx_= pythoncom.CLSCTX_LOCAL_SERVER

    _reg_clsid_ = "{65329968-260C-458A-9B0C-AF543EB782EE}"
    _reg_progid_ = "jj.san.macro"
    def execScript(self, script):
        global cnt
        cnt +=1
        m = "cnt: %s" % cnt
        print m, script
        return m

if __name__ == '__main__':
    import win32com.server.register
    win32com.server.register.UseCommandLine(SanMacro)

# and now run it in taskbar (this is notworking, but i would like to)

import win32.Demos.win32gui_taskbar # notepad  __init__.py in win32 &
Demos folder, to make it package
win32.Demos.win32gui_taskbar.main()
##################
# client script:
from  win32com.client import Dispatch
print Dispatch("jj.san.macro").execScript('test')




More information about the Python-win32 mailing list