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
  #2  
Antiguo 23-10-2008
Avatar de elcolo83
elcolo83 elcolo83 is offline
Miembro
 
Registrado: feb 2007
Ubicación: Argentina
Posts: 65
Poder: 20
elcolo83 Va por buen camino
Lo que tienes que hacer es crear la unidad del hilo (por una cuestion de proligidad, je) y luego incluirla en el uses de la unidad en la cual usaras ese hilo.
Aca te dejo una unidad que yo uso para hacer descargas desde la web para que veas un ejemplo.

Código Delphi [-]
unit ThDescarga;

interface

uses
  Classes, IdHTTP, Messages, sysutils, IdComponent, shellApi;

type
  TDescarga = class(TThread)
    procedure SetParam(_WebFile, _Destino: String);//; _ObjProg: TObject);
    Procedure UpdateProg;
  private
    { Private declarations }
  protected
    procedure Execute; override;
  public
    Progreso: integer;
    //ObjProg: TObject;
    WebFile: String;
    Destino: String
  end;

implementation

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure Descarga.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ Descarga }
uses Prin, dialogs, FuncionesVarias;

Procedure TDescarga.UpdateProg;
begin
  //Principal.ProgresoDescarga.Position:=
end;

procedure TDescarga.SetParam(_WebFile, _Destino: String);//; _ObjProg: TObject);
begin
  WebFile:= _WebFile;
  Destino:= _Destino;
//  ObjProg:= _ObjProg;
end;


procedure TDescarga.Execute;
var ArchDestino: TFileStream;
    BorrarArch: Boolean;
    i: integer;
    s, Pass: String;
const a=33;
begin
  { Place thread code here }
 { with TidHttp.Create(self)do
    try

    finally
      Free;
    end;}
//OnTerminate:= Principal.SubMenu.OnClick;
FreeOnTerminate:=True;
if pos('/PROGRAM/', Principal._Dst)>0 then
  begin
    Delete(Principal._Dst, 1, 9);
    Principal._Dst:= PChar(ExtractFilePath(ParamStr(0)))+Principal._Dst;
  end;
if (Principal.Descargando)and((Not FileExists(Principal._Dst))or
      (lowercase(ExtractFileExt(Principal._Dst))='.up')) then
  begin
    if Not DirectoryExists(Principal._Dst) then
      ForceDirectories(ExtractFilePath(Principal._Dst));
    ArchDestino:=TFileStream.Create(Principal._Dst, fmCreate);
    try
      BorrarArch:= False;
      try
        Principal.IdHTTP.Get(Principal._WF, ArchDestino);
      except
        BorrarArch:= True;
      end;
    finally
      if ArchDestino.Size <> Principal.FTotalBytes then
        BorrarArch:= True;
      ArchDestino.free;
      Principal.Descargando:= False;
      Principal.ProgresoDescarga.Visible:= False;

      if BorrarArch then
        DeleteFile(Principal._Dst)
      else
        begin
          if lowercase(ExtractFileExt(Principal._Dst))='.up' then
           begin
             Principal.ListaDescarga.Lines.Clear;
             Principal.ListaDescarga.Lines.LoadFromFile(Principal._Dst);
             Pass:= '#File,Get'+Chr(a+100);
             for i:= 0 to Principal.ListaDescarga.Lines.Count - 1 do
              begin
                s:= Principal.ListaDescarga.Lines[i];
                Principal.ListaDescarga.Lines[i]:= DesCifrar(S, Pass);
                if Pass='#File,Get'+Chr(a+100) then
                  Pass:= '#File,Dest'+Chr(a+100)
                else Pass:='#File,Get'+Chr(a+100);
              end;
             DeleteFile(Principal._Dst);
             Principal.IdHTTPWorkEnd(Self, wmRead);
           end
          else if lowercase(ExtractFileExt(Principal._Dst))='.exe' then
            begin
              try
                if (lowercase(ExtractFileName(Principal._Dst))<>'update.exe')then
                  ShellExecute(0, '', PChar(Principal._Dst), PChar('/'+PChar(ParamStr(0))), '', 0);
              except
                Principal.Log('Error al Ejecutar: '+Principal._Dst);
              end;
              {if (lowercase(ExtractFileName(Principal._Dst))='update.exe')then
                  Principal.AutoClose.Enabled:= True;}
            end;
        end;
    end;
  end
else
  Principal.Descargando:= False;
  Principal.ProgresoDescarga.Visible:= False;
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
como crear dll en tiempo de ejecucion Maycoll Varios 12 10-05-2008 01:57:19
Como crear aplicacion MultiCapa Delphi 2007 elopezf Conexión con bases de datos 0 06-09-2007 23:04:48
con delphi 2007 for php, Crear un nuevo tema? poliburro Debates 13 27-04-2007 20:16:24
Aplicacion con varios Hilos de Ejecución samantha jones Varios 1 02-03-2005 17:27:24
Hilos de ejecucion el toluca Varios 2 29-06-2004 22:59:04


La franja horaria es GMT +2. Ahora son las 10:35:51.


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