by Dan East » Dec 1, 2001 @ 4:46pm
I'll write the code right now to load / save settings:<br>[fixed]<br>struct MySettings {<br> int nSomeValue;<br> char sSomeString[64];<br> char sBlahBlahBlah[32];<br>};<br><br>int SaveSettings( MySettings *pSettings ) {<br> FILE *f=fopen( "MySettingsFile.cfg", "wb" );<br> if (!f)<br> return 0; //Unable to create file<br> if ( !fwrite( pSettings, sizeof( MySettings ), 1, f ) ) {<br> fclose( f );<br> return 0; //Error writing - Disk Full?<br> }<br> fclose( f );<br> return 1; //Success<br>}<br><br>int LoadSettings( MySettings *pSettings ) {<br> FILE *f=fopen( "MySettingsFile.cfg", "rb" );<br> if ( !f )<br> return 0; //Unable to open file Does Not Exist?<br> if ( !fread( pSettings, sizeof( MySettings ), 1, f ) {<br> fclose( f );<br> return 0; //Error reading - truncated file?<br> }<br> fclose( f );<br> return 1; //Success<br>}<br>[/fixed]<br><br>You can use wide-char versions of fopen to pass UNICODE filenames, or use Windows API CreateFile to support CE 2.11 as well. Just define struct to store whatever you want - EXCEPT POINTERS. This is off the top of my head, and may have syntax errors.<br><br>Dan East