Ver Mensaje Individual
  #9  
Antiguo 12-06-2006
JELIRM JELIRM is offline
Miembro
 
Registrado: feb 2005
Ubicación: EL SALVADOR
Posts: 124
Reputación: 20
JELIRM Va por buen camino
Cool

Gracias seoane fijate que solucione el problema, la cuestion era que yo lo estaba haciendo con un acceso directo de la cliente al servidor; pero para solucionarlo hice un maping desde la cliente al servidor y Zaz!!! funcionó!! mapeando accede a todos los recursos como local, por eso no funcionaba en el acceso directo.
Pero ahora tengo otro problemita, y es que a veces no se porque cuando lo ejecuto el programa desde la cliente no me sale la ip sale null(en blanco) y cierro lo aplicacion y vuelvo a correr hasta que sale pero es en un orden aleatorio a veces me sale a la primera y a veces no, cosa que no sucede cuando lo ejecuto en el servidor como local.
te mostraré el codigo que tengo.
ponle atención al evento create del formulario ya que ahi puse mi codigo lo demós tu lo sabes mejor que nadie; pero lo puse completo para que lo veas talvez estoy fallando en el orden del codigo. pero mejor hechale un vistazo


Código:
unit Principal;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    MainMenu1: TMainMenu;
    Acercade1: TMenuItem;
    Salir1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Acercade1Click(Sender: TObject);
    procedure Salir1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
 
implementation
uses Acerca;
{$R *.dfm}
 function IsWinNT: boolean;
var
  OSV: OSVERSIONINFO;
begin
  OSV.dwOSVersionInfoSize := sizeof(osv);
  GetVersionEx(OSV);
  result := OSV.dwPlatformId = VER_PLATFORM_WIN32_NT;
end;
function CmdExec(Cmd: string): string;
var
  Buffer: array[0..4096] of Char;
  si: STARTUPINFO;
  sa: SECURITY_ATTRIBUTES;
  sd: SECURITY_DESCRIPTOR;
  pi: PROCESS_INFORMATION;
  newstdin, newstdout, read_stdout, write_stdin: THandle;
  exitcod, bread, avail: Cardinal;
begin
  Result:= '';
  if IsWinNT 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
      GetStartupInfo(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);
      GetEnvironmentVariable('COMSPEC', @Buffer, SizeOf(Buffer) - 1);
      StrCat(@Buffer,PChar(' /c ' + Cmd));
      if CreateProcess(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 + String(PChar(@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;
procedure TForm1.FormCreate(Sender: TObject);
var
ResultadoWin9x:String;
ResultadoWinNT:String;
BanderaWin9x:String;
begin
Label1.Caption:='';
  //Corre comando de Dos para Ip de WindowsNT hacia abajo
ResultadoWin9x:=(CmdExec('WINIPCFG | find "IP Address"'));
ResultadoWin9x:=StringReplace(ResultadoWin9x,'IP Address','',[rfReplaceAll]);
BanderaWin9x:=copy(ResultadoWin9x,2,8);

//Valida si La pc no Windows NT hacia abajo
if BanderaWin9x = 'WINIPCFG' then begin;
           //Corre comando de Dos para Ip de versiones windos WindowsNT y posterior
               ResultadoWinNT:=(CmdExec('IPCONFIG | find "IP Address"'));
               ResultadoWinNT:=StringReplace(ResultadoWinNT,'IP Address','',[rfReplaceAll]);
               Label1.Caption:='Su Dirección IP es:'+(ResultadoWinNT);
         end
            else
                  begin;
                   if BanderaWin9x <> 'WINIPCFG' then begin;
                        Label1.Caption:='Su Dirección IP es:'+(ResultadoWin9x);
                    end;
            end;
end;
procedure TForm1.Acercade1Click(Sender: TObject);
begin
Form2.showmodal;
end;
procedure TForm1.Salir1Click(Sender: TObject);
begin
close;
end;

end.

y gracias de nuevo
Responder Con Cita