On Jun 22 02:41 97, Eric Schreiber of 1:115/327 wrote:
ES> Back to the problem...
ES> I know that if I want to *FEED* a long file name with embedded spaces
ES> to another program I should enclose it in quotes - for example, at a
ES> DOS prompt I can type CD "Program Files" to change to that dir.
ES> What I'm trying to discover is how to accept a long file name on the
ES> command line of MY program:
ES> I've written a 16-bit text editor. When it's the associated program
ES> for a .TXT file, when I double click readme.txt in Explorer,
ES> readme.txt gets loaded into my editor, no sweat.
ES> However, when I port that editor into 32-bit and associate .TXT files
ES> to the new 32-bit version, when I double click "Read Me Now.txt" in
ES> explorer, I get error "File not found: Read". My program is parsing
ES> paramstr(1) ('Read') as unrelated to paramstr(2) ('Me') etc.
ES> It's since ocured to me to whip together a prog that will display to
ES> me the entire command line, so I can see exactly what Win95 is
ES> sending. Perhaps then I'll figure it out.
ES> I guess what I'm looking for is someone to hand me code on a silver
ES> platter. I hate the 'original thinking' part of programming :-)
Ok, I don't know if you got my first post but here is the code I use...
This will load any file associated with your program (extension wise) in the
Windows95 Explorer...
function strCmdLine : string;
var
i : integer;
begin
Result := '';
for i := 1 to ParamCount do
Result := Result + ParamStr(i) + ' ';
Delete(Result,Length(Result),1);
end;
//*if there is a file on the command line proccess it.
//*called in the OnShow event...!
procedure TFrameForm.FormShow(Sender: TObject);
begin
if (FrameForm.Active = false) and
(FrameForm.MDIChildCount = 0) then //*no open child windows.
OpenFileDialog.FileName := strCmdLine; //*check the commandline.
if (OpenFileDialog.FileName '') then//*make sure something is there.
with TEditForm.Create(Self) do begin
Open(OpenFileDialog.FileName);
Editor.Modified := false; //*keep tabs on the editor...
Editor.MaxLength := 50000000;
end;
end;
Chris
--- Msgedsq 2.2e
---------------
* Origin: Esc1.71 - When you're old enough to drive the bus. (1:157/534.30)
|