home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / Profile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  2.2 KB  |  66 lines

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : profile.h                                                             //
  12. //  Description: .ini file API wrapper                                               //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KProfile
  17. {
  18.     TCHAR         sFileName[MAX_PATH];
  19.     const TCHAR * p;
  20.  
  21. public:
  22.     TCHAR         sLine[32768];
  23.  
  24.     KProfile(void)
  25.     {
  26.         sFileName[0] = 0;
  27.         sLine[0]     = 0;
  28.         p            = sLine;
  29.     }
  30.  
  31.     BOOL     SetFileName(HINSTANCE hInstance, const TCHAR *filename);
  32.  
  33.     int      ReadString(const TCHAR *sec, int no);
  34.     int      ReadString(const TCHAR *sec, const TCHAR * key);
  35.     int      ReadInt(const TCHAR *section, const TCHAR *key, int dflt) const;
  36.  
  37.     int      ReadSection(const TCHAR *sec)
  38.     {
  39.         sLine[0] = 0;
  40.         sLine[1] = 0;
  41.         p = sLine;
  42.  
  43.         return GetPrivateProfileSection(sec, sLine, sizeof(sLine)-2, sFileName);
  44.     }
  45.  
  46.     void     SkipLine(void)
  47.     {
  48.         while ( *p!=0 )
  49.             p ++;
  50.  
  51.         p++;
  52.     }
  53.  
  54.     BOOL     Write(const TCHAR *section, const TCHAR *key, int value) const;
  55.     BOOL     Write(const TCHAR *section, const TCHAR *key, const TCHAR *value) const;
  56.  
  57.     BOOL     ReadDelimiter(TCHAR ch);
  58.  
  59.     unsigned ReadHex(void);
  60.     unsigned ReadDec(void);
  61.     int      ReadIdentifier(TCHAR *rslt, int maxlength, TCHAR extra='_');
  62.     BOOL     ReadGuid(GUID & guid);
  63. };
  64.  
  65.  
  66.