Windows未公开函数揭密(3)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 gnuljf 的 blog

windows未公开函数揭密


   '根据一个特定文件夹对象的id获得它的目录pidl
public function getpidlfromfolderid(howner as long, nfolder as shspecialfolderids) as long
dim pidl as long
if shgetspecialfolderlocation(howner, nfolder, pidl) = noerror then
getpidlfromfolderid = pidl
end if
end function
public function getdisplaynamefrompidl(pidl as long) as string
dim sfib as shfileinfobyte
if shgetfileinfopidl(pidl, 0, sfib, len(sfib), shgfi_pidl or shgfi_displayname) then
getdisplaynamefrompidl = getstrfrombuffera(strconv(sfib.szdisplayname, vbunicode))
end if
end function
public function getpathfrompidl(pidl as long) as string
dim spath as string * max_path
if shgetpathfromidlist(pidl, spath) then
getpathfrompidl = getstrfrombuffera(spath)
end if
end function
public function getstrfrombuffera(sz as string) as string
if instr(sz, vbnullchar) then
getstrfrombuffera = left$(sz, instr(sz, vbnullchar) - 1)
else
getstrfrombuffera = sz
end if
end function
在mshell.bas中加入以下代码:
'mshell.bas函数包含注册和反注册系统通告以及文件夹信息转换的函数
option explicit
private m_hshnotify as long
'系统消息通告句柄
private m_pidldesktop as long
'定义系统通告的消息值
public const wm_shnotify = &h401
public type pidlstruct
pidl as long
bwatchsubfolders as long
end type
declare function shchangenotifyregister lib ″shell32″ alias ″#2″ _
(byval hwnd as long, _
byval uflags as shcn_itemflags, _
byval dweventid as shcn_eventids, _
byval umsg as long, _
byval citems as long, _
lpps as pidlstruct) as long
type shnotifystruct
dwitem1 as long
dwitem2 as long
end type
declare function shchangenotifyderegister lib ″shell32″ alias ″#4″ _
(byval hnotify as long) as boolean
declare sub shchangenotify lib ″shell32″ _
(byval weventid as shcn_eventids,
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, ne_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 shchange notify deregister(m_h shnotify) then
m_hshnotify = 0
call cotaskmemfree(m_pidldesktop)
m_pidldesktop = 0
shnotify_unregister = true
end if
end if
end function
public function shnotify_geteventstr(strpath1, strpath2 as string, dweventid as long) as string
dim sevent as string
select case dweventid
case shcne_renameitem: sevent =
″重命名文件″ + strpath1 + ″为″ + strpath2
case shcne_create: sevent = ″建立文件 文件名:″ + strpath1
case shcne_delete: sevent = ″删除文件 文件名:″ + strpath1
case shcne_mkdir: sevent = ″新建目录 目录名:″ + strpath1
case shcne_rmdir: sevent = ″删除目录 目录名:″ + strpath1
case shcne_mediainserted: sevent = strpath1 + ″中插入可移动存储介质″
case shcne_mediaremoved: sevent = strpath1 + ″中移去可移动存储介质″
case shcne_driveremoved: sevent = ″移去驱动器″ + strpath1
case shcne_driveadd: sevent = ″添加驱动器″ + strpath1
case shcne_netshare: sevent = ″改变目录″ + strpath1 + ″的共享属性″
case shcne_updatedir: sevent = ″更新目录″ + strpath1
case shcne_updateitem: sevent = ″更新文件 文件名:″ + strpath1
case shcne_serverdisconnect: sevent = ″断开与服务器的连″ + strpath1 + ″ ″ + strpath2
case shcne_updateimage: sevent = ″shcne_updateimage″

本文关键:Windows未公开函数揭密
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top