Hi All,

My application runs in Windows 2000 Server. The same application is accessed by different users in different windows session creating new application instance for every user.

I have a problem writing data into a file, if I run two instance using two different user Sessions. See the following code (this is a test loop checking for data loss.)

CLog c;
char str[200]={0};
for(int i=0; i < 18000; i++){
HANDLE hMutex = CreateMutex(NULL, FALSE, "MyProtectedErrorHandling");
sprintf(str, "Line:%d Message:Inside the loop, Handle:0x%x", i, hMutex);
DWORD dwResult = WaitForSingleObject(hMutex, INFINITE);
c.write(str); //Opens file in append mode, writes str and closes\ the file.
ReleaseMutex(hMutex);
CloseHandle(hMutex);
}

The total lines should be 36000. But I am not getting all the data I am writing in to the file. I am missing nearly 10 lines of data. Please tell me whether I am using Mutex properly for handling multiple processes or not. If wrong please suggest other useful ways to do this.

Thanks in advance.
Praveen