对文件和文件夹的操作都可以使用
BOOL LockFileEx(
  HANDLE hFile,                   // handle to file
  DWORD dwFlags,                  // lock options
  DWORD dwReserved,               // reserved
  DWORD nNumberOfBytesToLockLow,  // low-order word of length 
  DWORD nNumberOfBytesToLockHigh, // high-order word of length
  LPOVERLAPPED lpOverlapped       // contains starting offset
);
试试吧!