write on notepad with C programming

#include <winsock2.h>
#include <iostream>
#include <windows.h>
using namespace std;

BOOL WriteToNotepad(LPCTSTR lpszText)
    {
    HWND hwndNotepad; // A handle to the Notepad window
    HWND hwndEdit;// A handle to Notepad's work area
    // Where's Notepad?
    hwndNotepad = FindWindow("Notepad", NULL);
    // Did we find it?
    if(!hwndNotepad)


        {
        // Guess not
        // Try to run it from the Windows directory
        WinExec("Notepad", SW_SHOWNORMAL);
        // Wait a few milliseconds (If your computer is slow it may take a while)
        Sleep(100);
        // Find it again
        hwndNotepad = FindWindow("Notepad", NULL);
        // Did we find it this time?
        if(!hwndNotepad)


            {
            // Nope.
            // Return FALSE indicating failure :(
            return FALSE;
            }
            }
            // Good, we found Notepad.
            // Now lets find it's the edit control
            // that makes up it work area
            // We'll use FindWindowEx this time because it is used to find
            // child windows
           
            hwndEdit = FindWindowEx(hwndNotepad, NULL, "Edit", NULL);
            // Success?
            if(!hwndEdit)


                {
                // Oops. Busted.
                // Nothing we can do here. Return FALSE indicating failure (:
               
                return FALSE;
                }
                // Good, we found the edit control
                // Now we're going to loop through the characters in the lpszText (defined by user)
                // and display them individually
                int i;
                for( i = 0; i < lstrlen(lpszText); i ++)


                    {
                    LRESULT lRet; // We use this to recieve the return value of SendMessage (just in case it fails)
                    // Write the characters one by one by sending a WM_CHAR message to
                    // the edit control
                    lRet = SendMessage(hwndEdit, WM_CHAR, lpszText[i], NULL);
                   
                    // Any problems?
                    if(!lRet)


                        {
                        // Nothing we can really do. There's no point in breaking
                        // the loop, so ignore it.
                        }
                        }
                        // Good! Everything worked out.
                        // Return TRUE indicating success :)
                        return TRUE;
                    }


int main(){
char Notepad[MAX_PATH]="notepad.exe";
  HWND hwnd;
 
   //ShellExecute(hwnd,"open",Notepad,NULL,NULL,SW_MAXIMIZE);
   WriteToNotepad("Hello From Trojan!!!!");
 
}