Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

one instance of program without use of WINDOW TITLE

API Functions

one instance of program without use of WINDOW TITLE

by  danceman  Posted    (Edited  )
this method does not use the window title. which is handy when your title changes. It uses what is called atoms.

** declare the windos api functions
declare integer GlobalAddAtom in win32api string
declare integer GlobalFindAtom in win32api string
declare integer GlobalDeleteAtom in win32api integer

* need a location to hold the atom for exiting. made public
* here, could be a property of a class.
public natom

** when creating a name for the atom it has nothing to do with the window name. so make the name anything.
** it is not case senstive abc = ABC

** if the atom exist from previous load it will return a
** positive number
if GlobalFindAtom('any name') > 0
quit
else
natom = GlobalAddAtom('any name') && create atom for the app
endif

I say use any name, but the name must be consistant. doing a find and add atom will be with the same name.
** at the end of the program just before exiting
** destroy the atom
GlobalDeleteAtom(natom)

it is importen to destroy the atom, for it is not automaticly destroyed on exit. which will mean that the program will not run again, untill the system is restarted.

quit foxpro
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top