Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created December 31, 2015 08:28
Show Gist options
  • Save kumatti1/b76b7fe81cc86efee82b to your computer and use it in GitHub Desktop.
Save kumatti1/b76b7fe81cc86efee82b to your computer and use it in GitHub Desktop.
エクスプローラ起動
Option Explicit
Private Declare PtrSafe Function ILCreateFromPathW Lib "Shell32.dll" (ByVal pszPath As LongPtr) As Long
Private Declare PtrSafe Function SHGetIDispatchForFolder Lib "shdocvw.dll" (ByVal pidl As Long, arg2 As Any) As Long
Private Declare PtrSafe Sub ILFree Lib "Shell32.dll" (ByVal pidl As Long)
Private Declare PtrSafe Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As LongPtr, ByVal nFolder As Long, ppidl As Any) As Long
Const CSIDL_PERSONAL = &H5
Sub hoge()
Dim pidl&, hr&
'pidl = ILCreateFromPathW(StrPtr("C:\"))
SHGetSpecialFolderLocation 0, CSIDL_PERSONAL, pidl
Dim o As Object
hr = SHGetIDispatchForFolder(pidl, o)
Debug.Print TypeName(o), hr
ILFree pidl
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment