This code finds a notepad window, and places the text in the edit control. But why does it work? Wouldn't the pointer to the string "hi" be invalid in the notepad process?
Code:#include <windows.h> int main() { HWND hNote; HWND hChild; if (!(hNote=FindWindow("Notepad",NULL))) exit(1); if (!(hChild=FindWindowEx(hNote,NULL,"EDIT",NULL))) exit(2); SendMessage(hChild,WM_SETTEXT,NULL,(LPARAM)"hi"); return 0; }