Windows未公开函数揭密——之三[3]

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

本文简介:选择自 technofantasy 的 blog

                              byval uflags as shgfi_flags) as long

public type shfileinfo
    hicon as long
    iicon as long
    dwattributes as long
    szdisplayname as string * max_path
    sztypename as string * 80
end type

enum shgfi_flags
    shgfi_largeicon = &h0
    shgfi_smallicon = &h1
    shgfi_openicon = &h2
    shgfi_shelliconsize = &h4
    shgfi_pidl = &h8
    shgfi_usefileattributes = &h10
    shgfi_icon = &h100
    shgfi_displayname = &h200
    shgfi_typename = &h400
    shgfi_attributes = &h800
    shgfi_iconlocation = &h1000
    shgfi_exetype = &h2000
    shgfi_sysiconindex = &h4000
    shgfi_linkoverlay = &h8000
    shgfi_selected = &h10000
end enum

'根据一个特定文件夹对象的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, _

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

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

go top