Dimension tasklist[1,2] ?api_listapp(@tasklist) for i = 1 to alen(tasklist,1) *!* check for instances that you want next
FUNCTION api_ListApp parameters atask *!* pass an array by reference and it will be filled with running processes and hwnd LOCAL lnHandle, lnCount, lcTitle, lnI, lnHFox DIMENSION laApp[1,2] lnHFox=0 DECLARE INTEGER FindWindow ; IN win32api ; INTEGER nullpointer, ; STRING cwindow_name DECLARE INTEGER GetWindow ; IN win32api ; INTEGER ncurr_window_handle, ; INTEGER ndirection DECLARE INTEGER GetWindowText ; IN win32api ; INTEGER n_win_handle, ; STRING @ cwindow_title, ; INTEGER ntitle_length lnHFox = FindWindow(0,_SCREEN.CAPTION) lnHandle = lnHFox && GetWindow(lnHFox,0) lnCount = 0 DO WHILE lnHandle > 0 lcTitle=SPACE(255) lnI=GetWindowText(lnHandle, @lcTitle,LEN(lcTitle)) IF lnI>0 lcTitle=STRTRAN(TRIM(lcTitle),CHR(0),"") ELSE lcTitle="" ENDIF IF lnHandle > 0 .AND. !EMPTY(lcTitle) lnCount=lnCount+1 DIMENSION laApp(lnCount,2) laApp[lnCount,1]=lcTitle laApp[lnCount,2]=lnHandle ENDIF lnHandle = GetWindow(lnHandle,2) ENDDO lcString = "" IF ALEN(laApp,1)>0 FOR i=1 TO ALEN(laApp,1) lcString = lcString + laApp[i,1]+CHR(13)+CHR(10) NEXT if type("atask[1]") <> "U" *!* array was passed by reference =acopy(laApp,atask) endif release laApp ENDIF RETURN lcString ENDFUNC