home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
PASM.LZH
/
PROFILE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-26
|
1KB
|
60 lines
#include <string.h>
#include <dos.h>
#include "profile.h"
Profile::Profile(const char *profileName)
{
if (profileName[0] == '+') {
strcpy(ProfileName, _argv[0]);
char *p = strrchr(ProfileName, '\\');
if (p == NULL) {
p = ProfileName;
} else {
p++;
}
strcpy(p, profileName+1);
} else {
lstrcpy(ProfileName, profileName);
}
}
void Profile::SetSection(const char *section)
{
lstrcpy(Section, section);
}
BOOL Profile::DelSection(const char *section)
{
return ::WritePrivateProfileString(section, NULL, NULL, ProfileName);
}
BOOL Profile::PutString(const char *entry, const char *value)
{
return ::WritePrivateProfileString(Section, entry, value, ProfileName);
}
BOOL Profile::PutInt(const char *entry, int value)
{
char temp[16];
wsprintf(temp, "%d", value);
return PutString(entry, temp);
}
string Profile::GetString(const char *entry, const char *Default)
{
if (Default == NULL) {
Default = "";
}
char temp[_MAX_PATH];
::GetPrivateProfileString(Section, entry, Default, temp, sizeof(temp),ProfileName);
return string(temp);
}
int Profile::GetInt(const char *entry, int Default)
{
return ::GetPrivateProfileInt(Section, entry, Default, ProfileName);
}