J'utilise pour arriver à la sortie dos en utilisant delphi.
Quelles sont les causes du code de http://delphi.about.com/cs/adptips2001/a/bltip0201_2.htm ne fonctionnera pas avec Delphi2009 sur Vista? mais cela fonctionne sur D7 en XP. Je ne sais pas quelle partie à modifier pour le faire fonctionner.Comment obtenir la sortie dos. Dans delphi2009 avec vista
2
A
Répondre
7
DelphiDabbler has a solution, bien que je ne l'ai pas testé personnellement:
function GetDosOutput(CommandLine: string; Work: string = 'C:\'): string;
var
SA: TSecurityAttributes;
SI: TStartupInfo;
PI: TProcessInformation;
StdOutPipeRead, StdOutPipeWrite: THandle;
WasOK: Boolean;
Buffer: array[0..255] of AnsiChar;
BytesRead: Cardinal;
WorkDir: string;
Handle: Boolean;
begin
Result := '';
with SA do begin
nLength := SizeOf(SA);
bInheritHandle := True;
lpSecurityDescriptor := nil;
end;
CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
try
with SI do
begin
FillChar(SI, SizeOf(SI), 0);
cb := SizeOf(SI);
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
hStdOutput := StdOutPipeWrite;
hStdError := StdOutPipeWrite;
end;
WorkDir := Work;
Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
nil, nil, True, 0, nil,
PChar(WorkDir), SI, PI);
CloseHandle(StdOutPipeWrite);
if Handle then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
Result := Result + Buffer;
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(PI.hProcess, INFINITE);
finally
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
end;
finally
CloseHandle(StdOutPipeRead);
end;
end;
0
Il y a aussi une solution sur Torry: http://www.swissdelphicenter.ch/torry/showcode.php?id=683
Questions connexes
- 1. Comment créer un Pad simple dans Dictation Delphi2009 + Vista
- 2. Comment activer DOS sous Vista ou Win7
- 3. UnauthorizedAccessException: Obtenir dans Vista
- 4. Comment obtenir Phonemes sur la reconnaissance vocale?
- 5. Comment puis-je obtenir la sortie d'un script Perl dans un fichier à partir de l'invite DOS?
- 6. Sortie vers DOS en utilisant C# dans Visual Studio
- 7. Commande DOS dans C# - RedirectStandardError/Problème de sortie
- 8. Comment obtenir la sortie de commande externe combiner avec Pipe
- 9. Comment rediriger la sortie d'une commande lorsqu'elle est exécutée via la commande DOS START
- 10. Obtenir la sortie sqlcmd dans un GridView
- 11. Comment exécuter la commande en utilisant la sortie d'une autre commande sous DOS?
- 12. Comment obtenir la sortie HTML d'un DataGrid?
- 13. Comment obtenir la sortie de subprocess.Popen()
- 14. Sortie de sous-processus dans le script batch DOS non visible dans Apache
- 15. Obtenir la sortie d'un fil
- 16. Obtenir la sortie de vue dans Oracle
- 17. Obtenir la sortie dans Array Collection
- 18. Obtenir la sortie d'un processus
- 19. Comment obtenir Vista Edition par programme?
- 20. comment exécuter la commande DOS avec des options en java
- 21. Voir ram dans DOS
- 22. obtenir la sortie au format
- 23. obtenir la sortie de la console
- 24. commande LYNX comme dans DOS?
- 25. Dos à dos UIScrollView zoom
- 26. Message d'erreur Eclipse/adb dans Vista "Impossible d'analyser la sortie de la version adb"
- 27. obtenir la sortie et l'état de sortie shell_exec()
- 28. Comment utiliser la police DOS dans l'application WinForms
- 29. Obtenir la sortie entière de sous-processus.Popen
- 30. Comment obtenir le délai d'expiration du moniteur sur Vista