Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where to store common data files 1

Status
Not open for further replies.
Oct 5, 1999
105
GB
Where is the best place to store common data files used by different programs on different windows platforms? For example, I have various Label size definitions which I need in various programs.

I used to just store in a folder under "my documents" but that path keeps changing, being in the root under win98, then somewhere in "documents and settings" with XP. With Vista this changed to "Users" and I haven't yet tried Win7.

Is there an API call that would help?
 
various Label size definitions
Is that a text file? PDF? Excel? Access MDB? Other?

Can you store it on the server (constant, unchanged location)?

Have fun.

---- Andy
 
These are either text (.INI) files or access files.

No, don't have network available.
 

Houw about: create a folder at

[tt]C:\MyFiles[/tt]

or any other folder name, and keep all what you need in there.

Have fun.

---- Andy
 
Thanks for the sugeestion.

I was going to do this, but I gather this is not recommended under Windows 7.
 
>that path keeps changing,
>Is there an API call that would help?


My Documents is what is known as a 'special folder'. You might like to think of it as a clever shortcut. And yes, there is a way of determining the correct phyical location to which it refers on each Microsoft OS (indeed you should never try and hardcode the physical location of this or any of the other special folders). However, we don't quite need to resort to the API.

All we need to realise is that the shell (Explorer) knows where to find My Documents - so add a Reference to Microsoft Shell Controls and Automation.

Then add the following public function (a version of which I first posted in this forum 7 or so years ago) to a module:
Code:
[blue]Public Function GetSpecialPath(vDir As ShellSpecialFolderConstants) As String
With New Shell32.Shell
    GetSpecialPath = .Namespace(vDir).Self.Path
End With
End Function[/blue]

All you need to know now is that the ShelllSpecialFolderConstant that references My Documents is ssfPersonal (you can use the object browser in the IDE to examine all the constants included in the library) - so we can test this:

MsgBox GetSpecialPath(ssfPersonal)

Note that this will get the corrrect folder no matter what version of Windows you are running (XP/2000 and later), and no matter what language ...
 
But don't put application junk in My Documents, that folder is the user's playground (thus the name).

ssfCommonAppData is a better choice, though you're supposed to have your installer create a subfolder under it, then set the security on it so logged in users all have read/write access when required (for example an MDB file).


You also don't want to use early binding. The Shell32 ActiveX interface broke binary compatibility at Vista SP2 or Windows 7 (I forget which). An application compiled on one OS will then fail on the others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top