C++无法使用 FindWindow() 找到 cmd

C++ cant find cmd using FindWindow()

本文关键字:找到 cmd FindWindow C++      更新时间:2023-10-16
#include<iostream>
#include<Windows.h>
using namespace std;
int main()
{
HWND handle = FindWindow("ConsoleWindowClass","C:WINDOWSsystem32cmd.exe");
if (handle == NULL)
cout << "Window not found" << endl;
else
cout << "Window found " << endl;
system("pause");
return 0;
}

我尝试使用此代码查找正在运行的cmd应用程序的句柄,但是FindWindow((找不到句柄。它显示未找到Winodw。请帮忙。

对于 unicode,请尝试以下代码片段:

HWND handle = FindWindow(L"ConsoleWindowClass", L"C:\WINDOWS\system32\cmd.exe");