Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created September 13, 2012 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/3718117 to your computer and use it in GitHub Desktop.
Save kumatti1/3718117 to your computer and use it in GitHub Desktop.
起動済みExplorerの検索
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&)
Sub hoge()
Dim IE As Object
Dim tmp&, pidl&, v, strPath$
Dim Size&
Dim byt() As Byte
strPath = "C:\"
pidl = ILCreateFromPathW(StrPtr(strPath))
Size = ILGetSize(pidl)
ReDim byt(0 To Size - 1)
MoveMemory byt(0), ByVal pidl, Size
v = byt
'SWC_EXPLORER = 0x0,
'SWC_BROWSER = 0x00000001,
'SWFO_NEEDDISPATCH = 0x00000001,
Set IE = CreateObject("Shell.Application").Windows.findwindowSW(v, Empty, 1&, tmp, 1&)
Debug.Print Not IE Is Nothing
ILFree pidl
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment