Annotation of mstools/samples/midimon/prefer.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * prefer.c - Routines to get and set user preferences.
        !             3:  */
        !             4: 
        !             5: #include <windows.h>
        !             6: #include <mmsystem.h>
        !             7: #include <stdio.h>
        !             8: #include "midimon.h"
        !             9: #include "prefer.h"
        !            10: 
        !            11: /* getPreferences - Reads .INI file and gets the setup preferences.
        !            12:  *      Currently, the only user preferences are window location and size.
        !            13:  *      If the .INI file does not exist, returns default values.
        !            14:  *
        !            15:  * Params:  lpPreferences - Points to a PREFERENCES data structure that
        !            16:  *              is filled with the retrieved user preferences.
        !            17:  *
        !            18:  * Return:  void
        !            19: */
        !            20: void getPreferences(LPPREFERENCES lpPreferences)
        !            21: {
        !            22:     lpPreferences->iInitialX = 
        !            23:         GetPrivateProfileInt(INI_DISPLAYWINDOW, INI_X, DEF_X, INI_FILENAME);
        !            24: 
        !            25:     lpPreferences->iInitialY = 
        !            26:         GetPrivateProfileInt(INI_DISPLAYWINDOW, INI_Y, DEF_Y, INI_FILENAME);
        !            27: 
        !            28:     lpPreferences->iInitialW = 
        !            29:         GetPrivateProfileInt(INI_DISPLAYWINDOW, INI_W, DEF_W, INI_FILENAME);
        !            30: 
        !            31:     lpPreferences->iInitialH = 
        !            32:         GetPrivateProfileInt(INI_DISPLAYWINDOW, INI_H, DEF_H, INI_FILENAME);
        !            33: }
        !            34: 
        !            35: /* setPreferences - Writes the .INI file with the given setup preferences.
        !            36:  *
        !            37:  * Params:  lpPreferences - Points to a PREFERENCES data structure containing
        !            38:  *              the user preferences.
        !            39:  *
        !            40:  * Return:  void
        !            41:  */
        !            42: void setPreferences(LPPREFERENCES lpPreferences)
        !            43: {
        !            44:     char szTempString[20];
        !            45: 
        !            46:     sprintf(szTempString, "%d", lpPreferences->iInitialX);
        !            47:     if(WritePrivateProfileString(INI_DISPLAYWINDOW, INI_X,
        !            48:                               (LPSTR) szTempString, INI_FILENAME) == 0)
        !            49:         Error("Error writing MIDIMON.INI");
        !            50:         
        !            51:     sprintf(szTempString, "%d", lpPreferences->iInitialY);
        !            52:     if(WritePrivateProfileString(INI_DISPLAYWINDOW, INI_Y,
        !            53:                               (LPSTR) szTempString, INI_FILENAME) == 0)
        !            54:         Error("Error writing MIDIMON.INI");
        !            55:         
        !            56:     sprintf(szTempString, "%d", lpPreferences->iInitialW);
        !            57:     if(WritePrivateProfileString(INI_DISPLAYWINDOW, INI_W,
        !            58:                               (LPSTR) szTempString, INI_FILENAME) == 0)
        !            59:         Error("Error writing MIDIMON.INI");
        !            60:         
        !            61:     sprintf(szTempString, "%d", lpPreferences->iInitialH);
        !            62:     if(WritePrivateProfileString(INI_DISPLAYWINDOW, INI_H,
        !            63:                               (LPSTR) szTempString, INI_FILENAME) == 0)
        !            64:         Error("Error writing MIDIMON.INI");
        !            65: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.