Exe do not work

hello all i hae written following program to copy entire folder

in c++ , it works on my pc where i develope it . but when i copy

exe to my friends computer it fails gives error configuration

incorrect . can anyone help ? thanks in advance .

sending program also ->

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

string root;

void getallfiles(string s ,string dest)
{
HANDLE hFind;
WIN32_FIND_DATA finddata;

hFind = FindFirstFileA( s.c_str() , &finddata);

if (hFind == INVALID_HANDLE_VALUE)
return ;

string rep = "*";

do
{
string::size_type idx = s.find(rep);

rep = finddata.cFileName;

string temp(s,idx,s.length());

s.replace(idx,temp.length(),finddata.cFileName);

//cout<<s<<"\n";

idx = s.length() - root.length();

string temp2 = s;

temp2.replace(0 , root.length() ,dest);

//cout<<temp2<<"\n";

idx = temp2.find('.');
if(idx == string::npos)
{
//cout<< "creating "<<temp2<<"\n";
CreateDirectory(temp2.c_str(),NULL);
}

if(CopyFile(s.c_str(),temp2.c_str(),true))
{
;
}
else
{
//cout<<"error "<<GetLastError()<<"\n";
}

s = s + "\\*";

if( (rep != ".") && (rep != ".."))
{
getallfiles( s.c_str() , dest );
}

}while(FindNextFile (hFind, &finddata));
}

void main()
{
string sou;
string dest;

cout<<"enter source \n";
getline(cin,sou);
root = sou + "\\";
sou = sou + "\\*";

cout<<"enter destination \n";
getline(cin,dest);

CreateDirectoryEx("f:\\my",dest.c_str(),NULL);

dest = dest + "\\";

HWND h = FindWindow("ConsoleWindowClass",NULL);

system("cls");

ShowWindow(h,SW_HIDE);

getallfiles(sou , dest);

ShowWindow(h,SW_RESTORE);

system("pause");


}



Last edited on
What compiler are you using?
sorry i furgate to tell compiler name

i am using microsoft visual studio 2005 .

Last edited on
Google "visual c++ 2005 runtime redist". One of the top results will be a download page from Microsoft. The people you give your program to need to install that in order to run your program.
vivmen, if you are developing console apps or WinAPI apps, then you could use another compiler, for example Dev-C++ which is free: http://www.bloodshed.net/devcpp.html
Apps developed in Dev-C++ runs on other pcs with windows.
Another thing. WHERE in the world are you living and WHERE is your friend?

I had the same problem, and when I fixed it like that, it still didn't work on an american PC. I live in Norway.
Topic archived. No new replies allowed.