[python-win32] Re: Windows service features and Python
Imre András Róbert
beast at ludens.elte.hu
Mon Aug 16 13:59:03 CEST 2004
Hello Mark,
Monday, August 9, 2004, 2:28:08 PM, you wrote:
>> Based on the downloaded source, I created a dll with MSVC, and managed
>> to write events with IDs from that dll. However, for custom categories
>> I had to create the registry keys by hand, because I found no
>> method for
>> this in PyWin32.
> win32evtlogutil.py may have some helpers you find useful - it can register
> new event categories. win32service* only provide service specific
> functions - even though services usually use event logging functions, they
> are a discrete set of APIs.
win32evtlogutil.py deals with EventMessageFile and TypesSupported reg
keys only. For categories two additional keys should be used,
CategoryMessageFile and CategoryCount. These two keys I did not find
throughout all the source. Should I log the need for category support
as an RFE?
Maybe we could add this to the registering method like:
def AddSourceToRegistry(appName, msgDLL = None, eventLogType =
"Application", eventLogFlags = None, catDLL = None, catCount = 0):
>> Now I'm trying to figure out how can I make these IDs visible by
>> symbolic name in my Python source, like pipeTestService uses
>> servicemanager.pyd. I don't want to define these twice, and
>> keep in sync all the time...
> Check out "h2py" in the Python "Tools\scripts" directory for one option.
Yes, that would be fine for some sort of automatic translation of IDs
into Python source, provided I modified it for handling .mc syntax
instead of .h, but I'd like to see these IDs in only one source.
I'm trying to create a .cpp with these constants. Since I didnt
find a minimal Windows .dll example that can be used for Python,
I will try to deduce one from servicemanager.cpp.
>> I found this out only by looking at the source, as its help does
>> not mention this switch. It would also be nice if this would
>> support pause and continue functions.
> I agree. I'd welcome specific suggestions as to what needs better docs (and
> welcome even more the specific text to use <wink>). The --perfmon switches
> were a (possibly poor) attempt at merging services and the permon API, but
> although often used by services, just like the event logging functions they
> are a different set of APIs
I think the perfmon switches are quite ok, as they really have a relationship
with services.
Should I log the need for cmd line pause and continue as an RFE?
May I suggest adding the following usage information:
--perfmonini file: .ini file to use for registering performance monitor data
--perfmondll file: .dll file to use when querying the service for
performance data, default = perfmondata.dll
>> Thanks for the help so far.
>>
>> It seems that now I got all the answers, except for one new question:
>>
>> Q4) I can't make my service interactive. I never get a console
>> window despite that I use the --interactive flag, and I can
>> see it set under the logon tab of service properties. What
>> did I get wrong?
> I believe that flag controls the service's access to the win32 "desktop"
> (which is not the same as the Windows Explorer deskop). ie, if your service
> is "interactive", then you should see modal dialogs and other windows
> displayed by the service. However, you don't see a console created for the
> service itself (in the same way as you don't see a console created for other
> services when you set this flag via the standard Windows services GUI)
There are some services which give a console window when this flag
is set. I thought pythonservice.exe is such a console app. I suppose
with some modifications it would be suitable to compile it as a
console app.
--
Thanks,
András
> As I said before, you need to assume your questions are *not* Python related
> (until you can show otherwise), rather than the other way around :)
> Mark.
More information about the Python-win32
mailing list