AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Oberfläche für Freeware Kommandozeilen-Programm Unix2Dos
Thema durchsuchen
Ansicht
Themen-Optionen

Oberfläche für Freeware Kommandozeilen-Programm Unix2Dos

Ein Thema von schöni · begonnen am 16. Mai 2005 · letzter Beitrag vom 17. Mai 2005
 
schöni

Registriert seit: 23. Jan 2005
Ort: Dresden
445 Beiträge
 
Delphi 7 Personal
 
#1

Oberfläche für Freeware Kommandozeilen-Programm Unix2Dos

  Alt 16. Mai 2005, 23:58
Hallo Delphianer!

Ich habe mal wieder ein Problem. Ich will eine .EXE Datei aufrufen, konkret die
Datei Unix2Dos.exe, um Pascal-Quelltexte aus der Unix Welt in das DOS/Windows
Format zu konvertieren.

Unix: Zeile schließt mit $0A ab
Dos/Windows: Zeile schließt mit $0D0A ab

Ich will nun eine Oberfläche bauen, die mir in einer Listbox die zu
konvertierenden Dateien anbietet. Dann wähle ich eine aus (später
auch mehrere), die dann der Reihe nach konvertiert werden sollen.

Mein Problem ist: Die Konvertierung klappt nicht. Warum?

Von der Kommandozeile aus klappt die Konvertierung einwandfrei. Nur nicht, wenn ich das Tool
von meiner Delphi-Anwendung aus aufrufe.

Hier die Unit mit der Startroutine, die Unix2Dos aufruft:
Delphi-Quellcode:
unit Execute;

interface

uses Windows, Messages, SysUtils, Classes;

type
  TCommandLine = type String;

function ProcessExecute(CommandLine: TCommandLine; cShow: word): Integer;
function ExecProcess(CommandLine,DirOfProc: TCommandLine; cShow: word): Integer;

implementation

uses ShellAPI;

function ProcessExecute(CommandLine: TCommandLine; cShow: word): Integer;
var
  Rslt: LongBool;
  StartUpInfo: TStartUpInfo;
  ProcessInfo: TProcessInformation;
  hProcess,hThread: THandle;
begin
   FillChar(StartUpInfo, SizeOf(TStartUpInfo), 0);

   with StartUpInfo do
   begin
      cb := SizeOf(TStartUpInfo);
      dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
      wShowWindow := cShow;
   end;

   Rslt := CreateProcess(
     PChar(CommandLine),
     nil,
     nil,
     nil,
     false,
     NORMAL_PRIORITY_CLASS,
     nil, //Environment
     nil, //aktuelles Verzeichnis
     StartUpInfo,
     ProcessInfo
   );

   if Rslt then
   begin
      WaitForInputIdle(hProcess, INFINITE);
      CloseHandle(hThread);
      CloseHandle(hProcess);
      Result := 0;
   end
   else Result := GetLastError;
end;

function ExecProcess(CommandLine,DirOfProc: TCommandLine; cShow: word): Integer;
var
  Rslt: LongBool;
  StartUpInfo: TStartUpInfo;
  ProcessInfo: TProcessInformation;
  hProcess,hThread: THandle;
begin
   FillChar(StartUpInfo, SizeOf(TStartUpInfo), 0);

   with StartUpInfo do
   begin
      cb := SizeOf(TStartUpInfo);
      dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
      wShowWindow := cShow;
   end;

   Rslt := CreateProcess(
     PChar(CommandLine),
     nil,
     nil,
     nil,
     false,
     NORMAL_PRIORITY_CLASS,
     nil, //Environment
     PChar(DirOfProc), //aktuelles Verzeichnis
     StartUpInfo,
     ProcessInfo
   );

   if Rslt then
   begin
      WaitForInputIdle(hProcess, INFINITE);
      CloseHandle(hThread);
      CloseHandle(hProcess);
      Result := 0;
   end
   else Result := GetLastError;
end;

end.
Und hier das Hauptprogramm:

Delphi-Quellcode:
unit ConvMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  FileCtrl, StdCtrls, Execute;

type
  TForm1 = class(TForm)
    btnUnixToDos: TButton;
    btnDosUnix: TButton;
    FileListBox1: TFileListBox;
    DirectoryListBox1: TDirectoryListBox;
    procedure btnUnixToDosClick(Sender: TObject);
    procedure btnDosUnixClick(Sender: TObject);
  private
    { Private-Deklarationen }
    NewInstance: THandle;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.btnUnixToDosClick(Sender: TObject);
var toConvert: String; CurrentDir, Action: String;
begin
   //Konvertierung des Zeilenendezeichens von UNIX nach DOS CRLF
   CurrentDir := GetCurrentDir;
   if CurrentDir[Length(CurrentDir)]<>'\then CurrentDir := CurrentDir + '\';
   Action := CurrentDir + 'Unix2Dos.exe ';
   SetLength(CurrentDir, Length(CurrentDir)-1);
   toConvert := FileListBox1.Items[FileListBox1.ItemIndex];
   //ShellExecInfo.lpParameters := FileListBox1.Items[FileListBox1.ItemIndex]
   ExecProcess(
     Action + toConvert,
     GetCurrentDir,
     SW_SHOWNORMAL
   );
end;

procedure TForm1.btnDosUnixClick(Sender: TObject);
begin
   //Konvertierung des Zeilenendezeichens von DOS nach UNIX LF
   ShowMessage('Diese Umwandlung konnte noch nicht implenentieirt werden! Leider');
end;

end.
Danke schon mal für Eure Hilfe

schöni
Damit der Topf nicht explodiert, lässt man es ab und zu mal zischen.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz