Run Process -> Return Handle

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Run Process -> Return Handle

Post by AUGE_OHR »

hi,

i want to run many Instance of App but i need "Control" them.
as they all have "same Name" i can´t use "FindWindow" to get Handle

so how can i "run" a Instance and get it´s Handle under harbour :idea:
attached Xbase++ Sample using OT4XB Syntax
TRunProcess.zip
(3.95 KiB) Downloaded 62 times
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Run Process -> Return Handle

Post by AUGE_OHR »

hi

it seems that ShellExecute() return

Code: Select all

  HMG_retnl ((LONG_PTR) hInstance );
https://docs.microsoft.com/en-us/window ... llexecutea
If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an INT_PTR and compared to either 32 or the following error codes below.
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Run Process -> Return Handle

Post by AUGE_OHR »

hi

i try it this Way

Code: Select all

   hwnd := ShellExecute(0, "open", "Playvlc.exe", cPara,cHome ,1)
   AADD(aWin, hwnd)
it does start "Playvlc.exe" as i want but i have always 42 as hwnd ... :(
what do i miss ... :idea:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Run Process -> Return Handle

Post by AUGE_OHR »

hi,

found out that i can find "Title" even when use NOCAPTION
so i can "search" for Windows and it´s Handle after call ShellExecute()

Code: Select all

PROCEDURE GetVLChandle()
LOCAL cTitle, hwnd, ii, iMax, cMemo

   iMax := nRow * nCol
   FOR ii := 1 TO iMax
      cTitle := "PLAYVLC" + STRZERO( ii, 2 )
      hwnd := FindWindowEx(,,, cTitle )
      IF !EMPTY( hwnd )
         WritePlay( cTitle + ".PLAY", STR( hwnd ) )
         AADD( aWin, hwnd )
      ENDIF
   NEXT
! Note : i write a "Number" ... not a String ?!

Code: Select all

STATIC PROCEDURE CheckCloseScreen()
   ...
   IF lCheckScreen = .T.
      aDir := DIRECTORY( "PLAYVLC*.PLAY" )
      iMax := LEN( aDir )
      FOR ii := 1 TO iMax
         IF ".PLAY" $ aDir[ ii ] [ F_NAME ]
            nCount ++
            cMemo := ReadPlay( aDir[ ii ] [ F_NAME ] )
            AADD( aCheck, cMemo )
         ENDIF
      NEXT
      IF nCount <> nOpenVLC
         lCheckScreen = .F.
   
         iMax := LEN( aWin )
         FOR ii := 1 TO iMax
            hProcess := aWin[ ii ]
            SendMessage( hProcess, WM_CLOSE, 0, 0 )
            hb_idleSleep( .1 )
         NEXT
         Domethod( "IPTVMAIN", "PLAYTV", "SHOW" )
         SnapToCtrl("IPTVMAIN","PLAYTV")

      ENDIF
   ENDIF
have fun
Jimmy
Post Reply