When You Drag And Drop A File Into An Executable, How Does This Mechanism Work?

This is a discussion on When You Drag And Drop A File Into An Executable, How Does This Mechanism Work? within the C Programming forums, part of the General Programming Boards category; I have almost finished a "find and replace" program and I want the capability to be abe to drag the ...

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

    When You Drag And Drop A File Into An Executable, How Does This Mechanism Work?

    I have almost finished a "find and replace" program and I want the capability to be abe to drag the text file to be modified directly into the program. How could I signal to my program: "this file is trying to acess you, read it's contents and recognize it's file path"?
    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;
    }

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Here's a hint. It has to do with argc and argv

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    16
    Try declaring main like so:

    int main(int argc, char **argv)

    If argv[1] is not null, use argv[1] as the file naame to read.
    The box said 'Windows NT or better', so I installed Linux.

  4. #4
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    It works I would guess because of the command shell.

    argv[0] is the executable filename: program.exe
    argv[1] is the name of the text file.
    Try using argv[1] to open the file 'if condition' it exists.
    Infact you should perform several tests to make sure that the file is a valid textfile.

    Play around with it and run some tests.
    Last edited by Witch_King; 10-06-2001 at 01:31 AM.
    I compile code with:
    Visual Studio.NET beta2

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

    It was right under my nose!

    Thanks Guys!
    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;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open file by drag and drop
    By Abda92 in forum C Programming
    Replies: 3
    Last Post: 11-03-2007, 01:27 PM
  2. Drag n' Drop 'any file'
    By Oldman47 in forum C++ Programming
    Replies: 14
    Last Post: 12-19-2006, 04:33 PM
  3. DataGrid drag and drop
    By gtriarhos in forum C# Programming
    Replies: 0
    Last Post: 10-11-2005, 12:36 PM
  4. Drag and Drop using CImageList, Device contexts and BitBlt
    By MJWhiteman2 in forum Windows Programming
    Replies: 0
    Last Post: 03-03-2005, 06:22 AM
  5. drag and drop
    By depsypher in forum Windows Programming
    Replies: 2
    Last Post: 01-05-2002, 09:02 PM

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