CopyFile........

O.K.........here's tha deal:



I'm making a program. Tha first thing it needs to do is copy itself. Now, tha

program's name might not be tha what I originally intended it to be, hence, I

can't use a constant null-terminated file name. Is there some what that as soon

as my program runs it: finds it's full file name/path, puts it in a buffer, and uses

tha buffer to make a copy of itself???



Thanx a bunch,

*unknown*


Comments

  • Hello!



    If you have a main() function, then its argv[ 0 ]. And if you have WinMain (or MFC, Builder etc) then check the GetModuleFileName API.



    : O.K.........here's tha deal:

    :

    : I'm making a program. Tha first thing it needs to do is copy itself. Now, tha

    : program's name might not be tha what I originally intended it to be, hence, I

    : can't use a constant null-terminated file name. Is there some what that as soon

    : as my program runs it: finds it's full file name/path, puts it in a buffer, and uses

    : tha buffer to make a copy of itself???

    :

    : Thanx a bunch,

    : *unknown*

    :






  • In tha GetModuleFileName, tha first parameter says:



    "(it) identifies the module whose executable filename is being requested. If this

    parameter is NULL, GetModuleFileName returns the path for the file used to

    create the calling process."



    ...........so, if I use a NULL value in this parameter, it will return tha path of tha

    file that was just executed (and called tha process).



    Thanx much bro!

    *unknown*


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories