That code wont work, here is an example of how to send text to notepad:
Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
HWND hNotepad, hEdit;
memset(&si,0,sizeof(si));
/* Start up notepad */
CreateProcess(NULL,"notepad",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
Sleep(1000); /* Wait for notepad to open */
hNotepad = FindWindow(_T("Notepad"),NULL);
if(!hNotepad)
{
printf("Could not find notepad window\n");
return EXIT_FAILURE;
}
hEdit = FindWindowEx(hNotepad,NULL,_T("Edit"),NULL);
if(!hEdit)
{
printf("Could not find edit window\n");
return EXIT_FAILURE;
}
SendMessage(hEdit,WM_SETTEXT,0,(LPARAM)_T("This text will appear in notepad"));
/* Close handles */
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return EXIT_SUCCESS;
}