在delphi上我发现我可以像这样锁定一个文件:
aHandle := CreateFile(PChar(aFileName),GENERIC_READ, 0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); // get the handle of the file
aFileSize := GetFileSize(aHandle,nil); //get the file size for use in the lockfile function
Win32Check(LockFile(aHandle,0,0,aFileSize,0)); //lock the file
但是有没有办法让文件保持锁定直到下次重新启动而不让应用程序运行到那时?