Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created March 28, 2014 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/9828829 to your computer and use it in GitHub Desktop.
Save kumatti1/9828829 to your computer and use it in GitHub Desktop.
エクスプローラ検索
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