Gilles Lenfant said:
Hi,
I bought and read most of (excellent) Mark Hammond's book, Python
programming on Win32.
I started to make some sophisticated "hello world" app using win32ui (...)
but I need some more information to make the bridge between this book and
the MFC (black hole for me) in depth.
Any advise on good reading, and some python examples ?
Many thanks in advance.
--Gilles
here's an example showing how to use the Registry API in
ActivePython.
I have other scripts that enum windows, use Menu objects, and do
IPC using SendMessage.
hth,
Mark Pryor
####### begin script ############
#!/usr/bin/python
'''
author: mark pryor
keywords: registry enum license typelib
description: scriptlet to enum a subkey collection
date: 11/8/02 3:03PM
'''
import os, sys
import win32api as wi
import win32con as wc
import string as st
#exercise to enumerate a subkey collection
# try this for the Licenses key, then the TypeLib key
kName = "Licenses"
kName = "TypeLib"
# get a handle
pyk = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, kName)
# get key info, num1 has the key count
( num1, vals, works) = wi.RegQueryInfoKey( pyk )
print num1, vals, works
nt = 0
guid = wi.RegEnumKey( pyk, nt )
nt = nt + 1
#
done = 0
for nt in range(num1):
guid = wi.RegEnumKey( pyk, nt)
svers = ''
if kName == "TypeLib":
'''
for TypeLibs we need to step down to the version key and
read the help string (default value)
'''
pyj = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, os.path.join(kName,
guid) )
(num2, val2, work2) = wi.RegQueryInfoKey(pyj)
if num2 > 0:
# we are ingnoring multi versions, like Ado (2.1, 2.5, 2.7, etc)
svers = wi.RegEnumKey( pyj, 0)
valkey = wi.RegQueryValue( pyj, svers)
else:
valkey = wi.RegQueryValue( pyk, guid)
print guid, svers, valkey
nt = nt + 1
pyk.Close()
sys.exit()