Ignore:
Timestamp:
Jul 13, 2017, 5:17:57 AM (8 years ago)
Author:
stevenhl
Message:

Import modifications from cwmm-0_2_9-work-01_10_2006.zip dated 2006-08-27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common_functions/ini_funcs.c

    r2 r4  
    11/*
    2  * This file is (C) Chris Wohlgemuth 2001-2004
     2 * This file is (C) Chris Wohlgemuth 2001-2005
    33 */
    4 
    54#define INCL_WIN
    65
    76#include <os2.h>
    87
    9 /*
    10   hini may be NULL. Then the filename is used to open the ini file.
    11  */
    12 /*!**************************************************/
     8/*!**************************************************/
     9/*                                                  */
     10/* @@MODULE                                         */
     11/*                                                  */
     12/* Profile functions                                */
    1313/*                                                  */
    1414/* @@DESC                                           */
     
    3131/*                                                  */
    3232/*!!*************************************************/
    33 BOOL IniSaveWindowPos(HINI hini, char * iniFile, char* chrApp, char *chrKey, HWND hwnd)
     33BOOL PrfSaveWindowPos(HINI hini, char* iniFile, char* chrApp, char* chrKey, HWND hwnd)
    3434{
    3535  BOOL bError=FALSE;
     
    6565/*!**************************************************/
    6666/*                                                  */
     67/* @@MODULE                                         */
     68/*                                                  */
     69/* Profile functions                                */
     70/*                                                  */
    6771/* @@DESC                                           */
    6872/*                                                  */
     
    8589/*                                                  */
    8690/*!!*************************************************/
    87 BOOL IniRestoreWindowPos(HINI hini, char * iniFile, char* chrApp, char *chrKey, HWND hwnd, ULONG fSize)
     91BOOL PrfRestoreWindowPos(HINI hini, char * iniFile, char* chrApp, char *chrKey, HWND hwnd, ULONG fSize)
    8892{
    8993  HINI hiniPriv=hini;
     
    115119}
    116120
    117 
    118 
     121/*!**************************************************/
     122/*                                                  */
     123/* @@MODULE                                         */
     124/*                                                  */
     125/* Profile functions                                */
     126/*                                                  */
     127/* @@DESC                                           */
     128/*                                                  */
     129/* Save a string in an INI file.                    */
     130/*                                                  */
     131/*            .                                     */
     132/*                                                  */
     133/* @@REMARKS                                        */
     134/*                                                  */
     135/* If hini is NULL the given file name will be used */
     136/* for opening the INI file. If hini is not NULL    */
     137/* the file name is ignored.                        */
     138/*                                                  */
     139/* @@RETURNS                                        */
     140/*                                                  */
     141/* BOOL fSuccess                                    */
     142/*                                                  */
     143/* TRUE: Function succeeded.                        */
     144/* FALSE: Error occurred                            */
     145/*                                                  */
     146/*!!*************************************************/
     147BOOL PrfWriteString(HINI hini, char * iniFile, char* chrApp, char *chrKey, char* chrString)
     148{
     149  BOOL bError=FALSE;
     150  HINI hiniPriv=hini;
     151
     152  if(!hini && !iniFile)
     153    return FALSE;
     154
     155  do {
     156    if(!hiniPriv) {
     157      /* Open ini-file */
     158      if((hiniPriv=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)iniFile))
     159         ==NULLHANDLE)
     160        break;
     161    }/* end of if(!hiniPriv) */
     162
     163    if(!PrfWriteProfileString(hiniPriv, chrApp, chrKey, chrString))
     164      bError=TRUE;
     165
     166    if(hiniPriv && !hini)
     167      PrfCloseProfile(hiniPriv);
     168   
     169    if(bError)
     170      break;
     171    return TRUE;
     172  } while(TRUE);
     173  return FALSE;
     174}
     175
     176/*!**************************************************/
     177/*                                                  */
     178/* @@MODULE                                         */
     179/*                                                  */
     180/* Profile functions                                */
     181/*                                                  */
     182/* @@DESC                                           */
     183/*                                                  */
     184/* Get a string from an INI file.                   */
     185/*                                                  */
     186/*            .                                     */
     187/*                                                  */
     188/* @@REMARKS                                        */
     189/*                                                  */
     190/* If hini is NULL the given file name will be used */
     191/* for opening the INI file. If hini is not NULL    */
     192/* the file name is ignored.                        */
     193/*                                                  */
     194/* @@RETURNS                                        */
     195/*                                                  */
     196/* ULONG ulLength                                   */
     197/*                                                  */
     198/* TRUE: Function succeeded.                        */
     199/* FALSE: Error occurred                            */
     200/*                                                  */
     201/*!!*************************************************/
     202BOOL PrfQueryString(HINI hini, char * iniFile, char* chrApp, char *chrKey, char* chrDefault, char* chrBuffer, ULONG ulSize)
     203{
     204  HINI hiniPriv=hini;
     205  ULONG ulRC=0;
     206
     207  do{
     208    if(!hiniPriv) {
     209      if((hiniPriv=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)iniFile))
     210         ==NULLHANDLE)
     211        break;
     212    }/* end of if(!hini) */
     213
     214    ulRC=PrfQueryProfileString(hiniPriv, chrApp, chrKey, chrDefault, chrBuffer, ulSize);
     215
     216    if(hiniPriv && !hini)
     217      PrfCloseProfile(hiniPriv);
     218   
     219      break;
     220  } while(TRUE);
     221  return ulRC;
     222}
     223
     224
Note: See TracChangeset for help on using the changeset viewer.