Solved

Multi User File Open / Partial File Locking Winnt

Posted on 1998-11-05
4
311 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
Comment Utility
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
Comment Utility
Well, 'LockFile()' allows you to lock prtions of a file...
0
 

Author Comment

by:misha051797
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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