打开并锁定一个文件(使用LockFile API函数)
var
aHandle : THandle;
aFileSize : Integer;
aFileName : String; procedure TForm1.Button3Click(Sender: TObject);
begin
aFileName := 'C:\101\Java_new.pdf';
aHandle := CreateFile(PChar(aFileName),GENERIC_READ, , nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,); // get the handle of the file aFileSize := GetFileSize(aHandle,nil); //get the file size for use in the lockfile function
Win32Check(LockFile(aHandle,,,aFileSize,)); //lock the file
end; procedure TForm1.Button4Click(Sender: TObject);
begin
Win32Check(UnlockFile(aHandle,,,aFileSize,));//unlock the file
CloseHandle(aHandle);//Close the handle of the file.
end;
http://stackoverflow.com/questions/1916084/how-do-i-get-the-handle-for-locking-a-file-in-delphi
打开并锁定一个文件(使用LockFile API函数)的更多相关文章
- C#打开或者创建一个文件,然后向其末尾写入数据的方法
原文:C#打开或者创建一个文件,然后向其末尾写入数据的方法 FileStream fs = new FileStream(@"d:\timetick.txt" ...
- open, creat - 用来 打开和创建 一个 文件或设备
SYNOPSIS 总览 #includ e <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int o ...
- Windows文件操作的API函数[转载]
在VC中,大多数情况对文件的操作都使用系统提供的 API 函数,但有的函数我们不是很熟悉,以下提供一些文件操作 API 函数介绍: 一般文件操作 API CreateFile 打开文件 要对文件进行读 ...
- VC++打开对话框选择一个文件夹路径 BROWSEINFO结构
typedef struct _browseinfoW { HWND hwndOwner; PCIDLIST_ABSOLUTE pidlRoot; LPWSTR pszDisplayName; // ...
- python一个文件里面多个函数同时执行(多进程的方法,并发)
#coding=utf-8 import timefrom selenium import webdriverimport threading def fun1(a): print a def fun ...
- 与众不同 windows phone (38) - 8.0 关联启动: 使用外部程序打开一个文件或URI, 关联指定的文件类型或协议
[源码下载] 与众不同 windows phone (38) - 8.0 关联启动: 使用外部程序打开一个文件或URI, 关联指定的文件类型或协议 作者:webabcd 介绍与众不同 windows ...
- 程序4-5 打开一个文件,然后unlink
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- PHP文件操作 之读取一个文件(以二进制只读的方式打开)
最近应用了文件的读取,顺便复习一下! //读取一个文件 $f = fopen($filename,'rb'); $f: 表示返回的一个资源句柄 $filename:要打开的文件路径 rb:参数,表示只 ...
- 重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议
原文:重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议 [源码下载] 重新想象 Windows 8 Store ...
随机推荐
- Apparatus, system, and method for automatically minimizing real-time task latency and maximizing non-real time task throughput
An apparatus, system, and method are provided for automatically minimizing Real-Time (RT) task laten ...
- QEMU使用virtio磁盘
环境 宿主环境:windows 10 pro QEMU版本:3.1 客户机:windows2003 virtio是一种半虚拟化技术,window2003安装盘不带驱动程序,所以首先采用IDE方式安装w ...
- Objective-C的基础数据结构
类的数据结构 Class(指针) ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 typedef struct objc_c ...
- On-demand diverse path computation for limited visibility computer networks
In one embodiment, a source device detects a packet flow that meets criteria for multi-path forwardi ...
- Obtaining Directory Change Notifications(微软的例子,使用FindFirstChangeNotification,FindNextChangeNotification,FindCloseChangeNotification API函数)
An application can monitor the contents of a directory and its subdirectories by using change notifi ...
- Mac下cocos2dx3.1用Cocos IDE写的Lua binding篇01
本人Lua新手,写着玩玩. 新建一个模版project. 一.改动main.lua require "Cocos2d" require "Cocos2dConstants ...
- 第一泰泽(Tizen)智能手机发布在俄罗斯
请看下图: 这是韩国三星公司在俄罗斯境内公布的第一款泰泽(Tizen)智能手机(今年6月2日).这说明,Tizen操作系统没有死去. 在泰泽官网上将泰泽操作系统定义为:"The OS of ...
- java_Mac安装多个JDK版本并设置环境变量
JDK6.JDK7.JDK8三个版本的汇总地址:https://pan.baidu.com/s/1pKSYv8Z 安装 JDK6安装 JDK6下载地址 见网盘 安装完毕后确认版本 JavaForOSX ...
- Oracle 已有则更新,没有则插入
使用merge merge into 表名 t1 using (select '数据数据' 字段1,'数据数据' 字段2 from dual) t2 on (t1.字段1 = t2.字段1) when ...
- WPF笔记 ( xmlns引用,Resource、Binding 前/后台加载,重新绑定) 2013.6.7更新
原文:WPF笔记 ( xmlns引用,Resource.Binding 前/后台加载,重新绑定) 2013.6.7更新 1.xmlns Mapping URI的格式是 clr-namespace:&l ...