|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to minimized a program started with OpenProcess
I use the following to lauch a program and wait until it is complete, but I want to know how to force that program to be minimized. Sime I know the processid, can I use some other API to minimize (or even hide) the window?
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long) Const STILL_ACTIVE = &H103 Const PROCESS_QUERY_INFORMATION = &H400 Sub Shell32Bit(ByVal JobToDo As String) Dim hProcess As Long Dim RetVal As Long 'The next line launches JobToDo as icon, 'captures process ID hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1)) Do 'Get the status of the process GetExitCodeProcess hProcess, RetVal 'Sleep command recommended as well as DoEvents DoEvents: Sleep 100 'Loop while the process is active Loop While RetVal = STILL_ACTIVE End Sub |
|
#2
|
|||
|
|||
|
U can try to use This!
Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long Sample code: Const RSP_SIMPLE_SERVICE = 1 Const RSP_UNREGISTER_SERVICE = 0 Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long Public Sub MakeMeService() Dim pid As Long, reserv As Long 'Get the current process ID pid = GetCurrentProcessId() 'Register as service regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE) End Sub Public Sub UnMakeMeService() Dim pid As Long, reserv As Long 'Get the current process ID pid = GetCurrentProcessId() 'Unregister as service regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE) End Sub Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net MakeMeService 'Right now, you're program is hidden from the CTRL-ALT-DEL-list |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > How to minimized a program started with OpenProcess |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|