Link to home
Start Free TrialLog in
Avatar of Syouchi
Syouchi

asked on

how to close console window

Hi, All.

My main program calls another DOS application by 'CreateProcess'API.
After that, the console window opens and DOS app. starts.
But I cannnot close the console window when DOS app. is over.

Please teach me how to code.

Syouchi.

Avatar of Syouchi
Syouchi

ASKER

Edited text of question
so us your code. Zif.
Avatar of Syouchi

ASKER

This is a part of my app.
'irp.exe' is encrypt DOS program I made.

-----------------------------------------------

function TFrCrypt.Angouka():string;
var
   CodeFile,MyPath,ComLine,
   OpenkeyPath,tmpS:string;
   SI:TStartupinfo;
   PI:TProcessInformation;
begin
   MyPath := ExtractFilePath(ParamStr(0));
   Opendialog1.InitialDir:=mypath;
   if OpenDialog1.Execute then
   begin
       CodeFile := OpenDialog1.FileName;
       Angouka:=ChangeFileExt(CodeFile,'.irp');

       IniFile:=TIniFile.Create(ChangeFileExt(ParamStr(0),'.ini'));

       OpenkeyPath:=iniFile.readString('Crypt','NkeyDir','');
       OpenkeyPath:=OpenkeyPath+'Syochi.opn';

if AnsiupperCase(ExtractFilePath(CodeFile))=AnsiupperCase(mypath) then
       CodeFile:=ExtractFilename(CodeFile);
       ComLine := 'irp.exe /c '+ OpenkeyPath +' ' + CodeFile;
       GetStartupInfo(SI);
       tmpS := MyPath + ComLine;
    CreateProcess(nil,PChar(tmpS),nil,nil,false,0,nil,nil,SI,PI);

   end;
end;
---------------------------------------------------------------


ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Syouchi

ASKER

Dear ZifNab.

Your both ways lead me to success.
Thanks a lot.

Syouchi.