Okay so I'm JUST starting c++, and was wondering, how can I open an external program (for example notepad.exe) in c++?
Open External Program C++
Page 1 of 110 Replies - 10843 Views - Last Post: 09 November 2009 - 12:28 AM
Replies To: Open External Program C++
#2
Re: Open External Program C++
Posted 07 November 2009 - 09:24 PM
Can you further describe open?
Do you mean open to edit the source code, or open as in launch?
Do you mean open to edit the source code, or open as in launch?
#3
Re: Open External Program C++
Posted 07 November 2009 - 09:34 PM
When I say open I mean to launch the program.e
#5
Re: Open External Program C++
Posted 07 November 2009 - 09:53 PM
Wait, what?
I'm confused.
I'm confused.
#6
Re: Open External Program C++
Posted 08 November 2009 - 04:12 AM
shockin!, on 7 Nov, 2009 - 08:53 PM, said:
Wait, what?
I'm confused.
I'm confused.
Yep, that's to be expected. Ask a little later in your understanding of C++; get the basics sorted out before you try more complicated things.
But I see no harm showing you the code. Build a console application using Visual Studio* and give it the following:
#include <stdlib.h>
int main()
{
system("notepad.exe");
return 0;
}
Build and run it, and Notepad will appear as directed.
*In VS2008: File -> New Project. In Project Types select Visual C++ -> Win32, and in Templates select Win32 Console Application. Give the project a name, check the location is fine, ensure "Create new solution" is selected, doesn't matter if Create Directory is selected or not (I prefer not) and click OK. In the App Wizard click Next, the defaults should be fine so click Finish and it'll drop you into a code editor. Replace
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
with the above, select Build->Build Solution to build it; there shouldn't be any errors if you've followed the above instructions *exactly*, then Ctrl-F5 to run it.
#7
Re: Open External Program C++
Posted 08 November 2009 - 04:19 AM
try this also
#include <windows.h>
int main(){
ShellExecute(GetDesktopWindow(), "open", "notepad", NULL, NULL, SW_SHOWNORMAL);
return 0;
}
#8
Re: Open External Program C++
Posted 08 November 2009 - 01:20 PM
The system code doesn't work for reason: system identifier not found.
#9
Re: Open External Program C++
Posted 08 November 2009 - 03:00 PM
What compiler are you using?
#10
Re: Open External Program C++
Posted 09 November 2009 - 12:04 AM
Visual Studio 2010 Beta2, that's all I know.
#11
Re: Open External Program C++
Posted 09 November 2009 - 12:28 AM
you must include header files for using system or shellexecute
and the program must run from a location where notepad.exe is available
and the program must run from a location where notepad.exe is available
Page 1 of 1

New Topic/Question
Reply



MultiQuote




|