So far all the example win32 routines I've found, through google, only work on newer xp and nt versions of windows. This is the current attempt to get the process list on windows 98:
def GetProcessNameList(): from win32com.client import GetObject WMI = GetObject('winmgmts:') processes = WMI.InstancesOf('Win32_Process') names = [] for process in processes: names += [process.Properties_('Name').Value] return names
def IsRunning( filename ): n = 0 for process in GetProcessNameList(): if process.lower() == filename.lower(): n += 1 return n
Then in the startup section:
filename = os.path.basename(sys.argv[0]) # Wait for preview window to exit. t = clock() while IsRunning( filename) > 1 and clock() < t + 3: sleep(.01) # Start screen saver if only self is running. if IsRunning( filename)==1: saver = Screensaver() saver.launchScreenSaver()
Results in this error on windows 98, works fine on windows xp:
Traceback (most recent call last): File "Aztec.pyw", line 255, in ? File "Aztec.pyw", line 38, in IsRunning File "Aztec.pyw", line 29, in GetProcessNameList File "win32com\client\__init__.pyc", line 73, in GetObject File "win32com\client\__init__.pyc", line 88, in Moniker pywintypes.com_error: (-2147221014, 'Moniker cannot open file', None, None)
The program is in python v2.3 and packaged using pyexe, and inno setup.
-- http://mail.python.org/mailman/listinfo/python-list