Solved

Multi User File Open / Partial File Locking Winnt

Posted on 1998-11-05
4
312 Views
Last Modified: 2012-05-04
Greetings,
I am trying to get my database project started. Since I am building the multi-user database application I have know the best solution for allowing 2 or more users to write to the file. Is there a windows nt function that can do so? also can i partially lock a section of the file?
Thank you.
0
Comment
Question by:misha051797
4 Comments
 
LVL 1

Expert Comment

by:TheGrinch
ID: 1177065
You say "database project" but then talk only about files. Which is it? Considerations with a database are quite different from those with files.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1177066
Well, 'LockFile()' allows you to lock prtions of a file...
0
 

Author Comment

by:misha051797
ID: 1177067
TheGrinch,
Cood point. What I am trying to do is to allow multi user access to the file.
I do not want an application to lock file, so other users can't read/write to the file.
I guess there must be a simple solution to what I am trying to do. Right?
0
 

Accepted Solution

by:
guga earned 50 total points
ID: 1177068
When you open file with help of CreateFile function(Win32 API) u need use flags FILE_SHARE_READ|FILE_SHARE_WRITE.
U can read this file wihout sharing violation error.

hFile=CreateFile("data.base",
                 GENERIC_READ|GENERIC_WRITE,
                 FILE_SHARE_READ|FILE_SHARE_WRITE,
                 NULL,
                 OPEN_EXISTING,
                 FLAG_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,
                 NULL);
but when somebody want to write into file LockFile() needed. This
is unique solution to avoid conflict.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now