Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-04-2017
Snaked Snaked is offline
Baneado
NULL
 
Registrado: sep 2016
Posts: 102
Poder: 0
Snaked Va por buen camino
Question funcion para invocar comandos con fallos

necesito ayuda para esta funcion....sirve para invocar comandos de consola de windows pero sin que se muestre la ventana negra esa tan fea

la cosa es que lo he convertido de un codigo delphi y no he tenido mucha suerte

a ver si algun manitas puede arreglarmela para que funcione (creo que me he hecho el lio con los ifs y el do while repeat ese

Código PHP:
bool IsWinNT(void)
{
OSVERSIONINFO *OSV;

OSV->dwOSVersionInfoSize sizeof(OSV);
GetVersionEx(OSV);
int Result OSV->dwPlatformId;
return(
Result);
}

void CmdExec(AnsiString Cmd)
{
 
char Buffer[4096];
 
STARTUPINFO si;
 
SECURITY_ATTRIBUTES sa;
 
SECURITY_DESCRIPTOR sd;
 
PROCESS_INFORMATION pi;
THandle newstdinnewstdoutread_stdoutwrite_stdin ;
unsigned int exitcod;
unsigned int bread;
unsigned int avail;

int Result 0;
if (
IsWinNT)
{
InitializeSecurityDescriptor(&sdSECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sdtrueNULLfalse);
sa.lpSecurityDescriptor = &sd;
}
else 
sa.lpSecurityDescriptor NULL;
sa.nLength sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle true;
  if (
CreatePipe(newstdinwrite_stdin, &sa0))
   {
     if (
CreatePipe(read_stdoutnewstdout, &sa0))
      {
         
GetStartupInfo(&si);

          
si.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
          
si.wShowWindow SW_HIDE;
           
si.hStdOutput newstdout;
           
si.hStdError newstdout;
           
si.hStdInput newstdin;

           
Fillchar(Buffersizeof(Buffer), 0);
             
GetEnvironmentVariable('COMSPEC', &Buffersizeof(Buffer) - 1);
         
StrCat(&Buffer,PChar(' /c ' Cmd));
      }
      if (
CreateProcess(NULL, &BufferNULLNULLtrueCREATE_NEW_CONSOLENULLNULLsipi)
      {
          while(
exitcod != STILL_ACTIVE && bread 0)
             {
               
PeekNamedPipe(read_stdout, @BufferSizeOf(Buffer) - 1, @bread, @availnil);
                if 
bread 0 then
                
{
                   
Fillchar(BufferSizeOf(Buffer), 0);
                   
ReadFile(read_stdoutBufferbreadbreadnil);
                   
Result Result String(PChar(&Buffer));
                 }
             }

Application.ProcessMessages;
GetExitCodeProcess(pi.hProcessexitcod);
      }
CloseHandle(read_stdout);
CloseHandle(newstdout);
end;
CloseHandle(newstdin);
CloseHandle(write_stdin);
    }
   } 
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
Invocar Funcion PHP desde form html jfontane PHP 6 14-11-2016 22:11:23
Invocar Corrector ortografico de Word para edit y memos Lizette Varios 9 02-05-2010 04:19:48
Comandos SQL para añadir o modificar _Willa SQL 3 29-03-2007 13:38:23
shell para comandos del dos sarga API de Windows 1 16-04-2004 03:55:33
Comandos para Epson TM-U220B MAGRANA Impresión 3 12-01-2004 09:56:45


La franja horaria es GMT +2. Ahora son las 01:02:10.


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