G
Guest
I need to resolve Windows special folders. From what I have read it would
seem that using CSIDL's and SHGetSpecialFolderPath and SHGetFolderPath was
the way to accomplish that in VB6 and VB.NET. Is this still the best method
in VB 2005? If so does anyone have a working example of how to declare and
call the functions?
I have tried declaring the functions as follows:
Private Declare Function SHGetFolderPath Lib "shell32.dll" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" _
Alias "SHGetSpecialFolderPathA" _
(ByVal hwndOwner As Long, ByVal pszPath As String, _
ByVal nFolder As Long, ByVal fCreate As Long) As Long
And then to get the name of a directory i tried calling the functions like
this:
dim lTmp as Long
lTmp = SHGetFolderPath(Me.Handle, CSIDL_FAVORITES, 0, SHGFP_TYPE_CURRENT,
sPath)
lTmp = SHGetSpecialFolderPath(Me.Handle, sPath, CSIDL_FAVORITES, 0)
But I get an error saying that "a call to PInvoke has unbalanced the stack"
Everything I have been able to find on help sites says that the first
argument to those functions should be Me.hWnd but VB 2005 doesnt seem to
recognize Me.hWnd so I tried Me.Handle because it recognizes that.
If this is not the right approach and there is a better way please let me
know.
Thanks
seem that using CSIDL's and SHGetSpecialFolderPath and SHGetFolderPath was
the way to accomplish that in VB6 and VB.NET. Is this still the best method
in VB 2005? If so does anyone have a working example of how to declare and
call the functions?
I have tried declaring the functions as follows:
Private Declare Function SHGetFolderPath Lib "shell32.dll" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" _
Alias "SHGetSpecialFolderPathA" _
(ByVal hwndOwner As Long, ByVal pszPath As String, _
ByVal nFolder As Long, ByVal fCreate As Long) As Long
And then to get the name of a directory i tried calling the functions like
this:
dim lTmp as Long
lTmp = SHGetFolderPath(Me.Handle, CSIDL_FAVORITES, 0, SHGFP_TYPE_CURRENT,
sPath)
lTmp = SHGetSpecialFolderPath(Me.Handle, sPath, CSIDL_FAVORITES, 0)
But I get an error saying that "a call to PInvoke has unbalanced the stack"
Everything I have been able to find on help sites says that the first
argument to those functions should be Me.hWnd but VB 2005 doesnt seem to
recognize Me.hWnd so I tried Me.Handle because it recognizes that.
If this is not the right approach and there is a better way please let me
know.
Thanks