jw said:
i want to make a set up program to my c++ programs.what can i do?
Decide what operations the 'setup' procedure needs to do
(e.g. create 'folders', copy files, etc.), and write a program
to implement them. Some things might be done with standard
code, others might require platform specific code (which would
not be topical here). But note that in many cases, operating
system functions are accessible to your program via the standard
function 'system()', declared by <cstdlib>.
Simple example:
// Setup program for Microsoft Windows(tm): creates
// a folder "MYAPP" on drive C: and copies to there
// all files on drive A:
#include <cstdlib>
#include <iostream>
#include <string>
int main()
{
// strings used to build OS commands
const std::string source("A:\\");
const std::string dest("C:\\MYAPP");
const std::string cmd("copy ");
// instruct user
std::cout << "Place installation disk in drive "
<< source << '\n'
<< "Press ENTER when ready...";
std::string input;
std::getline(std::cin, input);
std::cout << "Installing...";
// send commands to OS via system() function
std::system(("mkdir " + dest).c_str());
std::system((cmd + dest + ' ' + source + "*.*").c_str());
std::cout << "Done\n"
<< "To start program, type "
<< dest << '\n';
return 0;
}
-Mike