home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpobj.zip / PROFILE.ZIP / PROFILE.C next >
Text File  |  1993-06-30  |  3KB  |  81 lines

  1. #define INCL_WINSHELLDATA
  2. #include <os2.h>
  3.  
  4. #include <string.h>
  5. #include <malloc.h>
  6.  
  7. #define  APP_NAME "SYS_DLLS"
  8. #define  KEY_NAME "LoadOneTime"
  9. #define  DLL_NAME "YOURDLL"
  10.  
  11. main()
  12. {
  13.   HAB   hAB;
  14.   PSZ   pszProfile;
  15.   PVOID pTemp;
  16.   ULONG ulLength;
  17.  
  18.   hAB = WinInitialize(0);
  19.  
  20.   /*-------------------------------------------------------------------
  21.     Query the current KEY_NAME's string length
  22.    -------------------------------------------------------------------*/
  23.   if (!(PrfQueryProfileSize (HINI_USERPROFILE,
  24.                              APP_NAME,
  25.                              KEY_NAME,
  26.                              &ulLength)))
  27.   {
  28.     exit();
  29.   }
  30.  
  31.   /*-------------------------------------------------------------------
  32.     Calculate the new KEY_NAME's string length, allowing for a blank
  33.     delimiter and NULL terminator, and allocate a buffer capable of
  34.     holding the new string
  35.    -------------------------------------------------------------------*/
  36.   ulLength += sizeof(DLL_NAME) + 2;
  37.   pszProfile = malloc(ulLength);
  38.  
  39.   /*-------------------------------------------------------------------
  40.     Query the current KEY_NAME's string ... Exit the pgm if an
  41.     error occurs
  42.    -------------------------------------------------------------------*/
  43.   if (!(PrfQueryProfileString (HINI_USERPROFILE,
  44.                                APP_NAME,
  45.                                KEY_NAME,
  46.                                NULL,
  47.                                pszProfile,
  48.                                ulLength)))
  49.   {
  50.     free(pszProfile);
  51.     exit();
  52.   }
  53.  
  54.   /*-------------------------------------------------------------------
  55.     Add the blank delimiter iff the current KEY_NAME string contains
  56.     something
  57.    -------------------------------------------------------------------*/
  58.   if (strlen(pszProfile))
  59.     strcat(pszProfile, " ");       /*Blank delimiter */
  60.  
  61.   /*-------------------------------------------------------------------
  62.     Add your DLL name to the KEY_NAME string
  63.    -------------------------------------------------------------------*/
  64.   strcat(pszProfile, DLL_NAME);
  65.  
  66.   /*-------------------------------------------------------------------
  67.     Write the new KEY_NAME string to your OS2.INI file
  68.    -------------------------------------------------------------------*/
  69.   PrfWriteProfileString (HINI_USERPROFILE,
  70.                          APP_NAME,
  71.                          KEY_NAME,
  72.                          pszProfile);
  73.  
  74.   /*-------------------------------------------------------------------
  75.     Clean up and exit stage right
  76.    -------------------------------------------------------------------*/
  77.   free(pszProfile);
  78.   exit();
  79.  
  80. }
  81.