How to disable the Op-Lock while opening a Windows File using CreateFile

Hello All,

We are opening a network file on Windows using the CreateFile API. According to MSDN, the flags FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH should bypass local caching and write directly to disk. However, we observe that the file still opens with an opportunistic lock. Could you advise if there are additional attributes or flags that can be used to prevent this?

Thank you very much

CreateFile(“FileName”,GENERIC_WRITE, FILE_SHARE_WRITE,
NULL,(COPY_FILE_FAIL_IF_EXISTS & dwCopyFlags) ? CREATE_NEW : CREATE_ALWAYS,
FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH , NULL);

CopyFile uses IOCTL_LMR_DISABLE_LOCAL_BUFFERING for this purpose:

IOCTL_LMR_DISABLE_LOCAL_BUFFERING control code - Win32 apps | Microsoft Learn