|
-
September 13th, 2001, 05:49 PM
#1
How to lock up application
Hi, I'm a newie programer in Visual Basic. I need a my application are lock up when past any time like 20', How to I'll for this.
Thank in advance, and sorry but my english is no good.
Hjagar
-
September 13th, 2001, 11:57 PM
#2
Re: How to lock up application
Hello,
Paste this on a vb form with a timer and textbox control.Give your program name as value of text1.text.Set the timer to the required interval and run the program (or execute the program when u need it to run).
Nived
Private Declare Function GetForegroundWindow Lib "user32" _
() As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal _
hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x _
As Long, ByVal y As Long, ByVal cx As Long, ByVal cy _
As Long, ByVal wFlags As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Timer1_Timer()
Dim lWindowHWnd As Long
Dim sBuffer As String
Dim a
sBuffer = Space(255)
lWindowHWnd = GetForegroundWindow()
GetWindowText lWindowHWnd, sBuffer, Len(sBuffer)
a = Trim(sBuffer)
Text1.Text = a
'change the following line as per your requirments
If Text1.Text = "Program Name" Then
SetWindowPos Me.hwnd, -1, Me.CurrentX, Me.CurrentY, 483, 441, &H40
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
Form1.Visible = True
Timer2.Enabled = True
Dim closeall As Long
closeall = FindWindow(vbNullString, Text1.Text)
PostMessage closeall, WM_CLOSE, CLng(0), CLng(0)
End If
End Sub
Private Sub Timer2_Timer()
SetWindowPos Me.hwnd, 1, Me.CurrentX, Me.CurrentY, 480, 450, &H40
Form1.Visible = False
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
|