//////////////////////////////////////////////////////////////////////
//
// Project  : BRender System Configuration Settings Sample
//            Copyright (c) 1996 Argonaut Technologies Ltd.
//            All rights reserved.
//
// Author   : Steve Williams, October 1996
//
// File     : CFG_SAMP.C
//
// Requires : BRender V1.3, Windows95 / NT, or DOS
//
// Comments : Sample code.
//
//////////////////////////////////////////////////////////////////////

#ifdef WIN32
#include <windows.h>
#endif

#include <stdio.h>
#include <brender.h>


void ShowSettings( char *Title )
{
    char String1[50], String2[50], String3[50];
    char Message[255];
	
    BrSystemConfigQueryString( BRT_BRENDER_PATH_STR, String1, 50 );
    BrSystemConfigQueryString( BRT_BRENDER_DEVICES_STR, String2, 50 );
    BrSystemConfigQueryString( BRT_DEFAULT_DEVICE_STR, String3, 50 );

    BrSprintf( Message, "BRENDER PATH : %s\nBRENDER_DEVICES : %s\nDEFAULT DEVICE : %s", 
	        String1, String2, String3 );
   

#ifdef WIN32
    MessageBox( NULL, Message, Title, MB_OK );
#else
    printf("%s\n%s\n\n\n", Title, Message );
#endif

}



#ifdef WIN32

int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        LPSTR lpCmdLine, int nCmdShow)
#else

int main( int argc, char **argv )

#endif
{
   br_error r ;
	
   // Initiallise BRender

   BrBegin();

   ShowSettings("Initial Setttings");

#if WIN32
   
   r = BrSystemConfigLoad( BRT_REGISTRY_STR, "\\SOFTWARE\\MyCompany\\MyApp", 
	                   (void*) HKEY_LOCAL_MACHINE );

   if ( r == BRE_OK )
	   ShowSettings("After registry load");
   else
      MessageBox( NULL, "Could not find specfied registry location", "Warning", MB_OK );

   r = BrSystemConfigLoad( BRT_INI_STR, "myapp.ini", (void*) "BRender" );
   
   if ( r == BRE_OK )
	   ShowSettings("After ini file load");
   else
      MessageBox( NULL, "Could not find [BRender] entry in ini file", "Warning", MB_OK );

#endif

   BrSystemConfigSetString( BRT_BRENDER_PATH_STR, "A test" );

   ShowSettings("After BrSystemConfigSetString");
   
   BrEnd();

   return 0 ;
}
