Writing onto a notepad

Is it possible to use c++ to open a notepad.exe and then have a message read out on the notepad?
There's no generic way for C++ to do that, but I'm sure there's a Windows specific way to do what you want. You should ask over on the Windows Programming forum... or search StackOverflow...
Sorry, but your post is a bit unclear:

Is it possible to use c++ to open a notepad.exe

Well, notepad.exe is a file, so it is possible to open the .exe file and read the object code and resources, but I guess you don't mean that...

and then have a message read out on the notepad?

So you want to launch notepad.exe and get it to display some text, yes? Either read from an existing file, or generated (or read in?) by your C++ program?

If you want to display some misc. text (that is, text obtained from the user or generated by you program, rather than read from an existing file), the easiest solution would be to write a (temporary) text file and then open it with notepad.exe.

The easiest way to launch notepad.exe would be with system()
http://www.cplusplus.com/reference/cstdlib/system/

But it would be more robust to use a WinAPI call; either CreateProcess or ShellExecute

CreateProcess function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx

ShellExecute function
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx

Or you could write a GUI app which opens the text file and then display the text in an Edit control (or similar). (Or even just display the text in the console?)

Andy
Last edited on
Topic archived. No new replies allowed.