ShellExecute

Delphi

10/02/2010

Olá pessoal,
É o seguite estou tentando executar um jogo (Swat.exe) q estar na sua repectiva pasta onde foi instalado. Mas nen com Shellexeute e nem com WinExecute eu estou conseguindo executar este aquivo. Mas tenho quaze serteza o jogo só aceita ser executado clicando diretamente no executavél
atravez de um atalho no qual o mesmo tenha
Destino: ´C:\Program Files\SWAT 4\Content\System\Swat4.exe´
Iniciar Em: ´C:\Program Files\SWAT 4\Content\System´

alguem sabe como faço para executar este aquivo com este algumeto

Veja meu esquema:
[b:3130375873][color=darkred:3130375873]function TForm1.executar;
var
exec: string;
begin
exec :=GetEnvironmentVariable(´PROGRAMFILES´) +´\SWAT 4\Content\System\Swat4.exe´;
if FileExists(exec) then
ShellExecute(handle,´open´,PChar(exec), ´´,´´,SW_SHOWNORMAL);
end;[/b:3130375873][/color:3130375873]


Cgm2k10

Cgm2k10

Curtidas 0

Respostas

Lehapan

Lehapan

10/02/2010

Verifique se o atalho não passa algum parâmetro para executá-lo.

Espero ter colaborado.


GOSTEI 0
Cgm2k10

Cgm2k10

10/02/2010

Verifique se o atalho não passa algum parâmetro para executá-lo. Espero ter colaborado.


Valeu amigo mas já consegui com a ajuda do ´Paulo Gurgel´ de um outro forum.

[b:5a0d4de641]procedure TForm1.executar;
var
Destino: string;
Iniciar_Em : string;
begin
Destino :=GetEnvironmentVariable(´programfiles´)+´\SWAT 4\Content\System\Swat4.exe´;
Iniciar_Em :=ExtractFilePath(Destino);
if FileExists(Destino) then begin //Verifica se o arquivo existe
ShellExecute(handle,´open´,PChar(Destino), ´´,PChar(Iniciar_Em),SW_SHOWNORMAL) end
else
OpenDialog1.Execute; //Se não existir, o openDialog1 abre a uma janela para localizar manualmente
if FileExists(OpenDialog1.FileName) then begin
Edit1.Text :=OpenDialog1.FileName;
ShellExecute(handle,´open´,PChar(OpenDialog1.FileName), ´´,PChar(Iniciar_Em),SW_SHOWNORMAL) end
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
executar; // executa a procedure acima quando clicado no Button1
end;

{Na inicialização verifica se o arquivo(Destino:) e a pasta(Iniciar Em:) existe
se existir é exibida nos Edit4 e Edit5}

procedure TForm1.FormCreate(Sender: TObject);
var
Destino: string;
Iniciar_Em : string;
begin
Destino :=GetEnvironmentVariable(´programfiles´)+´\SWAT 4\Content\System\Swat4.exe´;
Iniciar_Em :=ExtractFilePath(Destino);
if FileExists(Destino) then begin
Edit4.Text :=Destino;
Edit5.Text :=Iniciar_Em end
else
begin
Edit4.Text :=´Arquivo não Existe´;
Edit5.Text :=´Diretorio não Existe´;
end;
end;[/b:5a0d4de641]


GOSTEI 0
POSTAR