c++中 GetClassLongPtr函数运行无返回问题


char numm[2550];
int i = 0;
BOOL CALLBACK 我的函数(HWND hwnd, LPARAM lparam)
{
    cout << hwnd << endl;
    TCHAR lpstr[MAX_PATH] = {};
    cout << (char)GetClassLongPtr(hwnd, _WIN64) << endl;
    GetWindowText(hwnd,lpstr,MAX_PATH);
    cout << lpstr << endl;
    return 1;
}
int main()
{

    EnumWindows(我的函数, NULL);
  

}

在此代码中为什么 EnumWindows;函数返回有值但 cout << (char)GetClassLongPtr(hwnd, _WIN64) << endl;返回就是空

img

(char)GetClassLongPtr(hwnd, _WIN64) 返回空值的原因是您尝试将 GetClassLongPtr 返回的值强制转换为 char。GetClassLongPtr 返回的值实际上是一个指针,不能直接转换为 char