开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜