Ka-Ping Yee wrote: > Hi Thomas, > >> This does not work, for several reasons. >> >> 1. (pythoncom|pywintypes).CreateGuid() return a PyIID instance, which you >> cannot slice: > > You're right. The PEAK code must have been based on an earlier > version of the CreateGuid() routine. > > I've fixed this, and added detection of the UUID version so that > the MAC address will only be picked up if the UUID version is 1. > >> (BTW: Why does it first try pywintypes, the pythoncom?) > > Because PEAK does this, and i see the CreateGuid routine imported > from both modules in Google searches for code, i assumed that it > used to live in one module and moved to the other. > > I've also figured out how to get the MAC address using NetBIOS > calls, and added that to the repertoire of methods. I've tested > this and it works fast. I think this may be better than > UuidCreateSequential, because it should work on both Win98 and XP.
I have not tested the speed, but extending my snippet to also work on 98 should be nearly trivial: try: _func = windll.rpcrt4.UuidCreateSequential except AttributeError: _func = windll.rpcrt4.UuidCreate def CreateGuid(): uuid = UUID() if 0 == _func(byref(uuid)): return str(buffer(uuid)) Thomas _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com