Home > Archive > Visual Basic > March 2006 > Special Folders in VB 2005
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Special Folders in VB 2005
|
|
|
| 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
| |
| Ken Halter 2006-03-29, 6:56 pm |
| "DCC" <DCC@discussions.microsoft.com> wrote in message
news:B45CA649-08C4-4AB1-83BD-6F8658E7974E@microsoft.com...
>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, _
One problem is... a VB6 'Long' is a dotNet 'Integer' but, in the long
run,.....
You'll want to post that question in a .Net group.
They all contain "dotnet" or "vsnet" in their names.
This and all other groups on the MS server that start with
"microsoft.public.vb"
are for VB Classic (mostly VB5/6) and were in existance long before any .Net
products were released. While some of the code looks the same, they are very
different products and require a different set of groups.
Try one of these:
news://news.microsoft.com/microsoft....dotnet.general
news://news.microsoft.com/microsoft...et.languages.vb
news://news.microsoft.com/microsoft...ges.vb.controls
news://news.microsoft.com/microsoft...amework.interop
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
| |
|
|
"DCC" <DCC@discussions.microsoft.com> wrote in message
news:B45CA649-08C4-4AB1-83BD-6F8658E7974E@microsoft.com...
>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
>
As Ken said, you should be asking this in "dotnet" newsgroup, but in any
VB.NET version I've used, you've not needed to use these API functions. You
should be using GetFolderPath from System.Environment.
http://msdn.microsoft.com/library/d...br />
topic.asp
And just as an FYI, VB 2005 *is* VB.NET. Microsoft just dropped the .NET
from it to make everyone's lives more difficult.
--
Mike
Microsoft MVP Visual Basic
|
|
|
|
|