P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Dec 29th, 2003 06:51 PM Post subject: Find the path of the Cookies folder |
|
|
| Code: | Option Explicit
Const CSIDL_COOKIES As Long = &H21
Private Const ERROR_SUCCESS = 0&
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
Public Function GetSpecialFolder(hwnd As Long, CSIDL As Long) As String
Dim pidl As Long
Dim Pos As Long
Dim sPath As String
If SHGetSpecialFolderLocation(hwnd, CSIDL, pidl) = ERROR_SUCCESS Then
sPath = Space$(260)
If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then
Pos = InStr(sPath, Chr$(0))
If Pos Then
GetSpecialFolder = Left$(sPath, Pos - 1)
End If
Call CoTaskMemFree(pidl)
End If
End If
End Function
Private Sub Form_Load()
Dim strStartUpFolder As String
strStartUpFolder = GetSpecialFolder(Me.hwnd, CSIDL_COOKIES)
MsgBox strStartUpFolder
End Sub |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|