Solved

Locking a file

Posted on 1998-06-23
7
159 Views
Last Modified: 2011-09-20
I am using VB4.0 32-bits, and I wish to know how can I lock certain files from other user using it if
one user is already using it.

Something like microsoft word, where if I am already using docA.doc, and user B from another computer can only view this docA.doc but cannot modify it. However, I perfer that user B cannot even view it at all, if the file is being used.

Is there a way I can code it?
0
Comment
Question by:wsm
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:raygibbins
ID: 1464023
In your code you could create a file called docA.loc when a user  opens docA.doc for the first time. This lock file could contain things like user name etc. When another user wants to open docA.Doc the program first look for docA.loc. If docA.loc exists then you could read it and display a messagebox showing who has it open.
Code would be
If Dir$("c:\temp\docA.loc")<>"" Then
     'Read the lock file and display messagebox
End If

When the docA.doc is closed then the program would delete the lock file
0
 

Accepted Solution

by:
Ajoy earned 100 total points
ID: 1464024
you can use the key word app. This supports certain  properties out of which you can use the instance property.
if app.instance then don't run the file.
if this does not work then get back to me at atarafder@hotmail.com. i would be glad to help you
0
 

Author Comment

by:wsm
ID: 1464025
Ajoy,

I am not very sure what you are saying. Can you give a little bit more
details and example which I can look at?

I think raygibbins has given another good example. However, I do not wish to
create too many "temp" files just for this purpose, if possible.
0
Technology Partners: 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!

 
LVL 1

Expert Comment

by:raygibbins
ID: 1464026
My example is the similar to the way Microsoft and AutoDesk do it.
0
 

Author Comment

by:wsm
ID: 1464027
I notice that, but like I said before I do not wish to add any more "temp" files to the current directory. I have already added some other "temp" hidden files into that directory. Only when I cannot find any other solution to solve this then I will use this creating "temp" file.

I would really appreciate if you can give me any other ideas beside this one.
Thanx inadvance.
0
 

Expert Comment

by:Ajoy
ID: 1464028
wsm,
Before i can give you more details, Could you please tell me if your application is client/server based or a simple application.if your application isc/s based and the application runs on the server then what i said above can easily be implemented.
0
 

Author Comment

by:wsm
ID: 1464029
it is just a normal application that runs on win95. This should or might be a networked environment, but it is not a client/server application. If it is a networked environment, then those files are located at a shared directory
whereby users are allowed to access it. That is why I need some sort of codes
or function that will let people knows if that file is being used by another person.

 Hope u can understand what I am trying to say here.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

628 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