I am trying to write a function that returns a HWND from a process ID but there is one small problem. I am getting the error "expected an identifier". It will only compile if I remove the & in window_data &data
but then the function doesn't work.. Why is the & needed in the first place? The code compiles in C++ but not in C.
typedef struct
{
DWORD dwProcessID;
HWND hWnd;
} window_data;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
window_data &data = *(window_data*)lParam;
DWORD dwProcessID = 0;
GetWindowThreadProcessId(hwnd, &dwProcessID);
if (dwProcessID != data.dwProcessID)
return TRUE;
data.hWnd = hwnd;
return FALSE;
}