newbie win32 stuff

tony roth roth at teleport.com
Mon Dec 27 17:03:41 EST 1999


I have a script that when I run it within pythonwin it behaves poorly but
when I run it within idle it runs just fine.  Below is the code, I'm just
learning python so forgive me if it looks screwy.   Under idle it creates a
tuple "dm" which contains the names of all workstations within the
"xyzdomain" and then enumerates the nameserver values but under pythonwin it
just hangs the process.  Any ideas.
thanks

ps the try/except construct is still confusing to me.  Is the try catching
all exceptions generated beween the the try: except: construct?

import win32net,win32netcon,win32api,win32con
dm=win32net.NetServerEnum('',100,win32netcon.SV_TYPE_WORKSTATION,'xyzdomain'
,0,4096*2)
for x in dm[0]:
   try:

rk=win32api.RegConnectRegistry(str(x['name']),win32con.HKEY_LOCAL_MACHINE)

nk=win32api.RegOpenKeyExrk,'SYSTEM\\CurrentControlSet\\Services\\NetBT\\Adap
ters\\',0,win32con.KEY_ALL_ACCESS)
      test=win32api.RegEnumKey(nk,0)
      regkey='SYSTEM\\CurrentControlSet\\Services\\NetBT\\Adapters\\' + test
      nk=win32api.RegOpenKeyEx(rk,regkey,0,win32con.KEY_ALL_ACCESS)
      ns=win32api.RegQueryValueEx(nk,'NameServer')
      print str(x['name']),
      print ns[0][0],
except:
      print "can not contact " + str(x['name'])






More information about the Python-list mailing list