0

I have a small Delphi XE5 program whose sole purpose is to execute another windows program. This program is initiated via a call from a windows terminal emulator. We are trying to execute a program on the server, using DLLs on the server as well. Therefore it is important to set the current directory to the directory on the server containing the DLLs. The terminal emulator does not allow the current directory to be set. Hence the need for this program.

The program operates correctly and solves our "current directory" problem, except that we get a console screen that briefly appears on the screen as the program is initiated. Since it is not a console application, I fail to see why this console type screen is appearing. Can anyone tell me how to get rid of this and have the program execute without displaying itself?

The following is the code:

    program DoProg;

uses
   SysUtils, ShellAPI, Windows;

const
   ExeAreaDir = '\\public\dd3\Release';
   ExeArea = ExeAreaDir + '\';

procedure RunProg(Path, Param: String);
var
   SEInfo: TShellExecuteInfo;
begin
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do
   begin
   fMask := SEE_MASK_NOCLOSEPROCESS;
   Wnd := 0;
   lpFile := Pchar(Path);
   lpParameters := Pchar(Param);
   lpDirectory := Pchar(ExtractFilePath(Path));
   nShow := SW_SHOWNORMAL;
   end;
ShellExecuteEx(@SEInfo);
end;

begin
SetCurrentDir(ExeAreaDir);
RunProg(ExeArea + ParamStr(1), ParamStr(2));

end.
SysJames
  • 411
  • 3
  • 10

1 Answers1

5

You may have "generate console application" checked in linker options.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169