drag and drop onto exe

M

Mark

hi...

i have a program that opens a couple files and performs some operations
on them.
i wanted to modify my program so that if you drag and drop a file onto
the exe via windows, it will open this file and use it instead.

however, without even modifying my code first, if i drag and drop a
file onto the exe it no longer opens/writes to the files specified by
the program. but when no file is dragged onto it, it runs fine as
normal.

now i assumed that when you drag a file onto the exe it just passes in
an extra parameter.. i dont understand why this should modify the way
the program is run.

any explanation?
 
L

Luke Meyers

Mark said:
i have a program that opens a couple files and performs some operations
on them.
i wanted to modify my program so that if you drag and drop a file onto
the exe via windows, it will open this file and use it instead.

however, without even modifying my code first, if i drag and drop a
file onto the exe it no longer opens/writes to the files specified by
the program. but when no file is dragged onto it, it runs fine as
normal.

now i assumed that when you drag a file onto the exe it just passes in
an extra parameter.. i dont understand why this should modify the way
the program is run.

any explanation?

Your question is off-topic here. This is a newsgroup for discussion of
the C++ language. That does not encompass the particularities of
individual OSes and APIs. If you have questions about your OS or an
API you are using, please consult a forum related thereto.

Luke
 
S

Shark

Mark said:
hi...

i have a program that opens a couple files and performs some operations
on them.
Nice!

i wanted to modify my program so that if you drag and drop a file onto
the exe via windows, it will open this file and use it instead.

Very good!
however, without even modifying my code first, if i drag and drop a
file onto the exe it no longer opens/writes to the files specified by
the program. but when no file is dragged onto it, it runs fine as
normal.

Uh oh!
now i assumed that when you drag a file onto the exe it just passes in
an extra parameter.. i dont understand why this should modify the way
the program is run.
BLAH


any explanation?

magic.

1. What is your platform? Windows 3.1/95/NT/97/98/2k/xp? OS/2? Windows
emulator on SGI/Linux/FreeBSD/UNIX/.............?

2. How did you make your program? Dev C++/MsVC/CW/Borland/..........?

Just post on a newsgroup that deals with your platform and your
compiler.
 
M

Mark

dev-c++
windows xp

the following code WILL open the file dragged and dropped onto the exe

if( argc < 2 )
{
cout << "usage: scenario.chk\n";
return EXIT_FAILURE;
}

ifstream chk_in.open(argv[1], ios::binary);

however the other files specified globally don't want to open.

i'm guessing that when i run my program as normal, the constructors for
my files get run first.. but when i run it by drag and drop..perhaps it
skips them?
 
S

Shark

Mark said:
dev-c++
windows xp

the following code WILL open the file dragged and dropped onto the exe

if( argc < 2 )
{
cout << "usage: scenario.chk\n";
return EXIT_FAILURE;
}

ifstream chk_in.open(argv[1], ios::binary);

however the other files specified globally don't want to open.

i'm guessing that when i run my program as normal, the constructors for
my files get run first.. but when i run it by drag and drop..perhaps it
skips them?

Firstly: constructors are not moody }:)

Secondly: if your code works normally, i.e. works from command line but
not with drag and drop you should ask in the newsgroup that deals with
windows programming. Or even on IRC #winprog
 
M

Mark

alright alright, i'll ask elsewhere.
but i thought it was c++ related.
but just so you know, as long as i declare "ifstream" locally it works.
 
L

Luke Meyers

Mark said:
alright alright, i'll ask elsewhere.

Marvelous. Please feel welcome to return when you have an on-topic
question.
but i thought it was c++ related.

You should always read the FAQ for a newsgroup before posting it, to
avoid embarassing yourself and annoying others.

Luke
 
S

Shark

Mark said:
alright alright, i'll ask elsewhere.
but i thought it was c++ related.
but just so you know, as long as i declare "ifstream" locally it works.

If you have a question about your code, don't you think you should post
it completely? I mean with things that work, and don't work, things
that work in certain situations.

If you don't show all pieces of the puzzle it will be hard to guess
what the problem is in the first place. Just a thought.
 
M

Mark

err.. i know, but there was a lot of code, i thought it might be easier
to explain it.
anyways.. i'm not sure what was causing the problem, but i came up with
a solution.
probably better code too.. guess i shouldnt have been using globals in
the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top