MCPcopy Create free account
hub / github.com/JHRobotics/softgpu / registryRead

Function registryRead

winreg.c:119–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119BOOL registryRead(const char *path, char *buffer, size_t buffer_size)
120{
121 HKEY rootkey;
122 const char *key;
123 const char *subkey;
124 BOOL rc = FALSE;
125
126 if(registrySplitPath(path, &rootkey, &key, &subkey))
127 {
128 HKEY hKey;
129 LSTATUS lResult;
130
131 lResult = RegOpenKeyEx(rootkey, key, 0, KEY_READ, &hKey);
132 if(lResult == ERROR_SUCCESS)
133 {
134 DWORD type;
135 DWORD size = REG_PATH_MAX;
136
137 //lResult = RegGetValueA(hKey, NULL, subkey, RRF_RT_DWORD | RRF_RT_REG_SZ, &type, winreg_tmp, &size);
138 lResult = RegQueryValueExA(hKey, subkey, NULL, &type, (LPBYTE)winreg_tmp, &size);
139 if(lResult == ERROR_SUCCESS)
140 {
141 switch(type)
142 {
143 case REG_SZ:
144 case REG_MULTI_SZ:
145 case REG_EXPAND_SZ:
146 {
147 size_t cpy_size = MIN(size-1, buffer_size-1);
148 memcpy(buffer, winreg_tmp, cpy_size);
149 buffer[cpy_size] = '\0';
150 rc = TRUE;
151 break;
152 }
153 case REG_DWORD:
154 {
155 //DWORD temp_dw = *((LPDWORD)winreg_tmp);
156 DWORD temp_dw;
157 memcpy(&temp_dw, winreg_tmp, sizeof(DWORD));
158 sprintf(buffer, "%lu", temp_dw);
159 rc = TRUE;
160 break;
161 }
162 }
163 }
164
165 RegCloseKey(hKey);
166 }
167 }
168
169 return rc;
170}
171
172#define DW_BUF 12
173

Callers 4

softgpu_sysinfoFunction · 0.85
version_winFunction · 0.85
registryReadDWORDFunction · 0.85
readSettingsFunction · 0.85

Calls 1

registrySplitPathFunction · 0.85

Tested by

no test coverage detected