Okay, I have the following code:
The bolded line does return the correct string, because I have debug.printed the line.
However, if i use the following code in place of it:
If CBool(sBuild.ToString.IndexOf("ico")) = False Then
EnumChildWindows(CType(hwnd, IntPtr), proc, IntPtr.Zero)
End If
Doesnt make sense, works, but id like a logical way to do it
Thanks
VB.NET:
Option Strict On
Option Explicit On
Imports System.Text
Public Class Form1
Delegate Function EnumWindProc( _
ByVal hWnd As Int32, _
ByVal lParam As Int32) As Boolean
Delegate Function EnumChildWindProc( _
ByVal hWnd As Int32, _
ByVal lParam As Int32) As Boolean
Declare Function EnumWindows Lib "user32.dll" ( _
ByVal lpEnumProc As EnumWindProc, _
ByVal lParam As Int32) As Boolean
Declare Function EnumChildWindows Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal lpEnumFunc As EnumWindProc, _
ByRef lParam As IntPtr) As Int32
Dim sBuild As New StringBuilder(255)
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hwnd As Int32, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Int32) As Int32
Private Function EnumChild(ByVal hWnd As Int32, ByVal lParam As Int32) As Boolean
GetClassName(hWnd, sBuild, sBuild.Capacity)
Debug.Print(sBuild.ToString)
EnumChild = True
End Function
Private Function EnumWins(ByVal hwnd As Int32, ByVal lParam As Int32) As Boolean
Dim proc As New EnumWindProc(AddressOf EnumChild)
GetClassName(hwnd, sBuild, sBuild.Capacity).ToString()
[B] If sBuild.ToString.IndexOf("ico") > 0 Then
EnumChildWindows(CType(hwnd, IntPtr), proc, IntPtr.Zero)
End If[/B]
EnumWins = True
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim proc As New EnumWindProc(AddressOf EnumWins)
EnumWindows(proc, 0)
End Sub
End Class
The bolded line does return the correct string, because I have debug.printed the line.
However, if i use the following code in place of it:
If CBool(sBuild.ToString.IndexOf("ico")) = False Then
EnumChildWindows(CType(hwnd, IntPtr), proc, IntPtr.Zero)
End If
Doesnt make sense, works, but id like a logical way to do it
Thanks