Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multi User File Open / Partial File Locking Winnt

Posted on 1998-11-05
4
Medium Priority
?
320 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

636 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