|
-
Aug 27th, 2000, 03:58 PM
#1
Thread Starter
Hyperactive Member
I am launching a game program from my VB app that has a timer control on it, refreshing certain values while in operation. I would like to know how to suspend my control's timer, or make it use minimal resources, while the game is running, but then also have it return functionality after a user leaves the game and clicks on a prompt to resume, which was executed at the time the user launched into their game.
Does anyone have any help on this?
Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional
-
Aug 27th, 2000, 07:18 PM
#2
Not sure if this'll work, but try it.
Code:
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
'JobtoDo - Program to run
'frm - Form
'You can do anything after the loop.
'Anything after the loop is trigger when the program is unloaded.
Sub ShellProcess(ByVal JobToDo As String, frm As Form)
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
'Disable it here
'frm.Timer1.Enabled = False
'Sleep command recommended as well as DoEvents
DoEvents: Sleep 100
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE'
'Enable it here
'frm.Timer1.Enabled = True
End Sub
Usage:
Private Sub Command1_Click()
Call ShellProcess("C:\Game\Game.exe", Me)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|