I am trying to get properties from an HWND
. I'm used information from Using Window Properties, but the example below is not working for me. I'm getting an error while compiling my code.
argument of type "BOOL (__stdcall *)(HWND hwndSubclass, LPCSTR lpszString, HANDLE hData)" is incompatible with parameter of type "PROPENUMPROCEXW"
Here is my callback function
BOOL CALLBACK PropEnumProcEx(HWND hwndSubclass, LPCSTR lpszString, HANDLE hData) {
return TRUE;
}
and this how I'm using it
EnumPropsEx(hwnd, PropEnumProcEx, NULL);
Does someone have any suggestions of how this can be fixed?
LPCSTR lpszString
should beLPTSTR lpszString
. This argument should accept a pointer to either ANSI or Unicode null-terminated string.PROPENUMPROCEXW
indicates that you are building Unicode application soEnumPropsEx
macro expands toEnumPropsExW
call so you need to provide callback accepting wide string as an argument. Typically you should always explicitly call Unicode variants of API functions.Also you are missing last argument
ULONG_PTR dwData
.So your callback should look like: