Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

ghost's Avatar
0 0

I'm trying to make a c++ app that when downloaded and clicked on will copy another program(thats binded to the app thats clicked on)to another location,but the problem is I don't know where they're going to download this file to.some people might download it to c:/downloads and some to c:\documents, so how can i make this binded file copy its self to another directory if I don't know where it's at in the 1st place? so a system("copy file.exe C:\win"); is useless. Any help is appreciated.


ghost's Avatar
0 0

if it's windows, u can use an absolute location

such as %systemroot%/../ gives you the same thing as c:\

just use an absolute address… unless it has to be relative? I don't know much (anything, really) about C, so I don't know if you even can use absolute, but I would think that you can. Try that, or at least give us more info first.

Good luck… I think I'll learn java next month :p


ghost's Avatar
0 0

well you could do it in C++ without that command and i know one way to find they exzact place of the .exe you could declare argv in your int main() or w.e function and then cout<<argv; will tell you the exzact path you can also use _getcwd(); for the same result #include <direct.h> to get the windows directory you could do GetWindowDirectory(); and can't think of any other functions

google em or ask me and ill help :p


ghost's Avatar
0 0

_getcwd() will return the current working directory, which is not necessarely the dir in which the exe file is.

I use GetCommandLine() ans strip away the file name ad parameters.

Another usefull directory fonction is SHGetSpecialFolderPathA(). If you want the paths to things like the current user desktop or MyDocs, check it out.