`
eueuy
  • 浏览: 70678 次
  • 性别: Icon_minigender_1
  • 来自: 天津
最近访客 更多访客>>
社区版块
存档分类
最新评论

判断文件是否使用中 Checking If File Is In Use

阅读更多

 

Checking If File Is In Use

Your Guide, Zarko Gajic From Zarko Gajic,
Your Guide to Delphi Programming.
FREE Newsletter. Sign up now!
IsFileInUse will return true if the file is locked for exclusive access. It would fail if the file doesn't exist at all.

~~~~~~~~~~~~~~~~~~~~~~~~~
function IsFileInUse(fName : string) : boolean;
var
    HFileRes : HFILE;
begin
    Result := false;
    if not FileExists(fName) then exit;
    HFileRes :=
      CreateFile(pchar(fName),
                 GENERIC_READ or GENERIC_WRITE,
                 0, nil, OPEN_EXISTING,
                 FILE_ATTRIBUTE_NORMAL,
                 0) ;
    Result := (HFileRes = INVALID_HANDLE_VALUE) ;
    if not Result then
    CloseHandle
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Capture Maximize/Minimize Buttons
« Rotating text

uses wininet
 
if not InternetCheckConnection(PChar(CUrl), 1, 0) then
  Begin
    ShowMessage('网路不通!');
    Exit;
  End;
分享到:
评论

相关推荐

    hash table spell checking

    Note: the stl vector is used in this assignment, if you have any difficulties, you can refer to the documents given in this folder. Submission Submit only the following. 1. hashset.cpp – your ...

    如何编写批处理文件批处理文件批处理文件

    if 表示将判断是否符合规定的条件,从而决定执行不同的命令。有三种格式: 1、if "参数" == "字符串" 待执行的命令 参数如果等于指定的字符串,则条件成立,运行命令,否则运行下一句。(注意是两个等号) 如if "%1...

    .htaccess

    .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file. 从本指南中,你将可以学习到有关.htaccess文件及其功能的知识,并用以优化你的网站。尽管....

    VclZip pro v3.10.1

    - If a file does not extend beyond any of the original limitations (filesizes of 4 gig or 65535 files) then no Zip64 format information is included in the archive. - property isZip64 - tells you when ...

    数据结构作业Hash表

    Note: the stl vector is used in this assignment, if you have any difficulties, you can refer to the documents given in this folder. Submission Submit only the following. 1. hashset.cpp – your ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Note: If you use a symbol Foo in your source file, you should bring in a definition for Foo yourself, either via an #include or via a forward declaration. Do not depend on the symbol being brought in ...

    squashfs2.2-r2.tar.gz

    SQUASHFS 2.2 - A squashed read-only filesystem for Linux ... Released under the GPL licence (version 2 or later). Welcome to Squashfs version ... If an exclude file/directory is absolute (i.e. prefixed...

    Thinking in LINQ

    great only if you know how to use it properly; otherwise, you are not much better off than someone with a hammer. LINQ is powerful. Powerful beyond measure. I hope you will see some of that power by ...

    dx修复工具

    The simple style can be enabled by following steps: open the file “Settings.ini” under the programme folder (this file can be created manually if there is no such file under the folder); change the...

    cWhoisv1.52查寻域名是否注册

    If you are just checking availability and do not require the full whois details then you can speed up the function call with some domain extensions by setting $details="*"; before calling cWhois. If...

    convmv-1.15.tar.gz

    This disables checking if symlink targets are in subtree. Symlink target pointers will be converted regardlessly. If you convert multiple hundredthousands or millions of files the memory usage of ...

    BobBuilder_app

    Splitting a page when full is simple and does not require a tree traversal for node overflow checking as in a b+tree. Main page list updates are infrequent and hence the locking of the main page list...

    VB编程资源大全(英文源码 文件)

    Fix-Path.zip This is used to fix a filenames path<END><br>28 , Password-Finder.zip This will help you find you lost Microsoft Access 97 password<END><br>29 , fileexist.zip Checking file ...

    BURNINTEST--硬件检测工具

    in a log file. - Updated license management, in an attempt to remove a rare crash on startup. Release 5.3 build 1012.0002 WIN32 release 31 October 2007 - New build of Rebooter (64-bit Windows ...

    微软内部资料-SQL性能优化3

    If the class is not confident in their understanding, review appendix A04_Locking and its accompanying PowerPoint® file. Transactions in SQL Server provide the ACID properties: Atomicity A ...

    android lint performance probe帮助.zip

    This is a simple tool to help pinpoint performance bottlenecks in individual Android Lint checks. It uses Java byte code instrumentation to collect and report performance statistics per detector for a...

    Qemu-1.0.1 for windows

    -cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] [,cache=...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    Subsequent access times are essentially instantaneous, until either all of the 128 palette states are in use, or the palette is cleared via the VsClearPalette() command. The VsIsReady() function can...

    ICS delphixe10源码版

    If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and ...

Global site tag (gtag.js) - Google Analytics