Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 08-02-2010
Avatar de yapt
yapt yapt is offline
Miembro
 
Registrado: sep 2006
Ubicación: España
Posts: 258
Poder: 20
yapt Va por buen camino
Bueno, lo ideal sería convertir todas las llamadas a WideChar, pero me ha sido más fácil hacer lo contrario, convertirlas a AnsiChar.

Pruebalo bien, solo está muy ligeramente probado.

Un saludo.

Código Delphi [-]
function TForm1.ejecutarComando (comando : AnsiString) : AnsiString;
var
  Buffer: array[0..4096] of AnsiChar;
  si: STARTUPINFOA;
  sa: SECURITY_ATTRIBUTES;
  sd: SECURITY_DESCRIPTOR;
  pi: PROCESS_INFORMATION;
  newstdin, newstdout, read_stdout, write_stdin: THandle;
  exitcod, bread, avail: Cardinal;
begin
  Result:= '';

  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
     InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION);
     SetSecurityDescriptorDacl(@sd, true, nil, false);
     sa.lpSecurityDescriptor := @sd;
  end
  else
    sa.lpSecurityDescriptor := nil;

  sa.nLength := sizeof(SECURITY_ATTRIBUTES);
  sa.bInheritHandle := TRUE;
  if CreatePipe(newstdin, write_stdin, @sa, 0) then
  begin
     if CreatePipe(read_stdout, newstdout, @sa, 0) then
     begin
        GetStartupInfoA(si);
        with si do
        begin
          dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
          wShowWindow := SW_HIDE;
          hStdOutput := newstdout;
          hStdError  := newstdout;
          hStdInput  := newstdin;
        end;
        Fillchar(Buffer, SizeOf(Buffer), #0);
        GetEnvironmentVariableA(AnsiString('COMSPEC'), @Buffer, SizeOf(Buffer) - 1);
        StrCat(@Buffer,PAnsiChar(' /c ' + comando));
        if CreateProcessA(nil, @Buffer, nil, nil, TRUE, CREATE_NEW_CONSOLE, nil, nil, si, pi) then
        begin
          repeat
             PeekNamedPipe(read_stdout, @Buffer, SizeOf(Buffer) - 1, @bread, @avail, nil);
             if bread > 0 then
             begin
                FillChar(Buffer, SizeOf(Buffer), 0);
                ReadFile(read_stdout, Buffer, bread, bread, nil);
                Result:= Result + AnsiString(PAnsiChar(@Buffer));
             end;
             Application.ProcessMessages;
             GetExitCodeProcess(pi.hProcess, exitcod);
          until (exitcod <> STILL_ACTIVE) and (bread = 0);
        end;
        CloseHandle(read_stdout);
        CloseHandle(newstdout);
     end;
     CloseHandle(newstdin);
     CloseHandle(write_stdin);
  end;
end;
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Exportar reporte a pdf de crystal desde delhpi richy08 Varios 2 28-11-2008 17:07:40
Conectar delhpi con mysql richy08 Conexión con bases de datos 4 24-04-2008 22:02:05
Ayuda con Rave Report 6 y Delhpi 2005 MaSSaKKre Impresión 2 06-03-2008 18:23:28
usar el data link file en delhpi richy08 Varios 0 07-11-2007 17:30:34
Donde ubico al que hace los programas delhpi que trae de ejemplo jpardo25cl Varios 1 29-11-2006 16:24:09


La franja horaria es GMT +2. Ahora son las 21:33:47.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi