Thanks again....

This is a discussion on Thanks again.... within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Eman @CommonTater, I don't know why but I can't compile your code..it says unresolved reference to PathUnquotesA.. ...

  1. #46
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Eman View Post
    @CommonTater, I don't know why but I can't compile your code..it says unresolved reference to PathUnquotesA..
    And what your program does sounds really cool
    Ok... in the linker's list of libraries add shlwapi.lib ... I'm currently using code:blocks with MSVC++ so there's a dialog for that. Perhaps one of the others can explain how to do it on the command line for GCC...

    EDIT: Forgot to mention, that's a windows header so you may have to download the Windows SDK to get it... sorry.

    when every function is called, it saves its parameters to the stack.
    So the main(int argc, char **argv) saves the number of parameters and the address of the first element (of pointers) to the stack. So I should be able to do a loop and cout (I say cout because I don't know how else it could be used) the names of the parameters.
    I don't see the point of accessing the arguments in main, and i think it is because I don't know the use of it.

    But CommonTater just showed how useful it is.
    Ok... look at my source code... follow those parameters step by step...
    Code:
        if (!strcmp(argc[1],"-R") || (!strcmp(argc[1],"-r")))
          { Shuffle = true;
            if (argc[2])
              Target = argc[2];
            if (argc[3])
              Folder = argc[3]; }
        else
         {  if(argc[1])
              Target = argc[1];
            if (argc[2])
              Folder = argc[2]; }
    Notice how I'm copying them into other variables? Which ones I put where depends how many there are... Target is the output filename, Folder is the directory to be examined, Shuffle is the switch to tell it whether to list files in sorted or randomized order...

    Then..
    Code:
    DirList(Folder);   // reads the directory into a string vector
    
    DirList.SaveList(Target); // writes the list to a file
    The values of Folder and Target used in those functions came from the command line.

    The way you use CLI parameters will vary from program to program. What you need to know is that within Main these are valid string variables that you can use within your code.
    Last edited by CommonTater; 01-20-2011 at 11:36 AM.

  2. #47
    Registered User
    Join Date
    May 2010
    Posts
    2,711
    Also... All Windows Programs have to accept parameters on their command lines. This is done so that when you click on a file the Windows "file associations" data base can find the correct program to run for that file, add the filename to the command line and run the program for you... Any windows program that does not accept filenames on it's command line cannot be associated with any file type.
    Actually the Windows "file associations" are keyed to the program's extension, not the filename.

    Jim

  3. #48
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    I will try that CTater. Thanks
    You ended that sentence with a preposition...Bastard!

  4. #49
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by jimblumberg View Post
    Actually the Windows "file associations" are keyed to the program's extension, not the filename.

    Jim
    Actually, file associations are keyed to the filename's extension portion... not the program's extension at all. Program extensions are almost always .exe or .com, so that would be rather pointless.

    A file named myfavoritesong.mp3 would use the .mp3 portion of the name, the part after the dot (commonly called it's "extension" or "type") to trigger loading of the appropriate program.

    This is how, on a correctly configured Windows system, an operator can run the entire show simply by clicking on files.

  5. #50
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Eman View Post
    I will try that CTater. Thanks
    One of the best parts of programming is experimentation...
    Always push your boundaries. It's good for you.

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21