win32pdh and background processes

David L. Jessup dljessup at ix.netcom.com
Thu Jul 1 17:16:37 EDT 2004


I'm sorry if this is a duplicate posting.  I attempted to post before,
but it doesn't appear to have been sent out correctly.

Anyway, I've got a problem, and I'm hoping somebody here can help. 
First the background:

I'm trying to write a program that monitors processes on a legacy
Windows NT 4.0 box.  I have written one version of this program that I
can run from the command line --- but logging out of the account kills
the program.  I have also written a version of this program that runs
(successfully) as a service on Windows 2000, but fails on Win NT with
the following message:

    The procedure entry point RegisterServiceCtrlHandlerExW could not
    be located in the dynamic link library ADVAPI32.dll.

Further investigation has revealed that this DLL problem is associated
with all versions of the servicemanager module dating back to its
introduction in version 161 of the win32 package.

I have also tried running my program under the Scheduled Tasks
service.  If I am logged in, this works perfectly well, although it
creates a console for the program.  However, if I am not logged in,
the program dies on the win32pdh.EnumObjectItems function:

    items, instances = win32pdh.EnumObjectItems(None, None, \
      'Process', win32pdh.PERF_DETAIL_WIZARD)

My questions are:
(a) Why does win32pdh.EnumObjectItems die when I am not logged on?
(b) Is there a technique other than creating my own service or using
the Scheduled Tasks service to run a program when I'm not logged in?

--- David



More information about the Python-list mailing list