|
|
1.1 root 1: /*****************************************************************************
2: *
3: * Registry.c - This module handles requests for registry data, and
4: * reading/writing of window placement data
5: *
6: * Microsoft Confidential
7: * Copyright (c) 1992-1993 Microsoft Corporation
8: *
9: *
10: ****************************************************************************/
11:
12: #include <stdio.h>
13:
14: #include "perfmon.h"
15: #include "registry.h"
16: #include "utils.h" // for StringToWindowPlacement
17:
18: static TCHAR PerfmonNamesKey[] = TEXT("SOFTWARE\\Microsoft\\PerfMon") ;
19: static TCHAR WindowKeyName[] = TEXT("WindowPos") ;
20:
21: VOID LoadLineGraphSettings(PGRAPHSTRUCT lgraph)
22: {
23: lgraph->gMaxValues = DEFAULT_MAX_VALUES;
24: lgraph->gOptions.bLegendChecked = DEFAULT_F_DISPLAY_LEGEND;
25: lgraph->gOptions.bLabelsChecked = DEFAULT_F_DISPLAY_CALIBRATION;
26:
27: return;
28: }
29:
30: VOID LoadRefreshSettings(PGRAPHSTRUCT lgraph)
31: {
32: lgraph->gInterval = DEF_GRAPH_INTERVAL;
33: lgraph->gOptions.eTimeInterval = (FLOAT) lgraph->gInterval / (FLOAT) 1000.0 ;
34: return;
35: }
36:
37:
38: BOOL LoadMainWindowPlacement (HWND hWnd)
39: {
40: WINDOWPLACEMENT WindowPlacement ;
41: TCHAR szWindowPlacement [TEMP_BUF_LEN] ;
42: HKEY hKeyNames ;
43: DWORD Size;
44: DWORD Type;
45: DWORD Status;
46:
47: Status = RegOpenKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey,
48: 0L, KEY_READ, &hKeyNames) ;
49:
50: if (Status == ERROR_SUCCESS)
51: {
52: Size = sizeof(szWindowPlacement) ;
53:
54: Status = RegQueryValueEx(hKeyNames, WindowKeyName, NULL,
55: &Type, (LPBYTE)szWindowPlacement, &Size) ;
56: RegCloseKey (hKeyNames) ;
57:
58: if (Status == ERROR_SUCCESS)
59: {
60: StringToWindowPlacement (szWindowPlacement, &WindowPlacement) ;
61: SetWindowPlacement (hWnd, &WindowPlacement) ;
62: bPerfmonIconic = IsIconic(hWnd) ;
63: return (TRUE) ;
64: }
65: }
66:
67: if (Status != ERROR_SUCCESS)
68: {
69: // open registry failed, use Max as default
70: ShowWindow (hWnd, SW_SHOWMAXIMIZED) ;
71: return (FALSE) ;
72: }
73: }
74:
75:
76:
77: BOOL SaveMainWindowPlacement (HWND hWnd)
78: {
79: WINDOWPLACEMENT WindowPlacement ;
80: TCHAR ObjectType [2] ;
81: TCHAR szWindowPlacement [TEMP_BUF_LEN] ;
82: HKEY hKeyNames = 0 ;
83: DWORD Size ;
84: DWORD Status ;
85: DWORD dwDisposition ;
86:
87: ObjectType [0] = TEXT(' ') ;
88: ObjectType [1] = TEXT('\0') ;
89:
90: GetWindowPlacement (hWnd, &WindowPlacement) ;
91: WindowPlacementToString (&WindowPlacement, szWindowPlacement) ;
92:
93: // try to create it first
94: Status = RegCreateKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey, 0L,
95: ObjectType, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WRITE,
96: NULL, &hKeyNames, &dwDisposition) ;
97:
98: // if it has been created before, then open it
99: if (dwDisposition == REG_OPENED_EXISTING_KEY)
100: {
101: Status = RegOpenKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey, 0L,
102: KEY_WRITE, &hKeyNames) ;
103: }
104:
105: // we got the handle, now store the window placement data
106: if (Status == ERROR_SUCCESS)
107: {
108: Size = (lstrlen (szWindowPlacement) + 1) * sizeof (TCHAR) ;
109:
110: Status = RegSetValueEx(hKeyNames, WindowKeyName, 0,
111: REG_SZ, (LPBYTE)szWindowPlacement, Size) ;
112:
113: RegCloseKey (hKeyNames) ;
114:
115: }
116:
117: return (Status == ERROR_SUCCESS) ;
118: }
119:
120:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.