مدير المهام بالفيحول بيسك 6
كيفية عمل مدير المهام بالفيجوال بيسك 6
how to make task manager
By visual basic 6
اولا - افتح مشروع جديد
ثانيا - اضف الادوات
3- ازرار command
1- قائمة list
ثالثا - اجهز لوضع الاكواد
بالنسبة لحدث الفورم لود form_load
Private Sub Form_Load()
command1.Caption ="تحديث العمليات"
command3.Caption ="انهاء عملية"
command3.Caption ="انهاء البرنامج"
Command1_Click
me.Caption ="برنامج ادارة المهام"
End Sub
شرح الكود السابق
الزرار الاول
command1.Caption ="تحديث العمليات"
تسمية الزرار
والثانى والثالث ايضا تسنمية
commannd1_click
تنفيذ الكود الموجود فى الزرار الاول
me.Caption ="برنامج ادارة المهام"
تسمية الفورم
فى حدث الكليك للكومند 1
Private Sub Command1_Click()
List1.Clear
Select Case getVersion()
Case 1 'Windows 95/98
Dim f As Long, sname As String
Dim hSnap As Long, proc As PROCESSENTRY32
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If hSnap = hNull Then Exit Sub
proc.dwSize = Len(proc)
' Iterate through the processes
f = Process32First(hSnap, proc)
Do While f
sname = StrZToStr(proc.szExeFile)
List1.AddItem sname
f = Process32Next(hSnap, proc)
Loop
Case 2 'Windows NT
Dim cb As Long
Dim cbNeeded As Long
Dim NumElements As Long
Dim ProcessIDs() As Long
Dim cbNeeded2 As Long
Dim NumElements2 As Long
Dim Modules(1 To 200) As Long
Dim lRet As Long
Dim ModuleName As String
Dim nSize As Long
Dim hProcess As Long
Dim i As Long
'Get the array containing the process id's for each process object
cb = 8
cbNeeded = 96
Do While cb <= cbNeeded
cb = cb * 2
ReDim ProcessIDs(cb / 4) As Long
lRet = EnumProcesses(ProcessIDs(1), cb, cbNeeded)
Loop
NumElements = cbNeeded / 4
For i = 1 To NumElements
'Get a handle to the Process
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION _
Or PROCESS_VM_READ, 0, ProcessIDs(i))
'Got a Process handle
If hProcess <> 0 Then
'Get an array of the module handles for the specified
'process
lRet = EnumProcessModules(hProcess, Modules(1), 200, _
cbNeeded2)
'If the Module Array is retrieved, Get the ModuleFileName
If lRet <> 0 Then
ModuleName = Space(MAX_PATH)
nSize = 500
lRet = GetModuleFileNameExA(hProcess, Modules(1), _
ModuleName, nSize)
List1.AddItem Left(ModuleName, lRet)
ReDim Preserve TheProcessesIDs(List1.ListCount) As Long
TheProcessesIDs(List1.ListCount - 1) = ProcessIDs(i)
End If
End If
'Close the handle to the process
lRet = CloseHandle(hProcess)
Next
End Select
End Sub
فى الكومند 2
Private Sub Command2_Click()
Dim hProcess As Long
If List1.ListIndex > -1 Then
hProcess = OpenProcess(PROCESS_TERMINATE, 0, TheProcessesIDs(List1.ListIndex))
'Got a Process handle
If hProcess <> 0 Then
If MsgBox("هنا تضع رسالة هل انت متأكد" + vbCrLf + "", vbExclamation + vbYesNoCancel + vbSystemModal, "هنا اسم البرنامج") = vbYes Then
TerminateProcess hProcess, 0
'refresh list
Command1_Click
End If
'Close the handle to the process
CloseHandle hProcess
Else
MsgBox "Error can't open process", , ":("
End If
End If
End Sub
فى الكومند 3
Private Sub Command3_Click()
Unload Me
End
End Sub
الان قم يتجربة برنامجك
شكرا لمتابعتكم
تعليقات
إرسال تعليق