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 >
C/C++ Source or Header  |  1995-06-26  |  1KB  |  60 lines

  1. #include <string.h>
  2. #include <dos.h>
  3. #include "profile.h"
  4.  
  5. Profile::Profile(const char *profileName)
  6. {
  7.     if (profileName[0] == '+') {
  8.         strcpy(ProfileName, _argv[0]);
  9.         char *p = strrchr(ProfileName, '\\');
  10.         if (p == NULL) {
  11.             p = ProfileName;
  12.         } else {
  13.             p++;
  14.         }
  15.         strcpy(p, profileName+1);
  16.     } else {
  17.         lstrcpy(ProfileName, profileName);
  18.     }
  19. }
  20.  
  21. void Profile::SetSection(const char *section)
  22. {
  23.     lstrcpy(Section, section);
  24. }
  25.  
  26. BOOL Profile::DelSection(const char *section)
  27. {
  28.     return ::WritePrivateProfileString(section, NULL, NULL, ProfileName);
  29. }
  30.  
  31. BOOL Profile::PutString(const char *entry, const char *value)
  32. {
  33.     return ::WritePrivateProfileString(Section, entry, value, ProfileName);
  34. }
  35.  
  36. BOOL Profile::PutInt(const char *entry, int value)
  37. {
  38.     char temp[16];
  39.     wsprintf(temp, "%d", value);
  40.     return PutString(entry, temp);
  41. }
  42.  
  43.  
  44. string Profile::GetString(const char *entry, const char *Default)
  45. {
  46.     if (Default == NULL) {
  47.         Default = "";
  48.     }
  49.     char temp[_MAX_PATH];
  50.     ::GetPrivateProfileString(Section, entry, Default, temp, sizeof(temp),ProfileName);
  51.     return string(temp);
  52. }
  53.  
  54. int Profile::GetInt(const char *entry, int Default)
  55. {
  56.     return ::GetPrivateProfileInt(Section, entry, Default, ProfileName);
  57. }
  58.  
  59.  
  60.