Re: How to modify program files in Vista?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 06 Aug 2008 03:08:41 -0400
Your use of a .INI file which is kept in the same directory as your executable is
incorrect usage. You must change your program to store information in the My Documents or
AppData; it is completely inappropriate (and has always been incorrect) to store it in a
file kept in the same directory as the executable. Your program is incorrect and must be
fixed. Note that this behavior has *always* been incorrect, but due to the poor security
of earlier releases of Windows, you were able to get away with it. That is no longer
possible.
You can download my ShGetFolderPath Explorer from my MVP Tips site, which will give you
the following code:
For AppData
//----------------
// in stdafx.h
#define _WIN32_IE 0x500
#include <shlobj.h>
//-----------------
CString path;
LPTSTR p = path.GetBuffer(MAX_PATH);
HRESULT hr = ::SHGetFolderPath(CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, p);
if(SUCCEEDED(hr))
{ /* succeeded */
path.ReleaseBuffer();
...your code here
} /* succeeded */
else
{ /* failed */
path.ReleaseBuffer();
...failure code here
} /* failed */
and for My Documents
//----------------
// in stdafx.h
#define _WIN32_IE 0x500
#include <shlobj.h>
//-----------------
CString path;
LPTSTR p = path.GetBuffer(MAX_PATH);
HRESULT hr = ::SHGetFolderPath(CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, p);
if(SUCCEEDED(hr))
{ /* succeeded */
path.ReleaseBuffer();
...your code here
} /* succeeded */
else
{ /* failed */
path.ReleaseBuffer();
...failure code here
} /* failed */
You would then change the path used by your .INI file to use this path instead of the
executable path.
joe
On Wed, 6 Aug 2008 13:39:36 +0800, "fiveight" <fiveight@xxxxxxx> wrote:
Hi All:Joseph M. Newcomer [MVP]
I use vs2008 make a msi file of my program. When I install in
Vista(C:\program file\myproduct), the files in this folder can't be
modified. Only system and admin can modify these files. But there is an ini
file, every time my program should write something in this file use
WritePrivateProfileString function. I want to know how can I install my
program in Vista, and let my program can modify this ini file?
Thanks
Fiveight
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: How to modify program files in Vista?
- From: Daniel James
- Re: How to modify program files in Vista?
- References:
- How to modify program files in Vista?
- From: fiveight
- How to modify program files in Vista?
- Prev by Date: Re: CTreeCtrl and Checkboxes
- Next by Date: Love Potion for Miss Blandish
- Previous by thread: How to modify program files in Vista?
- Next by thread: Re: How to modify program files in Vista?
- Index(es):