Solved

Locking a file

Posted on 1998-06-23
7
151 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

744 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