Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Int32
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" ( _
ByVal hWnd1 As Int32, _
ByVal hWnd2 As Int32, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) _
As Int32
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Int32, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) _
As Int32
Public Function GetDesktopIconsCount()
Dim LVWHandle As Int32
'Handle zum Hauptprogramm finden
LVWHandle = FindWindow(vbNullString, "Program Manager")
'Handle zum Desktop Fenster ermitteln
LVWHandle = FindWindowEx(LVWHandle, 0, "shelldll_defview", vbNullString)
'Handle zur Desktop ListView ermitteln
LVWHandle = FindWindowEx(LVWHandle, 0, "SysListView32", vbNullString)
Return SendMessage(LVWHandle, 4100, 0, 0)
End Function