Thread: Command Line Question

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Command Line Question

    Hi all. I have a problem. I have written a compression program which ordinarily processes files dropped into the command line. When I am processing an uncompressed file, I simply slap an extension onto the end of the filename to name the new file. (This way, I don't have to store the old filename in the compressed data and then extract it.)
    Now after the compressed file is made you can either drop in into the command line to decompress it, or, as I would like to do, you can simply click on a compressed file, and since the specific extension is associated with the program, it has the same effect as dropping it to the command line.
    The problem is, when you click on it, the program is unable to open the file to process it since the file is already open! But I see other programs process files in this way...how could it be done?

    My second question is how to access the command line AFTER the program is already open. You know how when you have MS Paint open, you can drop files into it at any time and have them open?

    If anyone has any idea how these may work in theory, please let me know!!

    Thanx in advance - Sebastian.

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    It looks like you are aksing for too much from a dos program...

  3. #3
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    If you are programming in Windows, then this is not the right forum.
    The problem is, when you click on it, the program is unable to open the file to process it since the file is already open! But I see other programs process files in this way... how could it be done?
    They use windows style handlers to do this.. But don't do it yourself. It's system-specific. But note that you are able to drag'n'drop the files onto your programs icon.
    My second question is how to access the command line AFTER the program is already open. You know how when you have MS Paint open, you can drop files into it at any time and have them open?
    It is MSPaint. Why your program should do that? I think everyone is able to do things like: program <inputfile. On the other hand, it is quite hard to do in a command line program.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Well, no offense, but you are both off target! Believe me, the solution is probably not as difficult as writing a compression algorithm! Anyone?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    >>...the program is unable to open the file to process it since the file is already open!...

    i dont think i really understood what you said.. but here is my 2cents - close the file after compressing and then rename it. now try to open it.

    >>My second question is...

    maybe if you can call the program again using spawn() !!??
    -

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    for your first question, you have to set the file association manually (assuming you havent already done that) and make sure you have it set properly. One way to make sure is to look at another program and see what you may be missing (ie "c:\...\program_name\" "%1"). Also, there is probably an API function that will set the association automatically. You might want to look through MSDN to find a function that will do it.

    for your second question, this will be handled by another API call in response to a drag-and-drop event. Again, MSDN will probably have the answers you seek. Raimo was right, you might get more a more specific response in the Windows forum

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM