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.

139 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ConfNum.c
  5. Abstract:
  6. Return number of keywords for a given section of the config data.
  7. Author:
  8. John Rogers (JohnRo) 30-Jan-1992
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. 30-Jan-1992 JohnRo
  13. Created.
  14. 13-Feb-1992 JohnRo
  15. Added support for using the real Win32 registry.
  16. 06-Mar-1992 JohnRo
  17. Fixed NT RTL version.
  18. 12-Mar-1992 JohnRo
  19. Fixed bug in Win32 version (was using wrong variable).
  20. 20-Mar-1992 JohnRo
  21. Update to DaveGi's proposed WinReg API changes.
  22. 05-Jun-1992 JohnRo
  23. Winreg title index parm is defunct.
  24. Use PREFIX_ equates.
  25. --*/
  26. // These must be included first:
  27. #include <nt.h> // NT definitions (temporary)
  28. #include <ntrtl.h> // NT Rtl structure definitions (temporary)
  29. #include <nturtl.h> // NT Rtl structures (temporary)
  30. #include <windows.h> // Needed by <configp.h> and <winreg.h>
  31. #include <lmcons.h> // NET_API_STATUS, etc.
  32. // These may be included in any order:
  33. #include <config.h> // LPNET_CONFIG_HANDLE, Netp config routines.
  34. #include <configp.h> // private config stuff.
  35. #include <debuglib.h> // IF_DEBUG().
  36. #include <netdebug.h> // NetpKdPrint(()), etc.
  37. #include <prefix.h> // PREFIX_ equates.
  38. #include <strarray.h> // NetpTStrArrayEntryCount().
  39. #include <winerror.h> // ERROR_ equates, NO_ERROR.
  40. #include <winreg.h> // RegQueryKey(), etc.
  41. NET_API_STATUS
  42. NetpNumberOfConfigKeywords (
  43. IN LPNET_CONFIG_HANDLE ConfigHandle,
  44. OUT LPDWORD CountPtr
  45. )
  46. {
  47. NET_API_STATUS ApiStatus;
  48. DWORD Count;
  49. NET_CONFIG_HANDLE * lpnetHandle = ConfigHandle; // Conv from opaque type.
  50. if (CountPtr == NULL) {
  51. return (ERROR_INVALID_PARAMETER);
  52. }
  53. *CountPtr = 0; // Don't confuse caller on error.
  54. if (lpnetHandle == NULL) {
  55. return (ERROR_INVALID_PARAMETER);
  56. }
  57. {
  58. LONG Error;
  59. TCHAR ClassName[ MAX_CLASS_NAME_LENGTH ];
  60. DWORD ClassNameLength;
  61. DWORD NumberOfSubKeys;
  62. DWORD MaxSubKeyLength;
  63. DWORD MaxClassLength;
  64. DWORD NumberOfValues;
  65. DWORD MaxValueNameLength;
  66. DWORD MaxValueDataLength;
  67. DWORD SecurityDescriptorSize;
  68. FILETIME LastWriteTime;
  69. ClassNameLength = MAX_CLASS_NAME_LENGTH;
  70. Error = RegQueryInfoKey(
  71. lpnetHandle->WinRegKey,
  72. ClassName,
  73. &ClassNameLength,
  74. NULL, // reserved
  75. &NumberOfSubKeys,
  76. &MaxSubKeyLength,
  77. &MaxClassLength,
  78. &NumberOfValues,
  79. &MaxValueNameLength,
  80. &MaxValueDataLength,
  81. #ifndef REG_FILETIME
  82. &SecurityDescriptorSize,
  83. #endif
  84. &LastWriteTime
  85. );
  86. IF_DEBUG(CONFIG) {
  87. NetpKdPrint(( PREFIX_NETLIB
  88. "NetpNumberOfConfigKeywords: RegQueryInfoKey ret "
  89. FORMAT_LONG "; " FORMAT_DWORD " values and " FORMAT_DWORD
  90. " subkeys.\n", Error, NumberOfValues, NumberOfSubKeys ));
  91. }
  92. if (Error != ERROR_SUCCESS) {
  93. NetpAssert( Error == ERROR_SUCCESS );
  94. return (Error);
  95. }
  96. NetpAssert( NumberOfSubKeys == 0 );
  97. Count = NumberOfValues;
  98. ApiStatus = NO_ERROR;
  99. }
  100. *CountPtr = Count;
  101. IF_DEBUG(CONFIG) {
  102. NetpKdPrint(( PREFIX_NETLIB
  103. "NetpNumberOfConfigKeywords: returning " FORMAT_DWORD
  104. " for number of keywords.\n", Count ));
  105. }
  106. return (ApiStatus);
  107. }