Entwickler-Ecke

Sonstiges (Delphi) - ShellExecute Fehler


DelphiNoobCoder - Fr 26.01.07 19:06
Titel: ShellExecute Fehler
Hi ich wollte fragen was ist hier der Fehler?


Delphi-Quelltext
1:
ShellExecute(Form1.Handle, 'open'''+edit1.text+'unzip.exe''-oq SolidusRepack.zip'nil, SW_SHOWNORMAL);                    


Als Fehler werden diese angezeigt


Quelltext
1:
2:
3:
4:
5:
Build
  [Hint] Unit1.pas(46): Value assigned to 'GetInetFile' never used
  [Hint] Unit1.pas(75): Variable 'var1' is declared but never used in 'TForm1.FormCreate'
 >[Error] Unit1.pas(106): Incompatible types: 'String' and 'PAnsiChar'
  [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'


Saubäär - Fr 26.01.07 19:11

Edit1.Text ist kein PAnsiChar sondern ein String, muss also zu PAnsiChar konvertiert werden.

Delphi-Quelltext
1:
ShellExecute(Handle, 'open', PChar(Edit1.Text + 'unzip.exe'), '-oq SolidusRepack.zip'nil, SW_NORMAL);                    


Gruß

Saubäär


DelphiNoobCoder - Fr 26.01.07 19:21

Mhh geht irgenndwie immernoch nicht den in edit1 steht C:\ dort is diese unzip.exe. Bloß die .zip Datei wird nicht entpackt. Da alles aus einer .ini Datei gelesen wird. Klartext in der ini steht der Pfad dieser wird in edit1 geladen.


MKX - Fr 26.01.07 19:26

Versuch's mal damit:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
function ExecFile(filename,params:String;windowState:word):Boolean; 
var 
  cmdLine: String
  SUInfo: TStartupInfo; 
  ProcInfo: TProcessInformation; 

begin
  CmdLine := '"' + Filename + '" ' + Params;

  FillChar(SUInfo, SizeOf(SUInfo), #0); 
  with SUInfo do begin 
    cb := SizeOf(SUInfo); 
    dwFlags := STARTF_USESHOWWINDOW; 
    wShowWindow := WindowState; 
  end

  try 
    result := CreateProcess(NIL, PChar(CmdLine), NILNIL, FALSE, 
                            CREATE_NEW_CONSOLE or 
                            NORMAL_PRIORITY_CLASS, NIL
                            PChar(ExtractFilePath(Filename)), 
                            SUInfo, ProcInfo); 
  except 
     on E: Exception do 
      begin 
        Result:=false; 
      end
  end
end;


Delphi-Quelltext
1:
ExecFile(PAnsiChar(Edit1.Text + 'unzip.exe'), '-oq SolidusRepack.zip',SW_SHOW);                    

Das sollte funktionieren, wenn der Fehler etwas mit ShellExecute zutun hat.


DelphiNoobCoder - Fr 26.01.07 19:28

Boar geil es geht THX