Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-02-2007
mierda mierda is offline
Miembro
 
Registrado: may 2006
Posts: 129
Poder: 19
mierda Va por buen camino
usar lockfile and unlockfile

Hola, estoy tratando de usar estas funciones de la api ... pero no me chutan ... a ver si me podeis echar algun cable ... ya que a esta profundidad me pierdo

Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    OpenDialog1: TOpenDialog;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
 hFile: THandle;
 Sof: Longint;
begin
try
 hFile := CreateFile(pchar(edit1.text),0,0,nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
 Sof := GetFileSize(hFile,nil);
 if UnlockFile(hFile,0,0,Sof,0) then
   showmessage ('Unlock CONSEGUIDO!!!!')
 else
   showmessage ('Unlock no conseguido');
 CloseHandle(hFile);
except
    showmessage ('Ha ocurrido un error al intentar hacer el unlock');
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
  edit1.Text := OpenDialog1.FileName;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
 hFile: THandle;
 Sof: Longint;
begin
try
 hFile := CreateFile(pchar(edit1.Text),0,0,nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
 Sof := GetFileSize(hFile,nil);
 if LockFile(hFile,0,0,Sof,0) then
   showmessage ('Lock CONSEGUIDO!!')
 else
   ShowMessage('Lock no conseguido');
Except
  showmessage ('Ha ocurrido un error al intentar hacer el lock')
  end;
end;
end.

muchas gracias.
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
Que distribucion usar brandolin Linux 4 10-08-2006 03:03:22
Usar o no Usar un DBGrid Anabel Conexión con bases de datos 13 13-01-2006 20:05:21
Dll o BPL... que usar brandolin Varios 2 21-04-2005 18:10:03
¿Que componente usar? chele Impresión 9 18-03-2004 15:57:44
q usar? demonr Impresión 6 29-07-2003 19:43:18


La franja horaria es GMT +2. Ahora son las 10:26:49.


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