473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Restrict user to open same file instance

180 100+
Hi all,
How can I restrict a user to open the same file on multiple instances of the same application???? If you have word installed, then open multiple instances of it and try opening the same file on all the application...The user is restricted. How can I achieve this???

Thanks
May 16 '07 #1
6 2031
JosAH
11,448 Expert 8TB
Hi all,
How can I restrict a user to open the same file on multiple instances of the same application???? If you have word installed, then open multiple instances of it and try opening the same file on all the application...The user is restricted. How can I achieve this???

Thanks
Word does it like this: if it wants to open a file "foo.doc" it tries to create a file
"~$foo.doc". If it doesn't exist word creates it, writes the name of the user in
that file and opens "foo.doc".

If that funny file already exists, word 'knows' that another word instance is
already editing that file and it also knows who is editing that file.

When an editing session is done, word simply removes that "~$foo.doc" file
again.

This scenario works because file creation is an atomic process on most (if not
all) file systems.

kind regards,

Jos
May 16 '07 #2
vermarajeev
180 100+
Hi Jos,
Thanks for your reply.

I am working on an application where I can open multiple instances of same aplication. Presently the user is able to open the same file in any instances. The files are in text format. Can you provide me with some resources or something that can help me.

Waiting eagerly
Thanks
May 16 '07 #3
AdrianH
1,251 Expert 1GB
Word does it like this: if it wants to open a file "foo.doc" it tries to create a file
"~$foo.doc". If it doesn't exist word creates it, writes the name of the user in
that file and opens "foo.doc".

If that funny file already exists, word 'knows' that another word instance is
already editing that file and it also knows who is editing that file.

When an editing session is done, word simply removes that "~$foo.doc" file
again.

This scenario works because file creation is an atomic process on most (if not
all) file systems.

kind regards,

Jos
If you open a file with exclusive rights (read/write) wouldn't that stop you from opening it again in the same process as well as others?


Adrian
May 16 '07 #4
JosAH
11,448 Expert 8TB
If you open a file with exclusive rights (read/write) wouldn't that stop you from opening it again in the same process as well as others?


Adrian
It depends on the file system being used on a platform but I suspect what you
just descibed also works when one uses MS Windows. The OP wanted to know
how word does it however, so obediently I answered in my reply ;-)

kind regards,

Jos
May 16 '07 #5
vermarajeev
180 100+
If you open a file with exclusive rights (read/write) wouldn't that stop you from opening it again in the same process as well as others?


Adrian
Any resources with some sample programs???? I think mandatory locks can be some point of initiation. Can you suggest some links or so...

Thanks
May 16 '07 #6
AdrianH
1,251 Expert 1GB
Any resources with some sample programs???? I think mandatory locks can be some point of initiation. Can you suggest some links or so...

Thanks
As Jos said, it depends on the file system/operating system. See CreateFile() in windows Win32 for info on that platform. www.microsoft.msdn.com should get you there where you can search the MSDN website.


Adrian
May 16 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fred Payne | last post by:
Hello All, I'm using SQL Server 2000 and wish to restrict the user login to one instance only. Is this possible? Is this wise?
3
by: Paul | last post by:
Hi all, at present I I've built a website which can be updated by admin and users. My problem, I've combined "log in" and "access levels" to restrict access to certain pages, using the built...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
1
by: da_pander | last post by:
Hi, Can anyone tell me if it is possible to create a XSD schema document that will only allow certain elements to be displayed as available within the instance document depending on say a...
3
by: penguin732901 | last post by:
What do experienced programmers find the most efficient way to handle user settings. Currently I have 4 tables which allow various clients to customize my program to work for them,...
17
by: teddysnips | last post by:
One of my clients has asked me to make a change to one of their Access applications. The application is a Front End/Back End standard app. I didn't develop it, but looking at it tells me that...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
5
by: rahismailbox | last post by:
I want to allow only one account currently logged in from one IP. Sometimes user open two or three accounts from one IP. Is there any way to stop that? I m thinking of getting IP and storing it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.