hellfire052497
asked on
paramstr() can't handle long filenames?
when using the paramstr() option for opening a file, it cannot handle long filenames. For example in explorer from windows and you doubleclick on a file then it starts the program but cannot load any file with a space.
and so refuses it to load in the edit field, I use richedit, and when I click a file it loads in the richedit field fine, but when the file contains a space it refuses to do so.
putting the file in brackets helps "this is a testfile.txt" from a commandline but this is not possible in explorer so what code does open and display long filenames correct?
The Code I use is as follows:
if ExtractFileName(ParamStr(1 )) <> '' then
begin
OpenCode(ParamStr(1));
and Opencode relates to the Procedure Opencode...
What needs to be changed here.
and so refuses it to load in the edit field, I use richedit, and when I click a file it loads in the richedit field fine, but when the file contains a space it refuses to do so.
putting the file in brackets helps "this is a testfile.txt" from a commandline but this is not possible in explorer so what code does open and display long filenames correct?
The Code I use is as follows:
if ExtractFileName(ParamStr(1
begin
OpenCode(ParamStr(1));
and Opencode relates to the Procedure Opencode...
What needs to be changed here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I updated my question, I included the code I use for opening.
Please give clear explanation of what needs to be changed in my codelines, I am pretty new to Delphi so explain a bit better.
Thanks
Please give clear explanation of what needs to be changed in my codelines, I am pretty new to Delphi so explain a bit better.
Thanks
Here is the WHOLE FormCreate event as it should be in your code. Just copy and paste it in.:
procedure TForm1.FormCreate(Sender: TObject);
var
parameters: string;
x: integer;
begin
{Extract Parameters from ParamString. Will include spaces.}
parameters := '';
for x := 1 to paramCount do
begin
parameters := parameters + paramStr(x);
if x < paramCount then parameters := parameters +' ';{dont add a space to the last parameter}
end;
{Process Parameters}
in Parameters <> '' then OpenCode(Parameters);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
parameters: string;
x: integer;
begin
{Extract Parameters from ParamString. Will include spaces.}
parameters := '';
for x := 1 to paramCount do
begin
parameters := parameters + paramStr(x);
if x < paramCount then parameters := parameters +' ';{dont add a space to the last parameter}
end;
{Process Parameters}
in Parameters <> '' then OpenCode(Parameters);
end;
ASKER