Begin VB.Form Form1
Caption = "Key States"
ClientHeight = 825
ClientLeft = 60
ClientTop = 345
ClientWidth = 4440
LinkTopic = "Form1"
ScaleHeight = 825
ScaleWidth = 4440
StartUpPosition = 3 'Windows Default
Begin VB.Timer tmrKeyStates
Interval = 1000
Left = 0
Top = 0
End
Begin VB.TextBox Text3
Height = 375
Left = 3000
TabIndex = 2
Top = 240
Width = 1200
End
Begin VB.TextBox Text2
Height = 375
Left = 1680
TabIndex = 1
Top = 240
Width = 1200
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 1200
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetKeyState Lib _
"user32" (ByVal nVirtKey As Long) As Integer
Public Function CapsLockOn() As Boolean
Dim iKeyState As Integer
iKeyState = GetKeyState(vbKeyCapital)
CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function
Public Function NumLockOn() As Boolean
Dim iKeyState As Integer
iKeyState = GetKeyState(vbKeyNumlock)
NumLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function
Public Function ScrlLockOn() As Boolean
Dim iKeyState As Integer
iKeyState = GetKeyState(vbKeyScrollLock)
ScrlLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function
Private Sub Form_Load()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
End Sub
Private Sub tmrKeyStates_Timer()
If NumLockOn() Then
Text1.Text = ("NUM On")
Else
Text1.Text = ("NUM Off")
End If
If CapsLockOn() Then
Text2.Text = ("CAPS On")
Else
Text2.Text = ("CAPS Off")
End If
If ScrlLockOn() Then
Text3.Text = ("SCR On")
Else
Text3.Text = ("SCR Off")
End If
End Sub
قسمت General وارد کنید و بعد کد های مربوطه رو در یک دکمه قرار دهید و در جایی که نوشته
Pc Name نام کامپیوتر رو که می خواین خاموش بشه رو وارد کنید موفق باشید .
Api Code:
Private Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias _
"InitiateSystemShutdownA" (ByVal lpMachineName As String, ByVal lpMessage As _
String, ByVal dwTimeout As Long, ByVal bForceAppsClosed As Long _
, ByVal bRebootAfterShutdown As Long) As Long
Source Code:
ltimeout = 0
retval = InitiateSystemShutdown(Trim("PC Name"), "", ltimeout, True, True)
If retval <> 0 Then
MsgBox "PC Is Shutdown..."
End IF
Private Sub Command1_click()
Dim search as variant
sstr = InputBox("Enter Author to Search") ' Display a Input Box Window
data1.recordset.findfirst "Author='" & sstr & "'" ' Look for the record that has a value "sstr"
If trim(sstr) <> "" then
If data1.recordset.nomatch then 'check if the record exist
MsgBox "No record Exist"
Command1.setfocus
else
data1.recordsource = "SELECT * FROM TableName WHERE Author='" & sstr & "'" ' Display all the Records that has a Value of "sstr"
data1.refresh ' refresh the DBGRID or MSFLEXGRID
End if
End if
End Sub