Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "ncreg.h"
  4. #include "ncstring.h"
  5. VOID StripSpaces(WCHAR * buf)
  6. {
  7. WCHAR * pch = buf;
  8. Assert(buf);
  9. // Find first non-space
  10. while( (*pch) == L' ' )
  11. {
  12. pch++;
  13. }
  14. MoveMemory(buf, pch, CbOfSzAndTerm(pch));
  15. if (lstrlenW(buf) > 0) {
  16. // Do this only if there's at least one character in string
  17. pch = buf + lstrlenW(buf); // Point to null (at end of string)
  18. Assert(*pch == L'\0');
  19. pch--; // Go back one character.
  20. // As long as character is ' ' go to prev char
  21. while( (pch >= buf) && (*pch == L' ') )
  22. {
  23. pch--;
  24. }
  25. Assert (pch >= buf);
  26. Assert (*pch != L' ');
  27. // Next position after last char
  28. pch++;
  29. // null terminate at last byte
  30. *pch = L'\0';
  31. }
  32. }
  33. /////////////////////////////////////////////////////////////////////////////
  34. //
  35. // Reg_QueryInt
  36. //
  37. /////////////////////////////////////////////////////////////////////////////
  38. UINT Reg_QueryInt(HKEY hk, const WCHAR * pszValueName, UINT uDefault)
  39. {
  40. DWORD cbBuf;
  41. BYTE szBuf[32];
  42. DWORD dwType;
  43. HRESULT hr;
  44. cbBuf = sizeof(szBuf);
  45. hr = HrRegQueryValueEx(hk, pszValueName, &dwType, szBuf, &cbBuf);
  46. if (SUCCEEDED(hr))
  47. {
  48. Assert(dwType == REG_SZ);
  49. return (UINT)_wtoi((WCHAR *)szBuf);
  50. }
  51. else
  52. {
  53. return uDefault;
  54. }
  55. }