🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16500

Re: CreateDirectory

#16500
From: user
Date: Sun, 11 May 2003 14:50
45 lines
3038 bytes
CapStick wrote:
> I have reached the stage in My Application
> where i need to create a directory
> to hold users data.
> Is there a set format for how this should be done
> in relation to my .EXE
> 
> for example should i create a directory at root as say C:/mynewdirectory
> 
> or should my directory be created as say
> C:/Myapp/mynew directory
> 
> I would also Like To Password Protect this Directory
> and some or all of its contained files.
> 
> Also one more thing theres the question of running my app on different
> Versions Platforms Etc..
> Any Pointers Would be Appreciated
> Big Thanks In advance.
> 
A lot depends on how many versions and platforms you need to support. If 
you can limit it to Windows since NT4/95, those operating systems define 
system directories especially for this purpose.

You call SHGetFolderPath to get system folder locations at run time. For 
your purposes, the CSIDLs of interest are CSIDL_APPDATA, to get a folder 
specific to the current user, or CSIDL_COMMON_APPDATA, to get a folder 
that is shared by all users. (These folders are usually C:\Documents and 
Settings\username\Application Data and C:\Documents and Settings\All 
Users\Application Data, but you shouldn't assume they will be on every 
computer.)

For data that is private to each user, you'd get the CSIDL_APPDATA 
folder, probably create a subfolder for your application in it, and put 
the data files in there. If you have any data files that should be 
shared among all users, you can put them in a folder in the 
CSIDL_COMMON_APPDATA directory.

If you use these folders, you don't really have to take any further 
security measures. The common folder is of course accessible by anyone, 
but if the system is set up for multi-user use or if is on a network, 
the user folder should be secured by the operating system. Since the 
folders will only be accessible by the logged on user, your files will 
be safe, too. (And if the user has chosen to run an unsecured system, 
that's their business, isn't it?)
Technical Details
Message-ID: <3EBE6347.3070408@domain.invalid>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ebe1bab@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,603622406bfaac23
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-11 07:56:05 PST
Message-ID: <3EBE6347.3070408@domain.invalid>
Date: Sun, 11 May 2003 10:50:47 -0400
From:  user@domain.invalid
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: CreateDirectory
References: <3ebe1bab@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 151.201.32.85
X-Trace: newsgroups.borland.com 1052664670 151.201.32.85 (11 May 2003 07:51:10 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail