home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / BKUPINI.ZIP / BKUPSINI.C < prev    next >
Text File  |  1990-05-20  |  5KB  |  111 lines

  1.        
  2. #define  EXTERN extern
  3. #include "INIPGMS.h"
  4.  
  5. VOID APIENTRY Backup_Ini()
  6. {
  7. CHAR   buffersave[MAXNAMEL+1], buffer[MAXNAMEL+1] ;
  8. HINI   hiniBkup ;
  9. ULONG  ulApplLen, ulKeyNamesSize, ulKeyDataSize ;
  10. PVOID  pvoidKeyNames, pvoidKeyData ;
  11. PSZ    pszApplName, pszKeyNames ;
  12.  
  13. strcpy( buffersave, (PSZ)pvoidWorkArea ) ;
  14. strcpy( buffer, buffersave ) ;
  15. strcat( buffer, "OS2SV.INI" ) ;
  16. hiniBkup = PrfOpenProfile( hAB, buffer ) ;
  17. pvoidWorkArea  = pvoidWorkAreaOrigin ;
  18. ulWorkAreaSize = WORKAREASIZE ;
  19. ulApplLen      = ulWorkAreaSize ;
  20. if( PrfQueryProfileData( HINI_USERPROFILE,
  21.                          NULL,
  22.                          NULL,
  23.                          pvoidWorkArea,
  24.                          &ulApplLen )  )
  25.      {
  26.      (PBYTE)pvoidKeyNames = (PBYTE)pvoidWorkArea + 
  27.                             ulApplLen + 1 ;
  28.      for( pszApplName = (PSZ)pvoidWorkArea;
  29.           strlen(pszApplName) ;
  30.           pszApplName += strlen(pszApplName)+1 )
  31.           {
  32.           ulKeyNamesSize       = ulWorkAreaSize - (ulApplLen + 1) ;
  33.           PrfQueryProfileData( HINI_USERPROFILE,
  34.                                pszApplName,
  35.                                NULL,
  36.                                pvoidKeyNames,
  37.                                &ulKeyNamesSize ) ;
  38.           (PBYTE)pvoidKeyData = (PBYTE)pvoidKeyNames + ulKeyNamesSize + 1 ;
  39.           for( pszKeyNames = (PSZ)pvoidKeyNames;
  40.                strlen(pszKeyNames) ;
  41.                pszKeyNames += strlen(pszKeyNames)+1 )
  42.                {
  43.                ulKeyDataSize       = ulWorkAreaSize -
  44.                                      (ulApplLen + ulKeyNamesSize + 2) ;
  45.                PrfQueryProfileData( HINI_USERPROFILE,
  46.                                     pszApplName,
  47.                                     pszKeyNames,
  48.                                     pvoidKeyData,
  49.                                     &ulKeyDataSize ) ;
  50.                PrfWriteProfileData( hiniBkup,
  51.                                     pszApplName,
  52.                                     pszKeyNames,
  53.                                     pvoidKeyData,
  54.                                     ulKeyDataSize ) ;
  55.                }     /*   End of Key  process for       */
  56.           }          /*   End of Appl process for       */
  57.      }               /*   End of If Applname            */
  58. PrfCloseProfile( hiniBkup ) ;
  59.  
  60. strcpy( buffer, buffersave ) ;
  61. strcat( buffer, "OS2SYSSV.INI" ) ;
  62. hiniBkup = PrfOpenProfile( hAB, buffer ) ;
  63. pvoidWorkArea  = pvoidWorkAreaOrigin ;
  64. ulWorkAreaSize = WORKAREASIZE ;
  65. ulApplLen      = ulWorkAreaSize ;
  66. if( PrfQueryProfileData( HINI_SYSTEMPROFILE,
  67.                          NULL,
  68.                          NULL,
  69.                          pvoidWorkArea,
  70.                          &ulApplLen )  )
  71.      {
  72.      (PBYTE)pvoidKeyNames = (PBYTE)pvoidWorkArea + 
  73.                             ulApplLen + 1 ;
  74.      for( pszApplName = (PSZ)pvoidWorkArea;
  75.           strlen(pszApplName) ;
  76.           pszApplName += strlen(pszApplName)+1 )
  77.           {
  78.           ulKeyNamesSize       = ulWorkAreaSize - (ulApplLen + 1) ;
  79.           PrfQueryProfileData( HINI_SYSTEMPROFILE,
  80.                                pszApplName,
  81.                                NULL,
  82.                                pvoidKeyNames,
  83.                                &ulKeyNamesSize ) ;
  84.           (PBYTE)pvoidKeyData = (PBYTE)pvoidKeyNames + ulKeyNamesSize + 1 ;
  85.           for( pszKeyNames = (PSZ)pvoidKeyNames;
  86.                strlen(pszKeyNames) ;
  87.                pszKeyNames += strlen(pszKeyNames)+1 )
  88.                {
  89.                ulKeyDataSize       = ulWorkAreaSize -
  90.                                      (ulApplLen + ulKeyNamesSize + 2) ;
  91.                PrfQueryProfileData( HINI_SYSTEMPROFILE,
  92.                                     pszApplName,
  93.                                     pszKeyNames,
  94.                                     pvoidKeyData,
  95.                                     &ulKeyDataSize ) ;
  96.                PrfWriteProfileData( hiniBkup,
  97.                                     pszApplName,
  98.                                     pszKeyNames,
  99.                                     pvoidKeyData,
  100.                                     ulKeyDataSize ) ;
  101.                }     /*   End of Key  process for       */
  102.           }          /*   End of Appl process for       */
  103.      }               /*   End of If Applname            */
  104. PrfCloseProfile( hiniBkup ) ;
  105.  
  106. WinPostMsg(hwndThreadWaiter, WM_COMMAND, MPFROMSHORT(THREAD_GONE), 0L) ;
  107. DosExit( EXIT_THREAD, 0 ) ;
  108.  
  109. }
  110.  
  111.