byval uflags as shcn_itemflags, _
byval dwitem1 as long, _
byval dwitem2 as long)
public enum shcn_eventids
shcne_renameitem = &h1
shcne_create = &h2
shcne_delete = &h4
shcne_mkdir = &h8
shcne_rmdir = &h10
shcne_mediainserted = &h20
shcne_mediaremoved = &h40
shcne_driveremoved = &h80
shcne_driveadd = &h100
shcne_netshare = &h200
shcne_netunshare = &h400
shcne_attributes = &h800
shcne_updatedir = &h1000
shcne_updateitem = &h2000
shcne_serverdisconnect = &h4000
shcne_updateimage = &h8000&
shcne_driveaddgui = &h10000
shcne_renamefolder = &h20000
shcne_freespace = &h40000
shcne_assocchanged = &h8000000
shcne_diskevents = &h2381f
shcne_globalevents = &hc0581e0
shcne_allevents = &h7fffffff
shcne_interrupt = &h80000000
end enum
#if (win32_ie >= &h400) then
public const shcnee_orderchanged = &h2
#end if
public enum shcn_itemflags
shcnf_idlist = &h0
shcnf_patha = &h1
shcnf_printera = &h2
shcnf_dword = &h3
shcnf_pathw = &h5
shcnf_printerw = &h6
shcnf_type = &hff
shcnf_flush = &h1000
shcnf_flushnowait = &h2000
#if unicode then
shcnf_path = shcnf_pathw
shcnf_printer = shcnf_printerw
#else
shcnf_path = shcnf_patha
shcnf_printer = shcnf_printera
#end if
end enum
public function shnotify_register(hwnd as long) as boolean
dim ps as pidlstruct
if (m_hshnotify = 0) then
m_pidldesktop = getpidlfromfolderid(0, csidl_desktop)
if m_pidldesktop then
ps.pidl = m_pidldesktop
ps.bwatchsubfolders = true
'注册windows监视,将获得的句柄保存到m_hshnotify中
m_hshnotify = shchangenotifyregister(hwnd, shcnf_type or shcnf_idlist, _
shcne_allevents or shcne_interrupt, _
wm_shnotify, 1, ps)
shnotify_register = cbool(m_hshnotify)
else
call cotaskmemfree(m_pidldesktop)
end if
end if
end function
public function shnotify_unregister() as boolean
if m_hshnotify then
if shchangenotifyderegister(m_hshnotify) then
m_hshnotify = 0
call cotaskmemfree(m_pidldesktop)