Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determining Documents and Settings path programatically (VB6)

4 views
Skip to first unread message

Scott M. Lyon

unread,
Jun 15, 2005, 8:46:06 AM6/15/05
to
I am working on an older VB6 application, and I need to modify it to
reference an XML configuration file (instead of an old Access database
storing the same data).


The problem: the data file will be located under the user's "Documents and
Settings" folder (Windows 2000 or XP), at the following level:

Documents and Settings\username\Application Data\companyname\appname\app.xml


The problem, is that I cannot hard-code it, due to the facts that:

1) I may not be sure of the username
2) The "Documents and Settings" folder might be on the C: drive, or it might
be on the D: drive (the new policy is that new computers will have it on D:,
but we have to support the older ones with it still on C:).


Is there a way, in VB6, that I can determine the above folder (or at least
enough of it that I can hard-code and/or build the rest)?


Thanks!


Steven Burn

unread,
Jun 15, 2005, 8:53:08 AM6/15/05
to
Use the %appdata% variable

E.g.

%appdata%\companyname\appname\app.xml

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Scott M. Lyon" <scott.RED....@rapistan.BLUE.com> wrote in message news:#81r1gac...@TK2MSFTNGP12.phx.gbl...

JoeO

unread,
Jun 15, 2005, 8:59:12 AM6/15/05
to
INI file located in App.Path can do the job. App loads and reads Path saved
in INI and then looks for XML file in path indicated in the INI file. Check
WritePrivateProfileString and GetPrivateProfileString
Also you may want to save the path in the registery.

"Scott M. Lyon" <scott.RED....@rapistan.BLUE.com> wrote in message

news:%2381r1ga...@TK2MSFTNGP12.phx.gbl...

95isalive

unread,
Jun 15, 2005, 9:33:02 AM6/15/05
to
Have you tried:

%UserProfile%\Application Data\companyname\appname\app.xml

--
Steve
95isalive
This site is best viewed..................
..............................with a computer

"Scott M. Lyon" <scott.RED....@rapistan.BLUE.com> wrote in message
news:%2381r1ga...@TK2MSFTNGP12.phx.gbl...

Ken Halter

unread,
Jun 15, 2005, 10:46:36 AM6/15/05
to
"Scott M. Lyon" <scott.RED....@rapistan.BLUE.com> wrote in message
news:%2381r1ga...@TK2MSFTNGP12.phx.gbl...
>
>
> The problem: the data file will be located under the user's "Documents and
> Settings" folder (Windows 2000 or XP), at the following level:
>
> Documents and Settings\username\Application
> Data\companyname\appname\app.xml
>
>
> Is there a way, in VB6, that I can determine the above folder (or at least
> enough of it that I can hard-code and/or build the rest)?
>

This API will help you determine quite a few "popular shell folders". You
should be able to find just about any "user specific" folder with this
sample...

Using SHGetFolderPath to Find Popular Shell Folders
http://vbnet.mvps.org/index.html?code/browse/csidl.htm

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..


0 new messages