Source code of Windows XP (NT5)
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.

100 lines
2.3 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include "util.h"
  4. #include "rw_common.h"
  5. /*********************************************************************
  6. Looks for a subkey, under the Registration Database key given in the
  7. szBaseKey parameter, of the form "0000", "0001", etc. The numerical
  8. equivalent of the subkey is determined by the index value given in
  9. the enumIndex parameter. The value attached to the valueName
  10. specified in the string resource whose ID is given in valueStrID will
  11. be returned in szValue.
  12. Returns: FALSE if the key specified is not found.
  13. **********************************************************************/
  14. BOOL GetRegKeyValue(HINSTANCE hInstance, HKEY hRootKey, LPTSTR szBaseKey,int valueStrID, LPTSTR szValue)
  15. {
  16. BOOL returnVal = FALSE;
  17. HKEY hKey;
  18. LONG regStatus = RegOpenKeyEx(hRootKey, szBaseKey, 0, KEY_READ,&hKey);
  19. if (regStatus == ERROR_SUCCESS)
  20. {
  21. _TCHAR szValueName[128];
  22. //LoadString(hInstance,valueStrID,szValueName,128);
  23. _tcscpy(szValueName, _T("InternetProfile"));
  24. unsigned long infoSize = 255;
  25. //regStatus = RegQueryValueEx(hKey, szValueName, NULL, 0, (unsigned char*) szValue, &infoSize);
  26. regStatus = RegQueryValueEx(hKey, szValueName, NULL, 0, (LPBYTE) szValue, &infoSize);
  27. if (regStatus == ERROR_SUCCESS)
  28. {
  29. returnVal = TRUE;
  30. }
  31. RegCloseKey(hKey);
  32. }
  33. return returnVal;
  34. }
  35. void DisplayMessage(LPCSTR szMessage, LPCSTR szFormat)
  36. {
  37. #ifdef _LOG_IN_FILE
  38. if (szFormat)
  39. {
  40. DWORD dwError = GetLastError() ;
  41. CHAR errString[1024] ;
  42. sprintf(errString, szFormat, szMessage);
  43. RW_DEBUG << "\n " << errString << flush;
  44. }
  45. else
  46. {
  47. RW_DEBUG << "\n" << szMessage << flush;
  48. }
  49. #endif
  50. }
  51. BOOL Succeeded1(BOOL h, LPCSTR strFunctionName)
  52. {
  53. if (h == FALSE)
  54. {
  55. char errString[1024] ;
  56. sprintf(errString, "%s returns error %u",
  57. strFunctionName, GetLastError());
  58. #ifdef _LOG_IN_FILE
  59. RW_DEBUG << "\n Succeeded " << errString << flush;
  60. #endif
  61. return FALSE;
  62. }
  63. else
  64. {
  65. return TRUE ;
  66. }
  67. }
  68. BOOL Succeeded(HANDLE h, LPCSTR strFunctionName)
  69. {
  70. if (h == NULL)
  71. {
  72. char errString[1024] ;
  73. sprintf(errString, "%s returns error %u",
  74. strFunctionName, GetLastError());
  75. #ifdef _LOG_IN_FILE
  76. RW_DEBUG << "\n Succeeded " << errString << flush;
  77. #endif
  78. return FALSE;
  79. }
  80. else
  81. {
  82. return TRUE ;
  83. }
  84. }