Board index » delphi » Delphi 1: Problem with ShellExecute running Windows NT

Delphi 1: Problem with ShellExecute running Windows NT

Hi,

I have a piece of code in Delphi 1 that runs fine with Windows 95, but
it gives trouble with Windows NT 4.0 (service pack 3).

        procedure ShellExec(Wnd: HWnd; const FileName: String);
        var
          Commando: String;
        begin
          Commando := FileName + #0;
          ShellExecute(Wnd, nil, @Commando[1], nil, nil, SW_SHOWNORMAL);
        end;

I think the problem in this case is the long file name. If Windows NT
executes MS Word, it starts the following command: "C:\Program
Files\Microsoft Office\Office\WINWORD.EXE".

This command contains long file names and Delphi 1 will not execute this
command.

Am I rights about this?
And if I am, does anybody know a solutions for this problem?

Thanks in advance.

Jeroen Peters

 

Re:Delphi 1: Problem with ShellExecute running Windows NT


On Thu, 07 May 1998 15:27:24 +0200, "J.B. Peters" <pet...@mch.nl>
wrote:

Hi Jeroen,

Try this,

Quote
>procedure ShellExec(Wnd: HWnd; const FileName: String);    

var   FName  : String;
        PathName  : String;
        OldDir    : String;
       DriveStr    : String;

begin
  FName := ExtractFileName(FileName)+#0;  { Filename only }
  PathName := ExtractFilePath(FileName);           { Drive and Path }
  GetDir(0,OldDir);                                  { SaveCur. Dir}

  ChDir(PathName);                      { Change to Exedir}    

   DriveStr  := PathName[1]+':.\'+#0;      

  ShellExecute(Handle,NIL,@FName[1],NIL,@DriveStr[1],SW_SHOW);
  ChDir(OldDir);

end;

it's run with Windows NT 4.0, with Windows 95 not tested.

bye
  joerg

Quote
>Hi,

>I have a piece of code in Delphi 1 that runs fine with Windows 95, but
>it gives trouble with Windows NT 4.0 (service pack 3).

>    procedure ShellExec(Wnd: HWnd; const FileName: String);
>    var
>      Commando: String;
>    begin
>      Commando := FileName + #0;
>      ShellExecute(Wnd, nil, @Commando[1], nil, nil, SW_SHOWNORMAL);
>    end;

>I think the problem in this case is the long file name. If Windows NT
>executes MS Word, it starts the following command: "C:\Program
>Files\Microsoft Office\Office\WINWORD.EXE".

>This command contains long file names and Delphi 1 will not execute this
>command.

>Am I rights about this?
>And if I am, does anybody know a solutions for this problem?

>Thanks in advance.

>Jeroen Peters

Other Threads