16 : _buffer(NULL), _bufSize(0), _valSize(0), UserData(0)
    29     static CCSTR iniExt = _T(
".ini");
    37         if (dot) _tcscpy( dot, iniExt );
    47     bool ok = ((_bufSize >= Size) && (Size != 0));
    50         if (!Size) Size = MAX_PATH;
    52         ok = (newBuf != NULL);
    60     if (_buffer) _buffer[0] = 0;
    68     return GetPrivateProfileInt( Section, KeyName, Default, 
Filename );
    73     if (!_buffer) _valSize = 0;
    74     else _valSize = GetPrivateProfileString( Section, KeyName, Default, (
TSTR)_buffer, _bufSize, 
Filename ); 
    76     if (_valSize) 
_tcsncpyz( Buf, (
TSTR)_buffer, min_<UINT>( BufLen, (UINT)_valSize+1 ));
    77     if (_valSize == INT(_bufSize-1) || _valSize == INT(_bufSize-2) ) 
    84     if (!_buffer) _valSize = 0;
    85     else _valSize = GetPrivateProfileString( Section, KeyName, Default, (
TSTR)_buffer, _bufSize, 
Filename );
    87     if (_valSize == INT(_bufSize-1) || _valSize == INT(_bufSize-2) )
    89     if (Size) *Size = _valSize;
    90     return _valSize ? (
TSTR)_buffer : NULL;
    99         _valSize = GetPrivateProfileSection( Section, (
TSTR)_buffer, _bufSize, 
Filename );
   100         if (_valSize == INT(_bufSize - 2)) 
   102             _buffer[_valSize] = _buffer[_valSize+1] = 
_NUL; 
   103             _valSize = -_valSize;
   105         if (Size) *Size = _valSize;
   107     return (
TSTR)_buffer;
   114         _valSize = GetPrivateProfileSectionNames( (
TSTR)_buffer, _bufSize, 
Filename );
   115         if (_valSize == INT(_bufSize - 2))
   117             _buffer[_valSize] = _buffer[_valSize+1] = 
_NUL;
   118             _valSize = -_valSize;
   120         if (Size) *Size = _valSize;
   122     return (
TSTR)_buffer;
   127     BOOL ok = (_buffer != 0);
   128     if (ok) ok = (_bufSize >= cbData+1 );
   129     if (ok) ok = GetPrivateProfileStruct( Section, Key, _buffer, cbData, 
Filename );
   130     return ok ? _buffer : NULL;
   133 static BYTE __hexVal( TCHAR Ch )
   136     if (Ch <= _T(
'9')) val = Ch - _T(
'0');
   137     else val = 10 + (_totupper( Ch ) - _T(
'A'));
   140 static BYTE _hexVal( TCHAR* Src )
   142     BYTE hiVal = __hexVal( *Src );
   143     BYTE loVal = __hexVal( *(Src+1) );
   144     return (hiVal << 4) + loVal;
   151     if (size <= 0) 
return NULL;
   157         *dst = _hexVal( src );
   164     if (pSize) *pSize = size;
   167     for( INT i=0; i < size; ++i ) csum += _buffer[i];
   168     return (csum == _buffer[size]) ? _buffer : NULL;
   175     return WritePrivateProfileSection( Section, String, 
Filename );
   184 static UINT writeMultiSz( HANDLE hFile, 
CSTR pmSz )
   188     while( pEnd && *pEnd )
   191         pEnd = _tcschr( pEnd, 0 );
   208     static const TCHAR _SqBrkt  = _T(
'[');
   209     static const TCHAR _ESqBrkt = _T(
']');
   219         TSTR pSect = NULL, pNext = NULL;
   220         UINT nlen = (UINT)_tcslen( Section ); 
   222         UINT fsize = GetFileSize( hFile, NULL );
   231             if (
BlockRead( hFile, fbuf, fsize ) == fsize)
   239                     pTmp = _tcschr( pTmp, _SqBrkt );
   242                         if (_tcsnicmp( &pTmp[1], Section, nlen ) == 0)
   245                             TSTR pEnd = pTmp + (nlen+1);
   246                             if (*pEnd == _ESqBrkt)   
   249                                 pNext = _tcschr( pEnd, _SqBrkt ); 
   263         fpos = pSect ? UINT( 
PBYTE(pSect) - fbuf ) : fsize;
   264         SetFilePointer( hFile, fpos, NULL, FILE_BEGIN );
   266         WriteStr( hFile, _T(
"[%s]\r\n"), Section ); 
   267         nStr = writeMultiSz( hFile, MultiSz );      
   271             BlockWrite( hFile, (PVOID)_T(
"\r\n"), 2*
sizeof(TCHAR) ); 
   272             UINT nbytes = fsize - UINT( 
PBYTE(pNext) - fbuf ); 
   278         CloseHandle( hFile );
   288         case 10: fmt = _T(
"%li"); 
break;
   289         case 16: fmt = _T(
"0x%08X"); 
break;
   290         default: 
return FALSE;
   297     return WritePrivateProfileString( Section, KeyName, 
TSTR(Text), 
Filename );
   305     size_t dim = _bufSize/
sizeof(TCHAR); 
   306     _vstprintf_s( (
TSTR)_buffer, dim, Fmt, va );
   309     return WritePrivateProfileString( Section, KeyName, (
TSTR)_buffer, 
Filename );
   315     return WritePrivateProfileStruct( Section, Key, pStruct, Size, 
Filename );
   320     return WritePrivateProfileString( Section, KeyName, NULL, 
Filename );
   325     return WritePrivateProfileString( Section, NULL, NULL, 
Filename );
   332     BOOL ok = IsWindow( hWnd );
   335         RECT r; ok = GetWindowRect( hWnd, &r );
   336         if (ok) ok = 
WriteStruct( Section, Key, &r, 
sizeof(RECT) );
   344     BOOL ok = IsWindow( hWnd );
   347         PRECT pr = (PRECT) 
GetStruct( Section, Key, 
sizeof(RECT) );
   352             SIZE scrSiz = { 
SYSMET( CXSCREEN ), 
SYSMET( CYSCREEN ) };
   353             if ((pr->left < 0) || (pr->left > scrSiz.cx)) OffsetRect( pr, -pr->left, 0 );
   354             if ((pr->top < 0) || (pr->top > scrSiz.cy)) OffsetRect( pr, 0, -pr->top );
   357             ok = SetWindowPos( hWnd, NULL, pr->left, pr->top, pr->right, pr->bottom, SWP_NOZORDER );
 
HANDLE CheckHandle(HANDLE Hnd)
 
void SetFilename(CSTR FName)
 
BOOL WriteStringFmt(CSTR Section, CSTR KeyName, CSTR Fmt,...)
 
PBYTE GetBinary(CSTR Section, CSTR Key, OUT INT *pSize)
 
void * mem_Alloc(size_t Bytes)
 
PBYTE GetStruct(CSTR Section, CSTR Key, UINT cbStruct)
 
#define BEGIN_STRSAFE_OVERRIDE
 
UINT BlockWrite(HANDLE hFile, PVOID Buf, UINT nBytes)
 
BOOL WriteLine(HANDLE hFile, CSTR Buf, UINT ccBuf=0)
 
BOOL SaveWndRect(HWND hWnd, CSTR Section, CSTR Key)
 
void __cdecl DPrint(int Level, CSTR Fmt,...)
 
TSTR GetSectionNames(OPTOUT INT *Size=NULL)
 
INT GetString(CSTR Section, CSTR KeyName, CSTR Default, TSTR Buf, UINT BufLen)
 
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
 
void * mem_Free(void *pBlk)
 
BOOL WriteString(CSTR Section, CSTR KeyName, CSTR Text)
 
BOOL WriteSection(CSTR Section, CSTR Strings)
 
CSTR SysErrorMsg(DWORD Err=0, TSTR Buf=NULL, UINT Length=0)
 
BOOL DeleteSection(CSTR Section)
 
SECURITY_ATTRIBUTES DefSec
 
BOOL DeleteString(CSTR Section, CSTR KeyName)
 
UINT BlockRead(HANDLE hFile, PVOID Buf, UINT nBytes)
 
Debug and error handling support.
 
UINT GetInt(CSTR Section, CSTR KeyName, INT Default)
 
IniFile(CSTR FName=NULL, UINT BufSize=4096)
 
BOOL WriteInt(CSTR Section, CSTR KeyName, LONG Value, BYTE Radix=10)
 
bool AllocBuffer(UINT Size)
 
BOOL WriteStruct(CSTR Section, CSTR Key, PVOID pStruct, UINT Size)
 
BOOL RestoreWndRect(HWND hWnd, CSTR Section, CSTR Key)
 
LPRECT AbsToDimRect(LPRECT pRect)
 
BOOL WriteRawSection(CSTR Section, CSTR MultiSz)
 
#define END_STRSAFE_OVERRIDE
 
TSTR GetSection(CSTR Section, OPTOUT INT *Size=NULL)