bool VDRegistryKey::getString(const char *pszName, VDStringA& str) const { DWORD type, s = sizeof(DWORD); if (!pHandle || RegQueryValueEx((HKEY)pHandle, pszName, 0, &type, NULL, &s) || type != REG_SZ) return false; str.resize(s); if (RegQueryValueEx((HKEY)pHandle, pszName, 0, NULL, (BYTE *)str.data(), &s)) return false; if (!s) str.clear(); else str.resize(strlen(str.c_str())); // Trim off pesky terminating NULLs. return true; }
void VDDumpChangeLog() { HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(IDR_CHANGES), "STUFF"); if (!hResource) return; HGLOBAL hGlobal = LoadResource(NULL, hResource); if (!hGlobal) return; LPVOID lpData = LockResource(hGlobal); if (!lpData) return; const char *s = (const char *)lpData; while(*s!='\r') ++s; s+=2; tTextStream lineBuffer; VDStringA breakLineBuffer; bool foundNonIndentedLine = false; while(*s) { // parse line if (*s != ' ') { if (foundNonIndentedLine) break; foundNonIndentedLine = true; } const char *end = s; while(*end && *end != '\r' && *end != '\n') ++end; lineBuffer.clear(); append_cooked(lineBuffer, s, end, false); // skip line termination s = end; if (*s == '\r' || *s == '\n') { ++s; if ((s[0] ^ s[-1]) == ('\r' ^ '\n')) ++s; } lineBuffer.push_back(0); // break into lines const char *t = lineBuffer.data(); int maxLine = 78; breakLineBuffer.clear(); do { const char *lineStart = t; const char *break1 = NULL; const char *break2 = NULL; do { while(*t && *t != ' ') ++t; const char *u = t; while(*t && *t == ' ') ++t; if (u - lineStart > maxLine) { if (!break1) { break1 = u + maxLine; break2 = break1; } break; } break1 = u; break2 = t; } while(*t); breakLineBuffer.append(lineStart, break1); VDLog(kVDLogInfo, VDTextAToW(breakLineBuffer.data(), breakLineBuffer.size())); t = break2; breakLineBuffer.clear(); breakLineBuffer.resize(5, ' '); maxLine = 73; } while(*t); } }