I'm making a program that compresses text files using the LZW compression algorithm and creates a seperate compressed file. I made a file type and extension and icon for this file type (.nct), and set up 2 actions for it - one that calls the program and passes the .nct file path name, uncompresses the file and displays the text in the executable window (default), and one that recreates the original .txt file (simply passes a "/c" before the .nct file path name, only accessed by right clicking the .nct). I haven't even started with the program, I'm just experimenting with the file type and argument stuff. When I drag the .nct (not a real file, just a short text file with the extension changed to nct) onto a shortcut to the program (for now it just tells me the number of arguments passed to the program (the first main() argument) and the arguments themselves (the second argument to main(), an array of pointers to char arrays)), it gives me 2 arguments - the executable path and the nct path, as I would expect. (It shows '-' at the beginning and end of the strings, so I could verify there were no spaces at the end.)
Output:
nNumberofArgs = 2
The arguments are:
0-C:\Program Files\Text Compress\TextCompress.exe-
1-C:\Documents and Settings\Nick\Desktop\hioo.nct-
That's it
Press any key to continue . . .
But when I double click the nct or right click and select open (same thing, as I made my open action default) I get 4 arguments. The first one works (it has 2 spaces in it), but it gets rid of the 2 spaces in the nct path and counts it as 3 seperate arguments.
Output:
nNumberofArgs = 4
The arguments are:
0-C:\Program Files\Text Compress\TextCompress.exe-
1-C:\Documents-
2-and-
3-Settings\Nick\Desktop\hioo.nct-
That's it
Press any key to continue . . .
Why? How do I fix it so that I get one argument passed as the nct path when I use the open action, instead of just when I drag it onto the executable (or call in a DOS prompt)?
When I use the create text file action, I get the /c, but I still get seperate arguments from spaces in the nct path.
Output:
nNumberofArgs = 5
The arguments are:
0-C:\Program Files\Text Compress\TextCompress.exe-
1-/c-
2-C:\Documents-
3-and-
4-Settings\Nick\Desktop\hioo.nct-
That's it
Press any key to continue . . .
Here's my appliction for Open:
"C:\Program Files\Text Compress\TextCompress.exe" %1
and here's for Convert To .txt:
"C:\Program Files\Text Compress\TextCompress.exe" /c %1