Consulting

Results 1 to 7 of 7

Thread: Need 64 bit Compile Check Please

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,354
    Location

    Need 64 bit Compile Check Please

    Looking for someone with Office 64 bit installed who would check the following code for compile error. Thank you.

    Option Explicit
    #If Win64 Then
    Public Declare PtrSafe Function SHGetSpecialFolderLocation _
                             Lib "shell32" (ByVal hwnd As LongPtr, _
                                            ByVal nFolder As Long, ppidl As ITEMIDLIST) As LongPtr
    Public Declare PtrSafe Function SHGetPathFromIDList _
                             Lib "shell32" Alias "SHGetPathFromIDListA" _
                                 (ByVal pidl As LongPtr, ByVal pszPath As String) As Long
    Public Declare PtrSafe Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
    #Else
    Public Declare Function SHGetSpecialFolderLocation _
                             Lib "shell32" (ByVal hwnd As Long, _
                                            ByVal nFolder As Long, ppidl As Long) As Long
    Public Declare Function SHGetPathFromIDList _
                             Lib "shell32" Alias "SHGetPathFromIDListA" _
                                 (ByVal pidl As Long, ByVal pszPath As String) As Long
    Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
    #End If
    
    Private Type ****EMID
      cb As Long
      abID As Byte
    End Type
    
    Private Type ITEMIDLIST
      mkid As ****EMID
    End Type
    
    Public Const CSIDL_WINDOWS = &H24
    Public Const CSIDL_MYPICTURES = &H27
    Public Const CSIDL_PERSONAL = &H5
    Public Const MAX_PATH = 260
    Public Const NOERROR = 0
    
    Public Function SpecFolder(ByVal lngFolder As Long) As String
    Dim lngPidlFound As Long
    Dim lngFolderFound As Long
    Dim lngPidl As Long
    Dim strPath As String
    
      strPath = Space(MAX_PATH)
      lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
    
      If lngPidlFound = NOERROR Then
          lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
          If lngFolderFound Then
              SpecFolder = Left$(strPath, InStr(1, strPath, vbNullChar) - 1)
          End If
      End If
    
      CoTaskMemFree lngPidl
    lbl_Exit:
      Exit Function
    End Function
    
    Sub Test()
     MsgBox SpecFolder(CSIDL_WINDOWS)
    End Sub
    Last edited by SamT; 05-03-2018 at 11:50 AM.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •