Is there any way to tell in Windows how many copies of an application are open on the machine the program is running on? (server or stand-alone)
Thanks,
Jim
------------------
Jim Seekamp
Thanks,
Jim
------------------
Jim Seekamp
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Example of getting appCount via enumeration of all open windows '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ #COMPILE EXE #INCLUDE "WIN32API.INC" GLOBAL gWhatApp AS STRING, gAppCount AS LONG DECLARE CALLBACK FUNCTION DlgProc() AS LONG DECLARE FUNCTION EnumWindowsProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Create dialog and controls, etc '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ FUNCTION PBMAIN () AS LONG LOCAL hDlg AS LONG DIALOG NEW 0, "PB appCount..",,, 128, 22, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg CONTROL ADD BUTTON, hDlg, 10, "&Get count", 4, 4, 60, 14 CONTROL ADD BUTTON, hDlg, 11, "E&xit", 64, 4, 60, 14 DIALOG SHOW MODAL hDlg CALL DlgProc END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Main callback '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ CALLBACK FUNCTION DlgProc() AS LONG IF CBMSG = %WM_COMMAND THEN IF CBCTL = 10 THEN gAppCount = 0 gWhatApp = "powerbasic 32-bit dll compiler" '<- start of title to find (change to your liking) EnumWindows CODEPTR(EnumWindowsProc), 0 MSGBOX FORMAT$(gAppCount) & " occurrence(s) of PB/DLL 6 running" ELSEIF CBCTL = 11 THEN DIALOG END CBHNDL END IF END IF END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Enumerate open windows and compare titles '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ FUNCTION EnumWindowsProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG LOCAL zTitle AS ASCIIZ * %MAX_PATH GetWindowText hWnd, zTitle, %MAX_PATH '<- get window title IF UCASE$(LEFT$(zTitle, LEN(gWhatApp))) = UCASE$(gWhatApp) THEN INCR gAppCount FUNCTION = 1 '<- return value to contuine with next, return zero to break action END FUNCTION
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment