#include <iostream> #include <windows.h> #include <fstream> int main () { HWND hwnd; hwnd = ::FindWindow ("Notepad","無標題-記事本"); if (hwnd == NULL) { ::ShellExecute(hwnd,"open","a.txt",NULL,NULL,SW_SHOWNORMAL); Sleep(1000); char str[12] = "1"; ::SendMessage (hwnd, WM_SETTEXT, 0,(LPARAM)str); //向EDIT寫入文字 } }