[python-win32] How to find corresponding WMI/COM object for given Windows Registry key?

Radek Holý radekholypublic at gmail.com
Mon Jun 18 09:12:17 CEST 2012


2012/6/18 Tim Golden <mail at timgolden.me.uk>:
> On 18/06/2012 00:58, Radek Holý wrote:
>>
>> My question is probably poorly formulated.
>> In fact -- as I discovered -- some WMI objects reflect their values in
>> the Windows Registry keys (for example there is mapping
>> “root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot” in
>>
>> “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot”).
>> Is there some *common* attribute of WMI/COM/OLE objects giving the key
>> path?
>
>
> I don't believe so. The thing about WMI is that it provides a
> uniform and accessible layer on top of quite a lot of lower-level
> APIs. In some cases, that's a layer over registry entries; in other
> cases it's a layer over an actual API call. It may even be the only
> publicly-accessible means of achieving some result.
>
> As it happens, for *methods* there is sometimes a clue as to the
> underlying API. I have exposed this as (for want of a better name) the
> provenance attribute of a method class. So if you do this:
>
> <code>
> import wmi
>
> print wmi.WMI().Win32_Process.Create.provenance
>
> </code>
>
> You'll see something like this:
>
> Win32API|Process and Thread Functions|CreateProcess
>
> I'm not aware of any such thing for attributes, although it wouldn't
> surprise me utterly if there were.

I know that the dependence WMI <-> WinReg is not frequent. Saying
“common attribute” I thought common to this (reflecting) type of
objects. So it seems that it was an exception that I managed to print
this thing.
Or is it possible that the attribute belongs to underlaying COM or OLE
object? (In the pywin32 implementation!)

I wonder which object it was... :-/ What a pity that interactive shell
does not remember the history of commands after rebooting the
computer… :-D
-- 
Radek Holý
Czech republic


More information about the python-win32 mailing list