## Graphics Adapter Device Driver Reference

[prev][next][parent][TOC]

### How to Write to Windows Profiling Files in OS/2

Some display drivers must perform windows profiling (updates to SYSTEM.INI or WIN.INI file). The following sample source file can be included in display driver source and executed at ring 3 only.

         typedef ULONG APIENTRY WPF1(VOID);
         typedef WPF1 *PWPF1;
         typedef BOOL  APIENTRY WPF2(ULONG, BOOL);
         typedef WPF2 *PWPF2;
         typedef BOOL  APIENTRY WPF3(ULONG, PSZ);
         typedef WPF3 *PWPF3;
         BOOL UpdateWindowsIniFiles(VOID)
         {
           BOOL    result = TRUE;
           BOOL    res1;
           ULONG   hWpf;
           CHAR    szUpdateString[256];
           PWPF1   pWpfOpenProfileList;
           PWPF2   pWpfCloseProfileList;
           PWPF3   pWpfWriteProfileListLine;
           HMODULE hMod;
           if (DosLoadModule(NULL, 0, "WINPRF", &hMod) ||
               DosQueryProcAddr(hMod, 0, "WPFOPENPROFILELIST", (PFN *)&pWpfOpenProfileList) ||
               DosQueryProcAddr(hMod, 0, "WPFCLOSEPROFILELIST", (PFN *)&pWpfCloseProfileList) ||
               DosQueryProcAddr(hMod, 0, "WPFWRITEPROFILELISTLINE", (PFN *)&pWpfWriteProfileListLine))
           {
              return FALSE;
           }

           // Open the profile handler.
           if (hWpf = (*pWpfOpenProfileList)())
           {
           /*
           ** szUpdateString has the following format
           **
           ** <profile name>  <section>  <keyword>  [value]
           **
           ** ex.   "system.ini boot sdisplay.drv wd3116sl.drv"  will insert the line
           **    sdisplay.drv=wd3116sl.drv in the boot section of system.ini
           **
           ** if [value] is omitted, the <keyword> is deleted from the section
           */
              if (!(*pWpfWriteProfileListLine)(hWpf, szUpdateString))
              {
                 result = FALSE;          // Win Ini update failed!
              }

              res1 = (*pWpfCloseProfileList)(hWpf, result); // Close or abort the updates
              result &= res1;
           }
           else
           {
              result = FALSE;
           }

           return result;
       }