开发者

Ways to synchronize write access to a file on a network share

开发者 https://www.devze.com 2023-03-01 07:05 出处:网络
I\'m writing a program using C++ under Windows that needs to synchronize write ac开发者_StackOverflowcess to a file via a local network. I was thinking to use the following approach:

I'm writing a program using C++ under Windows that needs to synchronize write ac开发者_StackOverflowcess to a file via a local network. I was thinking to use the following approach:

//Create or open it using 0 for sharing mode
HANDLE hFile = CreateFile(L"\\\\server\\share\\path\\file", GENERIC_READ | GENERIC_WRITE, 0, , OPEN_ALWAYS, , ,);
if(hFile == INVALID_HANDLE_VALUE && ::GetLastError() == ERROR_SHARING_VIOLATION)
{
    //Try again later
}

Can someone confirm that it's a workable solution?

0

精彩评论

暂无评论...
验证码 换一张
取 消