Ignore:
Timestamp:
Oct 27, 1999, 3:10:35 PM (26 years ago)
Author:
phaller
Message:

Fix: console properties

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/conprop2.cpp

    r1476 r1477  
    1 /* $Id: conprop2.cpp,v 1.1 1999-10-27 12:38:47 phaller Exp $ */
     1/* $Id: conprop2.cpp,v 1.2 1999-10-27 13:10:35 phaller Exp $ */
    22
    33/*
     
    8585LONG  _System _O32_RegQueryValueEx(HKEY,LPSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
    8686LONG  _System _O32_RegCloseKey(HKEY);
     87LONG  _System _O32_RegSetValueEx( HKEY, LPCSTR, DWORD, DWORD, LPBYTE, DWORD );
     88
    8789DWORD _System GetModuleFileNameA(HMODULE,LPSTR,DWORD);
     90
     91
     92/*****************************************************************************
     93 * Name      : iQueryModuleKeyName
     94 * Funktion  : determine name of key to store the console properties for
     95 *             this process
     96 * Parameter :
     97 * Variablen :
     98 * Ergebnis  :
     99 * Bemerkung :
     100 *
     101 * Autor     : Patrick Haller [1998/06/13 23:20]
     102 *****************************************************************************/
     103
     104static DWORD iQueryModuleKeyName(LPSTR lpstrProcessName,
     105                                 DWORD dwProcessNameLength)
     106{
     107  // Note: one might want to scan the string and replace illegal characters
     108  // or use a module name only instead of the fully qualified path!
     109  return(GetModuleFileNameA(NULL,
     110                            lpstrProcessName,
     111                            dwProcessNameLength));
     112}
    88113
    89114
     
    156181
    157182  // query process's name
    158   dwRes = GetModuleFileNameA(NULL,
    159                              (LPSTR)&szProcessName,
    160                              sizeof(szProcessName));
     183  dwRes = iQueryModuleKeyName((LPSTR)&szProcessName,
     184                              sizeof(szProcessName));
    161185  if (dwRes == 0)
    162186  {
     
    249273            pConsoleOptions));
    250274
     275  // HKEY_CURRENT_USER/SOFTWARE/ODIN/ConsoleProperties/<process name>/<option name>
     276  LONG  lRes = ERROR_SUCCESS;
     277  HKEY  hkConsole;
     278  char  szKey[256];
     279  char  szProcessName[256];
     280  DWORD dwRes;
     281  DWORD dwSize;
     282  DWORD dwType;
     283  DWORD dwDisposition = 0;
     284
     285  // query process's name
     286  dwRes = iQueryModuleKeyName((LPSTR)&szProcessName,
     287                              sizeof(szProcessName));
     288  if (dwRes == 0)
     289  {
     290    dprintf(("KERNEL32: ConProp: ConsolePropertyLoad: GetModuleFileName failed\n"));
     291    lRes = ERROR_INVALID_PARAMETER;
     292  }
     293  else
     294  {
     295    // open process key
     296    sprintf (szKey,
     297             "Software\\ODIN\\ConsoleProperties\\%s",
     298             szProcessName);
     299
     300    lRes = _O32_RegCreateKeyEx(HKEY_CURRENT_USER_O32,
     301                               szKey,
     302                               0,
     303                               "",
     304                               0,
     305                               KEY_ALL_ACCESS,
     306                               NULL,
     307                               &hkConsole,
     308                               &dwDisposition);
     309    if (lRes != ERROR_SUCCESS)
     310       return lRes;
     311  }
     312
     313
     314#define REGSAVEVALUE(name,var) \
     315  lRes = _O32_RegSetValueEx(hkConsole, name, 0, REG_DWORD, \
     316                 (LPBYTE)&pConsoleOptions->var, sizeof(pConsoleOptions->var));
     317
     318  REGSAVEVALUE("AutomaticTermination",     fTerminateAutomatically)
     319  REGSAVEVALUE("Speaker",                  fSpeakerEnabled)
     320  REGSAVEVALUE("SpeakerDuration",          ulSpeakerDuration)
     321  REGSAVEVALUE("SpeakerFrequency",         ulSpeakerFrequency)
     322  REGSAVEVALUE("UpdateLimit",              ulUpdateLimit)
     323  REGSAVEVALUE("SetWindowPosition",        fSetWindowPosition)
     324  REGSAVEVALUE("DefaultPosition_x",        coordDefaultPosition.X)
     325  REGSAVEVALUE("DefaultPosition_y",        coordDefaultPosition.Y)
     326  REGSAVEVALUE("DefaultSize_x",            coordDefaultSize.X)
     327  REGSAVEVALUE("DefaultSize_y",            coordDefaultSize.Y)
     328  REGSAVEVALUE("BufferSize_x",             coordBufferSize.X)
     329  REGSAVEVALUE("BufferSize_y",             coordBufferSize.Y)
     330  REGSAVEVALUE("QuickInsert",              fQuickInsert)
     331  REGSAVEVALUE("InsertMode",               fInsertMode)
     332  REGSAVEVALUE("MouseActions",             fMouseActions)
     333  REGSAVEVALUE("Toolbar",                  fToolbarActive)
     334  REGSAVEVALUE("TabSize",                  ulTabSize)
     335  REGSAVEVALUE("DefaultAttribute",         ucDefaultAttribute)
     336  REGSAVEVALUE("CursorDivisor",            ucCursorDivisor)
     337  REGSAVEVALUE("ConsolePriorityClass",     ulConsoleThreadPriorityClass)
     338  REGSAVEVALUE("ConsolePriorityDelta",     ulConsoleThreadPriorityDelta)
     339  REGSAVEVALUE("ApplicationPriorityClass", ulAppThreadPriorityClass)
     340  REGSAVEVALUE("ApplicationPriorityDelta", ulAppThreadPriorityDelta)
     341#undef REGSAVEVALUE
     342
     343  _O32_RegCloseKey(hkConsole);
     344
    251345  return (NO_ERROR);
     346
    252347}
    253348
Note: See TracChangeset for help on using the changeset viewer.