Thread: path of app

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    91

    path of app

    any quick way of getting the path to the app, i know there is getmodulefilename but anything else?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    What makes you think the way you have is particularly slow?
    Is it too difficult to type in or something?
    Just how many times are you planning on calling it anyway?

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    got it sussed,

    Code:
    char Directory[MAX_PATH] = "";
      GetModuleFileName(NULL, Directory, MAX_PATH);

    ultra newb question here:-

    how do you join 2 chars together like,

    "C:\" and "myapp.exe" to obviously give,


    "C:\myapp.exe"

    ?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    strcat

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    Quote Originally Posted by Salem
    strcat
    thanks.

    it looks like i need to copy both chars into a buffer to join them like this,

    Code:
      char * stuff  = "abc";
     char * morestuff = "efg";
     char str[80];
     strcpy (str,stuff);
     strcat  (str,morestuff);
     MessageBox(NULL,str ,"",0);
    why can't i just say,

    Code:
      char * stuff  = "asd";
     char * morestuff = "dfg";
     
     MessageBox(NULL,strcat(stuff,morestuff) ,"",0);

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Because strcat() needs to store the result somewhere, and that somewhere is the memory pointed to by the first parameter.
    Since "strings like this" are constant, any attempt to modify them usually fails, either because the OS makes them read-only, or because there isn't any room to append more data.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. clipping path
    By stanlvw in forum Windows Programming
    Replies: 0
    Last Post: 07-23-2008, 11:47 PM
  2. suggestions for my file backup app (for linux)
    By Lateralus in forum C Programming
    Replies: 4
    Last Post: 08-02-2005, 08:58 AM
  3. best program to start
    By gooddevil in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-28-2004, 05:56 PM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. pasword app
    By GanglyLamb in forum C Programming
    Replies: 2
    Last Post: 06-07-2003, 10:28 AM