在请求其成员获取图标后,我使用下面的代码获得指向SysListView32桌面的指针:import ctypes
def GetDesktopListViewHandle():
import ctypes
FindWindow = ctypes.windll.user32.FindWindowW
GetWindow = ctypes.windll.user32.GetWindow
def GetClassName(hwnd):
buff = ctypes.create_unicode_buffer(100)
ctypes.windll.user32.GetClassNameW(hwnd, buff, 99)
return buff.value
from win32con import GW_CHILD
hwnd = FindWindow('Progman', None)
hwnd = GetWindow(hwnd, GW_CHILD) # SHELLDLL_DefView
hwnd = GetWindow(hwnd, GW_CHILD) # SysListView32
if GetClassName(hwnd) != 'SysListView32':
return 0
return hwnd
def ListView_GetItemCount(hwnd):
import commctrl
import ctypes
SendMessage = ctypes.windll.user32.SendMessageW
return SendMessage(hwnd, commctrl.LVM_GETITEMCOUNT, 0, 0)