i have a lot of games. so it is very difficult to search the exe files . so is it possible to write a program to execute a file
rgds
saimadhav
Printable View
i have a lot of games. so it is very difficult to search the exe files . so is it possible to write a program to execute a file
rgds
saimadhav
Yes, it most likely can be done. However, what do you ACTUALLY want to do? Search for a .exe file by name and then execute it, or something else?
--
Mats
no..
imagine i already know where the exe`s are located . i would like to make a program that will execute these exe`s on my inputs
i want the code in c++ that would execute a file
for ex;
what should the code be afterCode:main()
{
char game;
cout<<"Enter game";
cin>>game;
if (game==GTA)
{
}
Code:if (game==gta)
Seems like what you want is a table of which game is where. You can do it like you describ, but game should probably be a std::string, and you would want quotes around "GTA".
Then you call "ShellExecute()" [or system()] with the path to the game.
--
Mats
could you give an example?
This is a perfect job for a scripting language.
Isn't that what the start menu is for?
Yes, but I'm thinking of the actual hierarchical menu, not starting a Run dialog or a command prompt.
In my Windows installation, I've completely reorganized my Programs submenu. Now there's "Games", "Programming", "Background", "Drivers & Co" and "Other".
Of course, systems where there's no company ego dictating things, such a sane categorization is done by default (hint: Linux desktops). It's only on Windows that anyone thinks that finding a program in CompanyName -> ProductName -> ProductName is normal.
ya i know why there is a start menu! i am asking how do u execute a file by programming in c++?
You use, as I explained earlier, ShellExecute() or system(). The former is a Windows API call, which isn't exactly simple, the second just takes a string of something the computer will hopefully be able to execute - if it's wrong, there will be a return code to explain what went wrong.
--
Mats
If your executing ONLY programs, then use CreateProcess(), and you don't need an example, instructions on using the function are here.