Hi all!

What is the best way to prevent an user to start an run more than one
instance of a VFP-app?

Best regards
Christina

Re: Stop user from installing more than 1 instance by Rick

Rick
Fri Sep 17 18:42:13 CDT 2004

Christina,
There are multiple ways - here are a few I've used:
1) Lock a specific temp file and if it can't be locked, then the app is =
already running. (FLOCK() is good for this.)
2) Use API calls to see if the main window is already open.
3) Use the mutex API object.

Rick

"Ch L=F6fberg" <ch.lofberg@telia.com> wrote in message =
news:hvJ2d.3525$d5.27072@newsb.telia.net...
> Hi all!
>=20
> What is the best way to prevent an user to start an run more than one
> instance of a VFP-app?
>=20
> Best regards
> Christina
>=20
>

Re: Stop user from installing more than 1 instance by Cy

Cy
Fri Sep 17 18:45:12 CDT 2004

Ch Löfberg wrote:
> Hi all!
>
> What is the best way to prevent an user to start an run more than one
> instance of a VFP-app?
>
> Best regards
> Christina
>
>
What I find works best when I want to do that is to have a DBF file that
is contained in each local workstation directory which I open. Before
opening I try to open it exclusive using low level I/O and give a
message about only a single copy being allowed if I can't open it
exclusivly.

--
Cy Welch
Senior Programmer
MetSYS Inc
http://www.metsysinc.com

Re: Stop user from installing more than 1 instance by Ch

Ch
Sun Sep 19 14:23:56 CDT 2004

Hi Rick! and thank you!

I tried your solution to FLOCK() a file which is allready locked. But it
does´nt return .F. A file allready locke can be locked again and again an
FLOCK() returns .T. everytime.

In the help we can read "FLOCK() ...returns false (.F.) if the table or a
record in the table is already locked by another user".

Can you give us an example in code to explain your sugestion.

Best regards
Christina

"Rick Bean" <rgbean@unrealmelange-inc.com> skrev i meddelandet
news:uRxy4ARnEHA.3352@TK2MSFTNGP15.phx.gbl...
Christina,
There are multiple ways - here are a few I've used:
1) Lock a specific temp file and if it can't be locked, then the app is
already running. (FLOCK() is good for this.)
2) Use API calls to see if the main window is already open.
3) Use the mutex API object.

Rick

"Ch Löfberg" <ch.lofberg@telia.com> wrote in message
news:hvJ2d.3525$d5.27072@newsb.telia.net...
> Hi all!
>
> What is the best way to prevent an user to start an run more than one
> instance of a VFP-app?
>
> Best regards
> Christina
>
>



Re: Stop user from installing more than 1 instance by Anders

Anders
Mon Sep 20 05:30:35 CDT 2004

FLOCK() returns .T. if you repeat it in the same session. Set up two session
( different datasessionid values) and the second one to try flockin the same
table with get .F. Or launch VFP or two VFP apps and ony the first one to
FLOCK a table will succeed.
-Anders



"Ch Löfberg" <ch.lofberg@telia.com> wrote in message
news:g1l3d.103737$dP1.375154@newsc.telia.net...
> Hi Rick! and thank you!
>
> I tried your solution to FLOCK() a file which is allready locked. But it
> does´nt return .F. A file allready locke can be locked again and again an
> FLOCK() returns .T. everytime.
>
> In the help we can read "FLOCK() ...returns false (.F.) if the table or a
> record in the table is already locked by another user".
>
> Can you give us an example in code to explain your sugestion.
>
> Best regards
> Christina
>
> "Rick Bean" <rgbean@unrealmelange-inc.com> skrev i meddelandet
> news:uRxy4ARnEHA.3352@TK2MSFTNGP15.phx.gbl...
> Christina,
> There are multiple ways - here are a few I've used:
> 1) Lock a specific temp file and if it can't be locked, then the app is
> already running. (FLOCK() is good for this.)
> 2) Use API calls to see if the main window is already open.
> 3) Use the mutex API object.
>
> Rick
>
> "Ch Löfberg" <ch.lofberg@telia.com> wrote in message
> news:hvJ2d.3525$d5.27072@newsb.telia.net...
> > Hi all!
> >
> > What is the best way to prevent an user to start an run more than one
> > instance of a VFP-app?
> >
> > Best regards
> > Christina
> >
> >
>
>


Re: Stop user from installing more than 1 instance by Rick

Rick
Mon Sep 20 08:14:43 CDT 2004

Christina,
To avoid use tables, you can use FOPEN() on a temp file or one you know =
won't be used during your session. e.g.:
IF File("c:\autoexec.bat") and !FOPEN("c:\autoexec.bat")
* in use
ENDIF

This will even prevent firing up two copies inside VFP!

Rick

P.S. While I used "c:\autoexec.bat", you could use an empty text file in =
your local temp or VFP directory.


"Ch L=F6fberg" <ch.lofberg@telia.com> wrote in message =
news:g1l3d.103737$dP1.375154@newsc.telia.net...
> Hi Rick! and thank you!
>=20
> I tried your solution to FLOCK() a file which is allready locked. But =
it
> does=B4nt return .F. A file allready locke can be locked again and =
again an
> FLOCK() returns .T. everytime.
>=20
> In the help we can read "FLOCK() ...returns false (.F.) if the table =
or a
> record in the table is already locked by another user".
>=20
> Can you give us an example in code to explain your sugestion.
>=20
> Best regards
> Christina
>=20
> "Rick Bean" <rgbean@unrealmelange-inc.com> skrev i meddelandet
> news:uRxy4ARnEHA.3352@TK2MSFTNGP15.phx.gbl...
> Christina,
> There are multiple ways - here are a few I've used:
> 1) Lock a specific temp file and if it can't be locked, then the app =
is
> already running. (FLOCK() is good for this.)
> 2) Use API calls to see if the main window is already open.
> 3) Use the mutex API object.
>=20
> Rick
>=20
> "Ch L=F6fberg" <ch.lofberg@telia.com> wrote in message
> news:hvJ2d.3525$d5.27072@newsb.telia.net...
>> Hi all!
>>
>> What is the best way to prevent an user to start an run more than one
>> instance of a VFP-app?
>>
>> Best regards
>> Christina
>>
>>
>=20
>

RE: Stop user from installing more than 1 instance by Leemi

Leemi
Mon Sep 20 08:52:59 CDT 2004

Hi Christina:

Take a look at the FirstInstance.prg available from Universalthread.com. Go
to www.universalthread.com, click on the Download icon, and choose Visual
FoxPro as the product. In the ID text box of the query page, search for
"9497.

I hope this helps.

This posting is provided "AS IS" with no warranties, and confers no rights.

Sincerely,
Microsoft FoxPro Technical Support
Lee Mitchell

*-- VFP9 Public Beta Now Available!! --*
Download the VFP9 beta here: http://msdn.microsoft.com/vfoxpro/

*-- VFP8 HAS ARRIVED!! --*
Read about all the new features of VFP8 here:
http://www.universalthread.com/VisualFoxPro/News/VFP8Release.asp
Purchase VFP8 here:
http://shop.microsoft.com/Referral/Productinfo.asp?siteID=11518

Keep an eye on the product lifecycle for Visual FoxPro here:
http://support.microsoft.com/default.aspx?id=fh;[ln];lifeprodv
- VFP5 Mainstream Support retired June 30th, 2003
- VFP6 Mainstream Support retired Sept. 30th, 2003


>Hi all!

>What is the best way to prevent an user to start an run more than one
>instance of a VFP-app?

>Best regards
>Christina