[python-win32] ISensLogon COM Object

Roger Upole rwupole at msn.com
Thu Jan 10 14:06:52 CET 2008


This works on XP and Vista.

import win32com.client
import win32com.server.policy
import pythoncom

## from Sens.h
SENSGUID_PUBLISHER = "{5fee1bd6-5b9b-11d1-8dd2-00aa004abd5e}"
SENSGUID_SUBSCRIBER_LCE ="{d3938ab0-5b9d-11d1-8dd2-00aa004abd5e}"
SENSGUID_SUBSCRIBER_WININET = "{d3938ab5-5b9d-11d1-8dd2-00aa004abd5e}"
SENSGUID_EVENTCLASS_NETWORK = "{d5978620-5b9f-11d1-8dd2-00aa004abd5e}"
SENSGUID_EVENTCLASS_LOGON = "{d5978630-5b9f-11d1-8dd2-00aa004abd5e}"
SENSGUID_EVENTCLASS_ONNOW = "{d5978640-5b9f-11d1-8dd2-00aa004abd5e}"
SENSGUID_EVENTCLASS_LOGON2 = "{d5978650-5b9f-11d1-8dd2-00aa004abd5e}"


## from EventSys.h
CLSID_CEventSystem="{4E14FBA2-2E22-11D1-9964-00C04FBBB345}"
CLSID_CEventSubscription="{7542e960-79c7-11d1-88f9-0080c7d771bf}"
IID_IEventSubscription="{4A6B0E15-2E38-11D1-9965-00C04FBBB345}"

PROGID_EventSystem = "EventSystem.EventSystem"
PROGID_EventPublisher = "EventSystem.EventPublisher"
PROGID_EventClass = "EventSystem.EventClass"
PROGID_EventSubscription = "EventSystem.EventSubscription"
PROGID_EventPublisherCollection = "EventSystem.EventPublisherCollection"
PROGID_EventClassCollection = "EventSystem.EventClassCollection"
PROGID_EventSubscriptionCollection = "EventSystem.EventSubscriptionCollection"
PROGID_EventSubsystem = "EventSystem.EventSubsystem"
EVENTSYSTEM_PUBLISHER_ID = "{d0564c30-9df4-11d1-a281-00c04fca0aa7}"
EVENTSYSTEM_SUBSYSTEM_CLSID = "{503c1fd8-b605-11d2-a92d-006008c60e24}"

IID_ISensLogon = "{d597bab3-5b9f-11d1-8dd2-00aa004abd5e}"
class SensLogon(win32com.server.policy.DesignatedWrapPolicy):
    _com_interfaces_=[IID_ISensLogon]
    _public_methods_=[
        'Logon',
        'Logoff',
        'StartShell',
        'DisplayLock',
        'DisplayUnlock',
        'StartScreenSaver',
        'StopScreenSaver'
        ]
    
    def __init__(self):
        self._wrap_(self)
    def Logon(self, *args):
        print 'Logon'
        print args
    def Logoff(self, *args):
        print 'Logoff'
        print args
    def StartShell(self, *args):
        print 'StartShell'
        print args
    def DisplayLock(self, *args):
        print 'DisplayLock'
        print args
    def DisplayUnlock(self, *args):
        print 'DisplayUnlock'
        print args
    def StartScreenSaver(self, *args):
        print 'StartScreenSaver'
        print args
    def StopScreenSaver(self, *args):
        print 'StopScreenSaver'
        print args

sl=SensLogon()
subscription_interface=pythoncom.WrapObject(sl)

event_system=win32com.client.Dispatch(PROGID_EventSystem)

event_subscription=win32com.client.Dispatch(PROGID_EventSubscription)
event_subscription.EventClassID=SENSGUID_EVENTCLASS_LOGON
event_subscription.PublisherID=SENSGUID_PUBLISHER
event_subscription.SubscriptionName='Python subscription'
event_subscription.SubscriberInterface=subscription_interface

event_system.Store(PROGID_EventSubscription, event_subscription)


      Roger



More information about the python-win32 mailing list