تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] تعديل في الكود
#5
السلام عليكم، الكود التالي يقوم بجلب عناوين جميع القوائم (ليس القائمة الأساسية من كل تطبيق فقط) ثم مطابقة عناوينها مع قائمة أخرى من الكلمات و إذا تطابقت يغلق التطبيق الذي به هذه النافذة (طبعاً الكود يعمل عند الضغط على الزر Button1)

PHP كود :
Imports System.Runtime.InteropServices

Public Class Form1

    
<DllImport("user32.dll"EntryPoint:="GetWindowText")> _
    
Private Shared Function GetWindowText(ByVal hwnd As IntPtrByVal lpString As System.Text.StringBuilderByVal cch As Int32) As Int32
    End 
Function

    <
DllImport("user32.dll"EntryPoint:="GetWindowTextLength")> _
    
Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Int32
    End 
Function

    <
DllImport("user32.dll"EntryPoint:="EnumWindows")> _
    
Private Shared Function EnumWindows(ByVal Adress As CallBackByVal lParam As Integer) As Integer
    End 
Function

    <
DllImport("user32.dll"EntryPoint:="GetWindowThreadProcessId")> _
    
Private Shared Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, <Out()> ByRef lpdwProcessId As UInteger) As UInteger
    End 
Function

    Private 
Delegate Function CallBack(ByVal hWnd As IntPtrByVal lParam As Integer) As Boolean

    
Private Function Enumerator(ByVal hWnd As IntPtrByVal lParam As Integer) As Boolean
        windowTexts
.Add(hWndGetText(hWnd))
        Return 
True
    End 
Function

    Private Function 
GetText(ByVal handle As IntPtr) As String
        
If handle.ToInt32() <= 0 Then Return Nothing : Exit Function
        
Dim length As Integer GetWindowTextLength(handle)
        If 
length 0 Then Return String.Empty : Exit Function
        
Dim SB As New System.Text.StringBuilder(length 1)
        
GetWindowText(handleSBSB.Capacity)
        Return 
SB.ToString()
    
End Function

    Private 
Sub RefreshWindowTexts()
        
windowTexts.Clear()
        
EnumWindows(AddressOf EnumeratorNothing)
    
End Sub

    
Private windowTexts As New Dictionary(Of IntPtrString)

    Private 
Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        Dim forbiddenWords 
As New List(Of String)({"facebook""yahoo"})
        
RefreshWindowTexts()
        
Dim keys As IntPtr() = New IntPtr(windowTexts.Keys.Count 1) {}
        
windowTexts.Keys.CopyTo(keys0)
        For 
Each ptr As IntPtr In keys
            
For As Integer 0 To forbiddenWords.Count 1
                
If windowTexts(ptr).ToLower().Contains(forbiddenWords(I).ToLower()) Then
                    Dim pid 
As Integer 0
                    GetWindowThreadProcessId
(ptrpid)
                    
Process.GetProcessById(pid).Kill()
                
End If
            
Next
        Next
    End Sub
End 
Class 
الرد }}}
تم الشكر بواسطة: سعود , m0075 , الشاكي لله


الردود في هذا الموضوع
تعديل في الكود - بواسطة m0075 - 28-12-13, 08:10 AM
RE: تعديل في الكود - بواسطة الشاكي لله - 28-12-13, 09:32 AM
RE: تعديل في الكود - بواسطة m0075 - 28-12-13, 10:24 AM
RE: تعديل في الكود - بواسطة الشاكي لله - 28-12-13, 10:50 AM
RE: تعديل في الكود - بواسطة Aly El-Haddad - 29-12-13, 12:50 AM
RE: تعديل في الكود - بواسطة m0075 - 29-12-13, 04:48 PM
RE: تعديل في الكود - بواسطة m0075 - 29-12-13, 07:52 PM
RE: تعديل في الكود - بواسطة Aly El-Haddad - 29-12-13, 09:34 PM
RE: تعديل في الكود - بواسطة m0075 - 29-12-13, 09:46 PM


التنقل السريع :


يقوم بقرائة الموضوع: