Ver Mensaje Individual
  #5  
Antiguo 05-09-2010
fleming fleming is offline
Miembro
 
Registrado: sep 2010
Posts: 15
Reputación: 0
fleming Va por buen camino
Cita:
Empezado por duilioisola Ver Mensaje
Puedes utilizar TStringList, por ejemplo. Creo que es lo más sencillo:

Código Delphi [-]var ts : TStrings; h : word; //creo begin ts := TStringList.Create; try ts.LoadFromFile('c:\ruta\archivo.loquesea'); for i=0 to ts.Count -1 do begin h := FindWindow(nil, ts[i]); if h <> 0 then PostMessage(h, WM_CLOSE, 0, 0); end; finally ts.Free; end; end;


También puedes utilizar AssignFile y ReadLn:

Código Delphi [-]var f : TextFile; s : string; h : word; //creo begin AssignFile (f,'c:\ruta\archivo.logesea'); try Reset(f); while (not f.Eof) do // Mientras no llegue al final begin ReadLn(f,s); h := FindWindow(nil, ts[i]); if h <> 0 then PostMessage(h, WM_CLOSE, 0, 0); end; finally CloseFile(f); end; end;


Nota: El código puede contener errores, pues lo hice sin un Delphi en frente.
me arroja los siguientes errores el primero:

Build
[Error] Unit1.pas(44): Undeclared identifier: 'i'
[Error] Unit1.pas(44): Incompatible types: 'Boolean' and 'Integer'
[Error] Unit1.pas(45): Expression expected but 'BEGIN' found
[Error] Unit1.pas(46): Incompatible types: 'String' and 'PAnsiChar'
[Fatal Error] AD.dpr(9): Could not compile used unit 'Unit1.pas'
Responder Con Cita