delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2008/06/22/14:01:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Manuel Collado <m DOT collado AT lml DOT ls DOT fi DOT upm DOT es>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [OT] Accepting files (question)
Date: Sun, 22 Jun 2008 19:43:46 +0200
Organization: RedIRIS
Lines: 79
Message-ID: <g3m33o$i5s$1@heraldo.rediris.es>
References: <po-dnT-Z46oEqsPVRVnyjAA AT bt DOT com>
NNTP-Posting-Host: sri201.sri.fi.upm.es
Mime-Version: 1.0
X-Trace: heraldo.rediris.es 1214156728 18620 138.100.242.201 (22 Jun 2008 17:45:28 GMT)
X-Complaints-To: jesus DOT heras AT rediris DOT es
NNTP-Posting-Date: Sun, 22 Jun 2008 17:45:28 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
In-Reply-To: <po-dnT-Z46oEqsPVRVnyjAA@bt.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

MikeC escribió:
> Good Folk,
> 
> I have written a parser program that operates on one or more files to 
> produce an output file.  It takes an input file, parses it (with the help of 
> other files if they are given) and produces an output file.
> The way I operate the program under Windows XP is to make a shortcut icon to 
> my program on the task bar, then I select the input file(s) with Wndows 
> Explorer, drag it (or them symoltaneously) onto the shortcut icon, and drop 
> them.  The filenames are passed exactly as if I had typed them all on the 
> command line...
> 
> myparser d:\path_1\file_1  d:\path_2\file_2
> 
> ... and the filenames are placed in argv[n].   No problems there - it works 
> fine.
> 
> I have used the same technique on several other programs too.  It's a nice 
> way of operating a DOS program from Windows.
> 
> I want to write a simple file encryption program that uses a one-time pad. 
> This technique is very secure, as long as nobody gets hold of the key - and 
> therein lies the snag.  I want to use another file on the PC as a key, but I 
> don't want to say "Input key ... Browse", as that makes it obvious that it 
> is on the PC somewhere.  What I want to do is drop the document to be 
> encrypted on the program's shortcut icon to fire it up, then have it wait 
> till a second file (the key) is dropped on it, and have it detect and use 
> that second file.  I have played around with it a bit, but dropping a second 
> file on the icon just starts a second image of my program, and while 
> dropping the file into the DOS screen gives the right Windows indications (a 
> '+' copy icon), I can't detect the file name.  Can anybody shed some light 
> on this please?

The following solution is probably off-topic here (not related to 
DJGPP). A shell script (dropargs.bat) can solve the problem. Create a 
shortcut for it and drop the file arguments on it one after the other.

The first time it creates a temporary driver script to later call your 
program with the dropped file as the first argument. The second time it 
actually calls your program with both arguments.

Edit the script to call your specific program instead of the generic 
"myprog". The directory where the script resides must be writeable. 
Executing the script without arguments clears the temporary driver (in 
case you change your mind after the first drop).

--- dropargs.bat------------------------------
@echo off

rem --- no args, clear temporary driver
if .%1.==.. (
   if exist %~dp0dropargs~.bat del %~dp0dropargs~.bat
   exit /B
)

rem --- first arg, create a temporary driver
if not exist %~dp0dropargs~.bat (
   echo myprog %1 %%1 > %~dp0dropargs~.bat
   exit /B
)

rem -- second arg, execute via the temporary driver
call %~dp0dropargs~.bat %1
del %~dp0dropargs~.bat
----------------------------------------------

> 
> I have recently downloaded Notepad++, and I can't sing its praises highly 
> enough.  It's a terrific piece of work - and the comparison plugin has saved 
> me a lot of time already and made me look impressive in the eyes of my 
> colleagues - but what I wanted to say is that it operates in the way I said. 
> Drop a text file on it, and it starts up and displays the text.  Drop a 
> second one on it while it is running, and it opens a new tab and displays 
> the second file.  Admittedly, it is compiled by a compiler that is made for 
> Windows, not one that is made for DOS, but I'm sure DJGPP has a way, if 
> somebody can tell me.

-- 
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019