Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created Mar 28, 2014
Embed
What would you like to do?
エクスプローラ検索
Option Explicit
Declare Function ILCreateFromPathW& Lib "Shell32.dll" (ByVal pszPath&)
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Declare Sub ILFree Lib "Shell32.dll" (ByVal pidl&)
Declare Function ILGetSize& Lib "Shell32.dll" (ByVal pidl&)
Private Declare _
Function InitVariantFromBuffer Lib "propsys.dll" ( _
ByVal pv As LongPtr, _
ByVal cb As Long, _
ByRef pvar As Variant _
) As Long
Sub test()
Dim IE As Object
Dim tmp&, pidl&, v, strPath$, hr&
strPath = "d:\"
pidl = ILCreateFromPathW(StrPtr(strPath))
hr = InitVariantFromBuffer(pidl, ILGetSize(pidl), v)
If hr <> 0 Then Exit Sub
Set IE = CreateObject("Shell.Application").Windows.findwindowSW(v, Empty, 1&, tmp, 1&)
Debug.Print IE Is Nothing, tmp
ILFree pidl
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment