SendMessage가 필요한 클래스에서 텍스트를 가져 오지 못하는 이유를 모릅니다. 전에이 작업을했는데 VisualBasic이 였고 C++로 이식하려고했습니다. 다른 프로그램에서이 코드를 시도하지 않았습니다. 나는 그것에 대해 유니 코드 일 가능성이있는 것을 읽고 있었지만 구현 방법에 대해서는 확실하지 않았습니다. 이 프로그램은 문제없이 클래스를 발견하고 그것을 찾을해야하는 이유는 그래서 이유가 표시되지 않습니다 발견하지보고하지 않습니다 SendMessage가 텍스트를 가져 오지 않습니다.
:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream>
using namespace std;
void FindmIRC()
{
cout << "[mIRC]" << endl;
cout << "- find mIRC window" << endl;
HWND hwndmIRC = FindWindow(L"mIRC", NULL);
if (NULL != hwndmIRC)
{
cout << " + found mIRC window" << endl;
cout << "- find MDIClient window" << endl;
HWND hwndMDIClient = FindWindowEx(hwndmIRC, NULL, L"MDIClient", NULL);
if (NULL != hwndMDIClient)
{
cout << " + found MDIClient window" << endl;
cout << "- find mIRC_Channel window" << endl;
HWND hwndmIRC_Channel = FindWindowEx(hwndMDIClient, NULL, L"mIRC_Channel", NULL);
if (NULL != hwndmIRC_Channel)
{
cout << " + found mIRC_Channel window" << endl;
cout << "- find Static window" << endl;
HWND hwndStatic = FindWindowEx(hwndmIRC_Channel, NULL, L"Static", NULL);
if (NULL != hwndStatic)
{
cout << " + found Static window" << endl;
cout << "- get text length" << endl;
int textLen = (int)SendMessage(hwndStatic, WM_GETTEXTLENGTH, 0, 0);
if (0 < textLen)
{
cout << "- getting text" << endl;
const int bufferSize = 1024;
char textBuffer[bufferSize] = "";
SendMessage(hwndStatic, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)textBuffer);
cout << "[begin text]" << endl;
cout << textBuffer << endl;
cout << "[end text]" << endl;
}
else
{
cerr << "No text." << endl;
}
}
else
{
cerr << "Static not found." << endl;
}
}
else
{
cerr << "mIRC_Channel not found." << endl;
}
}
else
{
cerr << "MDIClient not found." << endl;
}
}
else
{
cerr << "mIRC not open." << endl;
}
}
int main()
{
FindmIRC();
return 0;
}
강조 표시된 클래스는 텍스트가 무엇인가 그것. 어떤 도움도 좋습니다!
텍스트를 다시받지 못했거나 호출에 실패 했습니까? 'GetLastError'는 여기서 무엇을 반환합니까? – templatetypedef
그냥'GetLastError'를 구현했고'GetProcessId가 eror 6으로 실패했습니다 : 핸들이 유효하지 않습니다. ' – justauser