Windows Common Item Dialog: ctypes + COM access violation

1 answer

Here is the solution:

COM methods accept an additional parameter: a pointer to 'this'. This is implied when you call a method from C ++, in C (and in ctypes) you must provide it yourself.

Change the line

 func_proto = ctypes.WINFUNCTYPE(HRESULT, HWND) 

in

 func_proto = ctypes.WINFUNCTYPE(HRESULT, c_long, HWND) 

and this line

 show(0) 

in

 show(ptr, 0) 

and your code will work.

+5
source

Source: https://habr.com/ru/post/926463/


All Articles