473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Special Folders in VB 2005

DCC
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
Mar 29 '06 #1
3 4287
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?


No, use System.Environment.GetFolderPath if the foilder you want is in
the SpecialFolder enumeration.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 30 '06 #2
DCC

Thanks for the response! I'll attempt to impliment the method you suggested.

Question though: The list of CSIDLs seems much more extensive than what's
exposed by System.Environment.GetFolderPath. Although many of the values
don't seem useful at this point, how would I go about handling CSIDLs if I
needed a value that's not available through System.Environment.GetFolderPath?

"Mattias Sjögren" wrote:
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?


No, use System.Environment.GetFolderPath if the foilder you want is in
the SpecialFolder enumeration.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Mar 30 '06 #3
>how would I go about handling CSIDLs if I
needed a value that's not available through System.Environment.GetFolderPath?


Then you're back to using functions like SHGetFolderPath. If you want
to do so, you must correct your declarations. The ones you posted were
probably written for VB6 and wont work in VB.NET. Try to find correct
ones at www.pinvoke.net.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Howard | last post by:
Hello all. On a file or folder object in Windows 2000/2003, it is possible to edit the standard Change, RW etc permissions and give "special" permissions. These special permissions do things...
0
by: Diane Blevins | last post by:
sFt ----HUISORc8AeipkQw2ckY Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html> <head> <style type=3D"text/css">.eyebrow { FONT-WEIGHT: bold; FONT-SIZE: 10px; TE=
2
by: Bob Hanson | last post by:
Hello All, I noticed in the ASP.NET beta 2 that we have more special folders. Can I get some clarification regarding these folders? I am just making sure of the intent. Thanks in advance, ...
1
by: Jim Haynes | last post by:
Does anyone know of a simple way to retrieve WITH CODE the path to special folders such as the 'My Documents' or 'Application Data' folders. I can do it with api calls using sffolder, etc but I...
12
by: Quemasda | last post by:
Hi, The application I'm working on should set the Special Folders (Favorites, My Documents, ...) but I can't find the way to do it. So far, I've been able to get the path of those Special...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
12
by: wheels619 | last post by:
How can I get access for another user's special folder locations? A configuration file is stored in the users' appData folder and the program altering it will be ran under the admin.
5
by: rogersw8n | last post by:
Some how, some way the account that creates folders under Temporary Internet files has been changed to a domain account for VS 2003 and VS 2005. I recently installed VS 2005. All seemed to be ok...
1
by: John Bailo | last post by:
* Using VS.NET 2005, c#, ASP.NET 2.0 I downloaded some source code for an ASP.net web site. The site has code in folders and subfolders. There were no solution or project files. I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.