[python-win32] Problems with Python+COM and XP Firewall Manager

Jens B. Jorgensen jens.jorgensen at tallan.com
Fri Oct 24 10:26:07 EDT 2003


Robert Olson wrote:

> At 07:00 PM 10/23/2003, Jens B. Jorgensen wrote:
>
>> You can actually fix this by modifying the hnet.py that was generated 
>> by makepy. Go to the line in there where it defines 
>> INetSharingConfigurationForINetConnection there is a line there with 
>> "InvokeTypes(0x6, LCID, 2, (9, 0), ((9, 1)"... and change the bit 
>> with "((9, 1)" to "((13, 1)" and now the code should work. If I had 
>> more time to spare at the moment looking at this I'd figure out a 
>> patch for makepy and send it on to Mark.
>
>
> And again, it works like a champ.
>
> (and I find that even though I get a dialog from Windows implying that 
> the firewall setting change will only last while the app is running, 
> the change sticks).
>
> Thanks so much.

Great to hear it worked out. By the way after I sent that last email I 
realized I should have probably explained a bit more. The 5th argument 
to InvokeTypes is a tuple describing the parameters to be passed to the 
function. The constant numeric values correspond to the enumeration 
constants for the VARIANT type. The value 9 is VT_DISPATCH, while value 
13 is VT_UNKNOWN. In the python com code a standard windows call is made 
to translate whatever type was passed into the variant type indicated. 
In this case an IUnknown * is passed and the python com code asks it to 
be converted to VT_DISPATCH (IDispatch *) which means that 
IUnknown->QueryInterface is called to get an IDispatch interface. Since 
the INetConnection interface doesn't derive from IDispatch and that 
class doesn't support it this call fails telling you it can't get that 
interface.

When makepy iterates through the type library it sees the argument to 
the function is type INetConnection *. When it is passed though it needs 
to be either IDispatch * or IUnknown * because that's what the dispatch 
(VARIANT) supports. I guess it just assumed that IDispatch * would work. 
It may not have bothered to see what INetConnection derived from or it 
may have made a mistake.

-- 
Jens B. Jorgensen
jens.jorgensen at tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions."





More information about the Python-win32 mailing list