我正在尝试从 txt 文件中读取窗口标题
我将使用 GetTitleWidnow 使用字符串获取窗口标题
我试过了,但它没有在应用程序中显示菜单
ostringstream GetTitleWidnow;
GetTitleWidnow << "MainSvrt on port 51752";
LPCWSTR LMainSvrtTitle;
std::string SMainSvrtTitle = GetTitleWidnow.str();
LMainSvrtTitle = (LPCWSTR)SMainSvrtTitle.c_str();
HWND hWnd = FindWindow(NULL,LMainSvrtTitle);
HMENU hCurrent = GetMenu(hWnd);
HMENU hNew = CreateMenu();
AppendMenu(hCurrent, MF_STRING | MF_POPUP, (unsigned int)hNew, TEXT("Menu"));
AppendMenu(hNew, MF_STRING, MYMENU_Reload, TEXT("Reload Config"));
AppendMenu(hNew, MF_STRING, MYMENU_Credits, TEXT("Credits"));
DrawMenuBar(hWnd);
但是当我尝试
HWND hWnd = FindWindow(NULL,TEXT("MainSvrt on port 51752"));
我让它工作正常,它在应用程序中显示菜单