?
Solved

Multi User File Open / Partial File Locking Winnt

Posted on 1998-11-05
4
Medium Priority
?
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 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