unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
h: THandle;
e: DWORD;
begin
h:=CreateFile(
PChar('c:\Downloads\Книга1.xls'),
GENERIC_READ or GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
0,
0
);
if h=INVALID_HANDLE_VALUE then
begin
e:=GetLastError;
if e=ERROR_SHARING_VIOLATION then ShowMessage('The process cannot access the file because it is being used by another process.')
else ShowMessage(SysErrorMessage(e));
end else CloseHandle(h);
end;
end.
__________________
Пишу программы за еду.
__________________