/*++ Copyright (c) 1990 Microsoft Corporation Module Name: tprof.c Abstract: Win32 Base API Test Program for Profile File Management calls Author: Steve Wood (stevewo) 26-Oct-1990 Revision History: --*/ #include #include #define WIN32_CONSOLE_APP #include void DumpProfile( LPTSTR ProfileFileName ) { LPTSTR Sections, Section; LPTSTR Keywords, Keyword; LPTSTR KeyValue; Sections = LocalAlloc( 0, 4096 * sizeof( *Sections ) ); Keywords = LocalAlloc( 0, 4096 * sizeof( *Keywords ) ); KeyValue = LocalAlloc( 0, 1024 * sizeof( *KeyValue ) ); #ifdef UNICODE printf( "\nDump of %ws\n", #else printf( "\nDump of %s\n", #endif ProfileFileName ? ProfileFileName : TEXT("win.ini") ); *Sections = TEXT('\0'); if (!GetPrivateProfileString( NULL, NULL, NULL, Sections, 4096 * sizeof( *Sections ), ProfileFileName ) ) { printf( "*** Unable to read - rc == %d\n", GetLastError() ); } Section = Sections; while (*Section) { #ifdef UNICODE printf( "[%ws]\n", #else printf( "[%s]\n", #endif Section ); *Keywords = TEXT('\0'); GetPrivateProfileString( Section, NULL, NULL, Keywords, 4096 * sizeof( *Keywords ), ProfileFileName ); Keyword = Keywords; while (*Keyword) { GetPrivateProfileString( Section, Keyword, NULL, KeyValue, 1024 * sizeof( *KeyValue ), ProfileFileName ); #ifdef UNICODE printf( " %ws=%ws\n", #else printf( " %s=%s\n", #endif Keyword, KeyValue ); while (*Keyword++) { } } while (*Section++) { } } LocalFree( Sections ); LocalFree( Keywords ); LocalFree( KeyValue ); return; } void DumpSection( LPTSTR ProfileFileName, LPTSTR SectionName ) { LPTSTR SectionValue; LPTSTR s; SectionValue = LocalAlloc( 0, 4096 * sizeof( TCHAR ) ); #ifdef UNICODE printf( "\nDump of Section %ws in %ws\n", #else printf( "\nDump of Section %s in %s\n", #endif SectionName, ProfileFileName ? ProfileFileName : TEXT("win.ini") ); *SectionValue = TEXT('\0'); GetPrivateProfileSection( SectionName, SectionValue, 4096 * sizeof( TCHAR ), ProfileFileName ); #ifdef UNICODE printf( "[%ws]\n", #else printf( "[%s]\n", #endif SectionName ); s = SectionValue; while (*s) { #ifdef UNICODE printf( " %ws\n", s ); #else printf( " %s\n", s ); #endif while (*s++) { } } LocalFree( SectionValue ); return; } #define MAX_SECTIONS 32 #define MAX_KEYWORDS 32 DWORD main( int argc, char *argv[], char *envp[] ) { ULONG n; int SectionNumber, KeyNumber; LPTSTR SectionValue, KeyValue, Keyword; TCHAR SectionName[ 32 ], KeyName[ 32 ], KeyValueBuffer[ 32 ], Buffer[ 32 ]; FILE *fh; printf( "TPROF: Entering Test Program\n" ); SectionValue = LocalAlloc( 0, 4096 * sizeof( TCHAR ) ); KeyValue = LocalAlloc( 0, 1024 * sizeof( TCHAR ) ); #if 0 for (SectionNumber=0; SectionNumber