S
SQACSharp
How can I "convert" from a char to a string. I'm trying to display in
the console the Classname and the text in the notepad window.
Start notepad and type some text before running the following code.
#include <windows.h>
#include <iostream>
#include <winuser.h>
using namespace System;
int main()
{
HWND hNotepad, hEdit;
hNotepad = FindWindow(L"Notepad", NULL);
hEdit = FindWindowEx(hNotepad, NULL, L"edit", NULL);
SetForegroundWindow(hNotepad);
static char ClassName[51];
GetClassName(hNotepad,(LPTSTR) ClassName, 50 );
std::cout << "ClassName = " << ClassName; // *** NOT WORKING ***
int iLength = (int)::SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0);
TCHAR * textData = (TCHAR *) malloc((iLength + 1) * sizeof(TCHAR));
SendMessage(hEdit, WM_GETTEXT, iLength+1, (LPARAM)textData);
std::cout << "Text captured from notepad = " << textData; // *** NOT
WORKING ***
free((void *) textData);
}
Thanks.
the console the Classname and the text in the notepad window.
Start notepad and type some text before running the following code.
#include <windows.h>
#include <iostream>
#include <winuser.h>
using namespace System;
int main()
{
HWND hNotepad, hEdit;
hNotepad = FindWindow(L"Notepad", NULL);
hEdit = FindWindowEx(hNotepad, NULL, L"edit", NULL);
SetForegroundWindow(hNotepad);
static char ClassName[51];
GetClassName(hNotepad,(LPTSTR) ClassName, 50 );
std::cout << "ClassName = " << ClassName; // *** NOT WORKING ***
int iLength = (int)::SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0);
TCHAR * textData = (TCHAR *) malloc((iLength + 1) * sizeof(TCHAR));
SendMessage(hEdit, WM_GETTEXT, iLength+1, (LPARAM)textData);
std::cout << "Text captured from notepad = " << textData; // *** NOT
WORKING ***
free((void *) textData);
}
Thanks.