Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another app instance question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00628296
Message ID:
00628379
Vues:
17
>>>I need to know how many instances of an application are running. The main window title for the application might or might not be different among the running instances, so I cannot use findwindow. What I would really like to be able to do is sniff the system's task list... as I need something that would perform the equivalent of (if it existed) an ATasks() function. Each row would contain info about a running task, and the columns would contain things like the EXE name, the PID, the length of time it has been running, etc. Any suggestions? Thanks very much.
>>>
>>>P.S. Maybe instead of ATasks(), I could use ATasker() function call. :-) George?
>>
>>ROFL!
>>
>>Each running application has a window associated with it. It's a relatively simple matter to iterate through the top level windows, retrieve the title bar text and compare it for possible matches. My Is_Run32 program (in the download section) does this to retrieve the window handle based on the known portion of the title bar text. Besides that, you might also want to look at my SpyFoxFox (also in the download section). This retrieves the window handle, title text and class name of all open windows including children.
>>
>>The problem with trying to retrieve windows based on their class is that while many applications retain the class name from version to version (VB - Thunderform, Word - OpusApp) others do not. VFP is an example of the latter.
>
>But what if I have a compiled VFP app called MyApp.EXE? I just need to ask the OS how many instances of it are running.

OK, how about
UINT GetWindowModuleFileName(
  HWND hwnd,            // handle to window
  LPTSTR lpszFileName,  // file name buffer
  UINT cchFileNameMax   // max size of file name buffer
* VFP Declaration and usage...
DECLARE INTEGER GetWindowModuleFileName IN Win32API;
  INTEGER hwnd, STRING @lpszFileName, INTEGER cchFileNameMax
#DEFINE MAX_PATH 260
lcfilename = SPACE(MAX_PATH)
* lnhwnd is the window of interest
lnresult = GetWindowModuleFileName(lnhwnd, @lcfilename, MAX_PATH)
? LEFT(lcfilename, lnresult)
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform