Created
March 15, 2017 03:16
-
-
Save kumatti1/17d661cd6f928d7874ae7b925da592e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Private Declare PtrSafe _ | |
Function SHGetDesktopFolder Lib "Shell32.dll" ( _ | |
ByRef ppshf As IUnknown) As Long | |
Private Declare PtrSafe _ | |
Function SHInvokeDefaultCommand Lib "shlwapi.dll" Alias "#279" ( _ | |
ByVal hWnd As LongPtr, _ | |
ByVal lpFolder As IUnknown, _ | |
ByVal lpApidl As Long) _ | |
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 unk As IUnknown 'IShellFolder | |
Dim pidl&, hr& | |
SHGetSpecialFolderLocation 0, CSIDL_PERSONAL, pidl | |
hr = SHGetDesktopFolder(unk) | |
hr = SHInvokeDefaultCommand(0, unk, pidl) | |
Debug.Print Hex$(hr) | |
ILFree pidl | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment