0

enumwindows を使用して現在のウィンドウを一覧表示しようとしており、このコード形式 cplusplus を使用しています

include <iostream>
include <windows.h>
using namespace std;

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);

int Main(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
EnumWindows(EnumWindowsProc, NULL);

return 0;
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
    char class_name[80];
    char title[80];
    GetClassName(hwnd,class_name, sizeof(class_name));
    GetWindowText(hwnd,title,sizeof(title));
    cout <<"Window title: "<<title<<endl;
    cout <<"Class name: "<<class_name<<endl<<endl;
    return TRUE;
}

main() は以前は winmain でしたが、コンソール アプリケーションを使用して出力を読み取りたかったので、それを main に切り替えました。ビルド時に未解決の外部エラーが発生しました。

error LNK2001: unresolved external symbol
[code["int stdcall EnumWindowsProc(struct HWND *, long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z) link.exe[/code] の実行エラー

XP で古いバージョンの Visual C++ を使用しており、kernel32 lib と user32 lib を含めました。

ありがとう。

4

0 に答える 0