home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / center2g / modpdhms.bas < prev    next >
Encoding:
BASIC Source File  |  1998-02-17  |  17.2 KB  |  664 lines

  1. Attribute VB_Name = "modPdhMsg"
  2. '   Event message definititions used by routines by PDH.DLL
  3. '
  4. '     PDH DLL messages
  5. '
  6. '
  7. '      Success Messages
  8. '
  9. '         the Win32 error value ERROR_SUCCESS is used for success returns
  10. '
  11. '      MESSAGE NAME FORMAT
  12. '
  13. '          PDH_CSTATUS_...   messages are data item status message and
  14. '                     are returned in reference to the status of a data
  15. '                     item
  16. '          PDH_...           messages are returned by FUNCTIONS only and
  17. '                     not used as data item status values
  18. '
  19. '      Success Messages
  20. '         These messages are normally returned when the operation completed
  21. '         successfully.
  22. '
  23. '
  24. '  Values are 32 bit values layed out as follows:
  25. '
  26. '   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  27. '   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  28. '  +---+-+-+-----------------------+-------------------------------+
  29. '  |Sev|C|R|     Facility          |               Code            |
  30. '  +---+-+-+-----------------------+-------------------------------+
  31. '
  32. '  where
  33. '
  34. '      Sev - is the severity code
  35. '
  36. '          00 - Success
  37. '          01 - Informational
  38. '          10 - Warning
  39. '          11 - Error
  40. '
  41. '      C - is the Customer code flag
  42. '
  43. '      R - is a reserved bit
  44. '
  45. '      Facility - is the facility code
  46. '
  47. '      Code - is the facility's status code
  48. '
  49. '
  50. ' Define the facility codes
  51. '
  52.  
  53.  
  54. '
  55. ' Define the severity codes
  56. '
  57. Public Const STATUS_SEVERITY_WARNING = &H2
  58. Public Const STATUS_SEVERITY_SUCCESS = &H0
  59. Public Const STATUS_SEVERITY_INFORMATIONAL = &H1
  60. Public Const STATUS_SEVERITY_ERROR = &H3
  61.  
  62.  
  63. '
  64. ' MessageId: PDH_CSTATUS_VALID_DATA
  65. '
  66. ' MessageText:
  67. '
  68. '  The returned data is valid.
  69. '
  70. Public Const PDH_CSTATUS_VALID_DATA = &H0
  71.  
  72. '
  73. ' MessageId: PDH_CSTATUS_NEW_DATA
  74. '
  75. ' MessageText:
  76. '
  77. '  The return data value is valid and different from the last sample.
  78. '
  79. Public Const PDH_CSTATUS_NEW_DATA = &H1
  80.  
  81. '
  82. '        Informational messages
  83. '
  84. '  None
  85. '
  86. '      Warning Messages
  87. '         These messages are returned when the function has completed
  88. '         successfully but the results may be different than expected.
  89. '
  90. '
  91. ' MessageId: PDH_CSTATUS_NO_MACHINE
  92. '
  93. ' MessageText:
  94. '
  95. '  Unable to connect to specified machine or machine is off line.
  96. '
  97. Public Const PDH_CSTATUS_NO_MACHINE = &H800007D0
  98.  
  99. '
  100. ' MessageId: PDH_CSTATUS_NO_INSTANCE
  101. '
  102. ' MessageText:
  103. '
  104. '  The specified instance is not present.
  105. '
  106. Public Const PDH_CSTATUS_NO_INSTANCE = &H800007D1
  107.  
  108. '
  109. ' MessageId: PDH_MORE_DATA
  110. '
  111. ' MessageText:
  112. '
  113. '  There is more data to return than would fit in the supplied buffer. Allocate
  114. '  a larger buffer and call the function again.
  115. '
  116. Public Const PDH_MORE_DATA = &H800007D2
  117.  
  118. '
  119. ' MessageId: PDH_CSTATUS_ITEM_NOT_VALIDATED
  120. '
  121. ' MessageText:
  122. '
  123. '  The data item has been added to the query, but has not been validated nor
  124. '  accessed. No other status information on this data item is available.
  125. '
  126. Public Const PDH_CSTATUS_ITEM_NOT_VALIDATED = &H800007D3
  127.  
  128. '
  129. ' MessageId: PDH_RETRY
  130. '
  131. ' MessageText:
  132. '
  133. '  The selected operation should be retried.
  134. '
  135. Public Const PDH_RETRY = &H800007D4
  136.  
  137. '
  138. ' MessageId: PDH_NO_DATA
  139. '
  140. ' MessageText:
  141. '
  142. '  No data to return.
  143. '
  144. Public Const PDH_NO_DATA = &H800007D5
  145.  
  146. '
  147. ' MessageId: PDH_CALC_NEGATIVE_DENOMINATOR
  148. '
  149. ' MessageText:
  150. '
  151. '  A counter with a negative denominator value was detected.
  152. '
  153. Public Const PDH_CALC_NEGATIVE_DENOMINATOR = &H800007D6
  154.  
  155. '
  156. ' MessageId: PDH_CALC_NEGATIVE_TIMEBASE
  157. '
  158. ' MessageText:
  159. '
  160. '  A counter with a negative timebase value was detected.
  161. '
  162. Public Const PDH_CALC_NEGATIVE_TIMEBASE = &H800007D7
  163.  
  164. '
  165. ' MessageId: PDH_CALC_NEGATIVE_VALUE
  166. '
  167. ' MessageText:
  168. '
  169. '  A counter with a negative value was detected.
  170. '
  171. Public Const PDH_CALC_NEGATIVE_VALUE = &H800007D8
  172.  
  173. '
  174. ' MessageId: PDH_DIALOG_CANCELLED
  175. '
  176. ' MessageText:
  177. '
  178. '  The user cancelled the dialog box.
  179. '
  180. Public Const PDH_DIALOG_CANCELLED = &H800007D9
  181.  
  182. '
  183. ' MessageId: PDH_END_OF_LOG_FILE
  184. '
  185. ' MessageText:
  186. '
  187. '  The end of the log file was reached.
  188. '
  189. Public Const PDH_END_OF_LOG_FILE = &H800007DA
  190.  
  191. '
  192. '     Error Messages
  193. '        These messages are returned when the function could not complete
  194. '        as requested and some corrective action may be required by the
  195. '        the caller or the user.
  196. '
  197. '
  198. ' MessageId: PDH_CSTATUS_NO_OBJECT
  199. '
  200. ' MessageText:
  201. '
  202. '  The specified object is not found on the system.
  203. '
  204. Public Const PDH_CSTATUS_NO_OBJECT = &HC0000BB8
  205.  
  206. '
  207. ' MessageId: PDH_CSTATUS_NO_COUNTER
  208. '
  209. ' MessageText:
  210. '
  211. '  The specified counter could not be found.
  212. '
  213. Public Const PDH_CSTATUS_NO_COUNTER = &HC0000BB9
  214.  
  215. '
  216. ' MessageId: PDH_CSTATUS_INVALID_DATA
  217. '
  218. ' MessageText:
  219. '
  220. '  The returned data is not valid.
  221. '
  222. Public Const PDH_CSTATUS_INVALID_DATA = &HC0000BBA
  223.  
  224. '
  225. ' MessageId: PDH_MEMORY_ALLOCATION_FAILURE
  226. '
  227. ' MessageText:
  228. '
  229. '  A PDH function could not allocate enough temporary memory to complete the
  230. '  operation. Close some applications or extend the pagefile and retry the
  231. '  function.
  232. '
  233. Public Const PDH_MEMORY_ALLOCATION_FAILURE = &HC0000BBB
  234.  
  235. '
  236. ' MessageId: PDH_INVALID_HANDLE
  237. '
  238. ' MessageText:
  239. '
  240. '  The handle is not a valid PDH object.
  241. '
  242. Public Const PDH_INVALID_HANDLE = &HC0000BBC
  243.  
  244. '
  245. ' MessageId: PDH_INVALID_ARGUMENT
  246. '
  247. ' MessageText:
  248. '
  249. '  A required argument is missing or incorrect.
  250. '
  251. Public Const PDH_INVALID_ARGUMENT = &HC0000BBD
  252.  
  253. '
  254. ' MessageId: PDH_FUNCTION_NOT_FOUND
  255. '
  256. ' MessageText:
  257. '
  258. '  Unable to find the specified function.
  259. '
  260. Public Const PDH_FUNCTION_NOT_FOUND = &HC0000BBE
  261.  
  262. '
  263. ' MessageId: PDH_CSTATUS_NO_COUNTERNAME
  264. '
  265. ' MessageText:
  266. '
  267. '  No counter was specified.
  268. '
  269. Public Const PDH_CSTATUS_NO_COUNTERNAME = &HC0000BBF
  270.  
  271. '
  272. ' MessageId: PDH_CSTATUS_BAD_COUNTERNAME
  273. '
  274. ' MessageText:
  275. '
  276. '  Unable to parse the counter path. Check the format and syntax of the
  277. '  specified path.
  278. '
  279. Public Const PDH_CSTATUS_BAD_COUNTERNAME = &HC0000BC0
  280.  
  281. '
  282. ' MessageId: PDH_INVALID_BUFFER
  283. '
  284. ' MessageText:
  285. '
  286. '  The buffer passed by the caller is invalid.
  287. '
  288. Public Const PDH_INVALID_BUFFER = &HC0000BC1
  289.  
  290. '
  291. ' MessageId: PDH_INSUFFICIENT_BUFFER
  292. '
  293. ' MessageText:
  294. '
  295. '  The requested data is larger than the buffer supplied. Unable to return the
  296. '  requested data.
  297. '
  298. Public Const PDH_INSUFFICIENT_BUFFER = &HC0000BC2
  299.  
  300. '
  301. ' MessageId: PDH_CANNOT_CONNECT_MACHINE
  302. '
  303. ' MessageText:
  304. '
  305. '  Unable to connect to the requested machine.
  306. '
  307. Public Const PDH_CANNOT_CONNECT_MACHINE = &HC0000BC3
  308.  
  309. '
  310. ' MessageId: PDH_INVALID_PATH
  311. '
  312. ' MessageText:
  313. '
  314. '  The specified counter path could not be interpreted.
  315. '
  316. Public Const PDH_INVALID_PATH = &HC0000BC4
  317.  
  318. '
  319. ' MessageId: PDH_INVALID_INSTANCE
  320. '
  321. ' MessageText:
  322. '
  323. '  The instance name could not be read from the specified counter path.
  324. '
  325. Public Const PDH_INVALID_INSTANCE = &HC0000BC5
  326.  
  327. '
  328. ' MessageId: PDH_INVALID_DATA
  329. '
  330. ' MessageText:
  331. '
  332. '  The data is not valid.
  333. '
  334. Public Const PDH_INVALID_DATA = &HC0000BC6
  335.  
  336. '
  337. ' MessageId: PDH_NO_DIALOG_DATA
  338. '
  339. ' MessageText:
  340. '
  341. '  The dialog box data block was missing or invalid.
  342. '
  343. Public Const PDH_NO_DIALOG_DATA = &HC0000BC7
  344.  
  345. '
  346. ' MessageId: PDH_CANNOT_READ_NAME_STRINGS
  347. '
  348. ' MessageText:
  349. '
  350. '  Unable to read the counter and/or explain text from the specified machine.
  351. '
  352. Public Const PDH_CANNOT_READ_NAME_STRINGS = &HC0000BC8
  353.  
  354. '
  355. ' MessageId: PDH_LOG_FILE_CREATE_ERROR
  356. '
  357. ' MessageText:
  358. '
  359. '  Unable to create the specified log file.
  360. '
  361. Public Const PDH_LOG_FILE_CREATE_ERROR = &HC0000BC9
  362.  
  363. '
  364. ' MessageId: PDH_LOG_FILE_OPEN_ERROR
  365. '
  366. ' MessageText:
  367. '
  368. '  Unable to open the specified log file.
  369. '
  370. Public Const PDH_LOG_FILE_OPEN_ERROR = &HC0000BCA
  371.  
  372. '
  373. ' MessageId: PDH_LOG_TYPE_NOT_FOUND
  374. '
  375. ' MessageText:
  376. '
  377. '  The specified log file type has not been installed on this system.
  378. '
  379. Public Const PDH_LOG_TYPE_NOT_FOUND = &HC0000BCB
  380.  
  381. '
  382. ' MessageId: PDH_NO_MORE_DATA
  383. '
  384. ' MessageText:
  385. '
  386. '  No more data is available.
  387. '
  388. Public Const PDH_NO_MORE_DATA = &HC0000BCC
  389.  
  390. '
  391. ' MessageId: PDH_ENTRY_NOT_IN_LOG_FILE
  392. '
  393. ' MessageText:
  394. '
  395. '  The specified record was not found in the log file.
  396. '
  397. Public Const PDH_ENTRY_NOT_IN_LOG_FILE = &HC0000BCD
  398.  
  399. '
  400. ' MessageId: PDH_DATA_SOURCE_IS_LOG_FILE
  401. '
  402. ' MessageText:
  403. '
  404. '  The specified data source is a log file.
  405. '
  406. Public Const PDH_DATA_SOURCE_IS_LOG_FILE = &HC0000BCE
  407.  
  408. '
  409. ' MessageId: PDH_DATA_SOURCE_IS_REAL_TIME
  410. '
  411. ' MessageText:
  412. '
  413. '  The specified data source is the current activity.
  414. '
  415. Public Const PDH_DATA_SOURCE_IS_REAL_TIME = &HC0000BCF
  416.  
  417. '
  418. ' MessageId: PDH_UNABLE_READ_LOG_HEADER
  419. '
  420. ' MessageText:
  421. '
  422. '  The log file header could not be read.
  423. '
  424. Public Const PDH_UNABLE_READ_LOG_HEADER = &HC0000BD0
  425.  
  426. '
  427. ' MessageId: PDH_FILE_NOT_FOUND
  428. '
  429. ' MessageText:
  430. '
  431. '  Unable to find the specified file.
  432. '
  433. Public Const PDH_FILE_NOT_FOUND = &HC0000BD1
  434.  
  435. '
  436. ' MessageId: PDH_FILE_ALREADY_EXISTS
  437. '
  438. ' MessageText:
  439. '
  440. '  There is already a file with the specified file name.
  441. '
  442. Public Const PDH_FILE_ALREADY_EXISTS = &HC0000BD2
  443.  
  444. '
  445. ' MessageId: PDH_NOT_IMPLEMENTED
  446. '
  447. ' MessageText:
  448. '
  449. '  The function referenced has not been implemented.
  450. '
  451. Public Const PDH_NOT_IMPLEMENTED = &HC0000BD3
  452.  
  453. '
  454. ' MessageId: PDH_STRING_NOT_FOUND
  455. '
  456. ' MessageText:
  457. '
  458. '  Unable to find the specified string in the list of performance name and
  459. '  explain text strings.
  460. '
  461. Public Const PDH_STRING_NOT_FOUND = &HC0000BD4
  462.  
  463. '
  464. ' MessageId: PDH_UNABLE_MAP_NAME_FILES
  465. '
  466. ' MessageText:
  467. '
  468. '  Unable to map to the performance counter name data files. The data
  469. '  will be read from the registry and stored locally.
  470. '
  471. Public Const PDH_UNABLE_MAP_NAME_FILES = &H80000BD5
  472.  
  473. '
  474. ' MessageId: PDH_UNKNOWN_LOG_FORMAT
  475. '
  476. ' MessageText:
  477. '
  478. '  The format of the specified log file is not recognized by the PDH DLL.
  479. '
  480. Public Const PDH_UNKNOWN_LOG_FORMAT = &HC0000BD6
  481.  
  482. '
  483. ' MessageId: PDH_UNKNOWN_LOGSVC_COMMAND
  484. '
  485. ' MessageText:
  486. '
  487. '  The specified Log Service command value is not recognized.
  488. '
  489. Public Const PDH_UNKNOWN_LOGSVC_COMMAND = &HC0000BD7
  490.  
  491. '
  492. ' MessageId: PDH_LOGSVC_QUERY_NOT_FOUND
  493. '
  494. ' MessageText:
  495. '
  496. '  The specified Query from the Log Service could not be found or could not
  497. '  be opened.
  498. '
  499. Public Const PDH_LOGSVC_QUERY_NOT_FOUND = &HC0000BD8
  500.  
  501. '
  502. ' MessageId: PDH_LOGSVC_NOT_OPENED
  503. '
  504. ' MessageText:
  505. '
  506. '  The Performance Data Log Service key could not be opened. This may be due
  507. '  to insufficient privilege or because the service has not been installed.
  508. '
  509. Public Const PDH_LOGSVC_NOT_OPENED = &HC0000BD9
  510.  
  511. Public Function GetPdhReturn(ByVal PdhReturnCode As Long) As String
  512.     If PdhReturnCode And STATUS_SEVERITY_INFORMATIONAL Then Debug.Print "Informational"
  513.     If PdhReturnCode And STATUS_SEVERITY_WARNING Then Debug.Print "Warning"
  514.     If PdhReturnCode And STATUS_SEVERITY_ERROR Then
  515.         Select Case PdhReturnCode
  516.             Case PDH_CSTATUS_VALID_DATA
  517.                 GetPdhReturn = "The returned data is valid."
  518.     
  519.             Case PDH_CSTATUS_NEW_DATA
  520.                 GetPdhReturn = "The return data value is valid and different from the last sample."
  521.     
  522.     
  523.             Case PDH_CSTATUS_NO_MACHINE
  524.                 GetPdhReturn = "Unable to connect to specified machine or machine is off line."
  525.     
  526.             Case PDH_CSTATUS_NO_INSTANCE
  527.                 GetPdhReturn = "The specified instance is not present."
  528.     
  529.             Case PDH_MORE_DATA
  530.                 GetPdhReturn = "There is more data to return than would fit in the supplied buffer. Allocate a larger buffer and call the function again."
  531.     
  532.             Case PDH_CSTATUS_ITEM_NOT_VALIDATED
  533.                 GetPdhReturn = "The data item has been added to the query, but has not been validated nor accessed. No other status information on this data item is available."
  534.     
  535.             Case PDH_RETRY
  536.                 GetPdhReturn = "The selected operation should be retried."
  537.     
  538.             Case PDH_NO_DATA
  539.                 GetPdhReturn = "No data to return."
  540.     
  541.             Case PDH_CALC_NEGATIVE_DENOMINATOR
  542.                 GetPdhReturn = "A counter with a negative denominator value was detected."
  543.     
  544.             Case PDH_CALC_NEGATIVE_TIMEBASE
  545.                 GetPdhReturn = "A counter with a negative timebase value was detected."
  546.     
  547.             Case PDH_CALC_NEGATIVE_VALUE
  548.                 GetPdhReturn = "A counter with a negative value was detected."
  549.     
  550.             Case PDH_DIALOG_CANCELLED
  551.                 GetPdhReturn = "The user cancelled the dialog box."
  552.     
  553.             Case PDH_END_OF_LOG_FILE
  554.                 GetPdhReturn = "The end of the log file was reached."
  555.     
  556.             Case PDH_CSTATUS_NO_OBJECT
  557.                 GetPdhReturn = "The specified object is not found on the system."
  558.     
  559.             Case PDH_CSTATUS_NO_COUNTER
  560.                 GetPdhReturn = "The specified counter could not be found."
  561.     
  562.             Case PDH_CSTATUS_INVALID_DATA
  563.                 GetPdhReturn = "The returned data is not valid."
  564.     
  565.             Case PDH_MEMORY_ALLOCATION_FAILURE
  566.                 GetPdhReturn = "A PDH function could not allocate enough temporary memory to complete the operation. Close some applications or extend the pagefile and retry the function."
  567.     
  568.             Case PDH_INVALID_HANDLE
  569.                 GetPdhReturn = "The handle is not a valid PDH object."
  570.     
  571.             Case PDH_INVALID_ARGUMENT
  572.                 GetPdhReturn = "A required argument is missing or incorrect."
  573.     
  574.             Case PDH_FUNCTION_NOT_FOUND
  575.                 GetPdhReturn = "Unable to find the specified function."
  576.     
  577.             Case PDH_CSTATUS_NO_COUNTERNAME
  578.                 GetPdhReturn = "No counter was specified."
  579.     
  580.             Case PDH_CSTATUS_BAD_COUNTERNAME
  581.                 GetPdhReturn = "Unable to parse the counter path. Check the format and syntax of the specified path."
  582.     
  583.             Case PDH_INVALID_BUFFER
  584.                 GetPdhReturn = "The buffer passed by the caller is invalid."
  585.     
  586.             Case PDH_INSUFFICIENT_BUFFER
  587.                 GetPdhReturn = "The requested data is larger than the buffer supplied. Unable to return the requested data."
  588.     
  589.             Case PDH_CANNOT_CONNECT_MACHINE
  590.                 GetPdhReturn = "Unable to connect to the requested machine."
  591.     
  592.             Case PDH_INVALID_PATH
  593.                 GetPdhReturn = "The specified counter path could not be interpreted."
  594.     
  595.             Case PDH_INVALID_INSTANCE
  596.                 GetPdhReturn = "The instance name could not be read from the specified counter path."
  597.     
  598.             Case PDH_INVALID_DATA
  599.                 GetPdhReturn = "The data is not valid."
  600.     
  601.             Case PDH_NO_DIALOG_DATA
  602.                 GetPdhReturn = "The dialog box data block was missing or invalid."
  603.     
  604.             Case PDH_CANNOT_READ_NAME_STRINGS
  605.                 GetPdhReturn = "Unable to read the counter and/or explain text from the specified machine."
  606.     
  607.             Case PDH_LOG_FILE_CREATE_ERROR
  608.                 GetPdhReturn = "Unable to create the specified log file."
  609.     
  610.             Case PDH_LOG_FILE_OPEN_ERROR
  611.                 GetPdhReturn = "Unable to open the specified log file."
  612.     
  613.             Case PDH_LOG_TYPE_NOT_FOUND
  614.                 GetPdhReturn = "The specified log file type has not been installed on this system."
  615.     
  616.             Case PDH_NO_MORE_DATA
  617.                 GetPdhReturn = "No more data is available."
  618.     
  619.             Case PDH_ENTRY_NOT_IN_LOG_FILE
  620.                 GetPdhReturn = "The specified record was not found in the log file."
  621.     
  622.             Case PDH_DATA_SOURCE_IS_LOG_FILE
  623.                 GetPdhReturn = "The specified data source is a log file."
  624.     
  625.             Case PDH_DATA_SOURCE_IS_REAL_TIME
  626.                 GetPdhReturn = "The specified data source is the current activity."
  627.     
  628.             Case PDH_UNABLE_READ_LOG_HEADER
  629.                 GetPdhReturn = "The log file header could not be read."
  630.     
  631.             Case PDH_FILE_NOT_FOUND
  632.                 GetPdhReturn = "Unable to find the specified file."
  633.     
  634.             Case PDH_FILE_ALREADY_EXISTS
  635.                 GetPdhReturn = "There is already a file with the specified file name."
  636.     
  637.             Case PDH_NOT_IMPLEMENTED
  638.                 GetPdhReturn = "The function referenced has not been implemented."
  639.     
  640.             Case PDH_STRING_NOT_FOUND
  641.                 GetPdhReturn = "Unable to find the specified string in the list of performance name and explain text strings."
  642.     
  643.             Case PDH_UNABLE_MAP_NAME_FILES
  644.                 GetPdhReturn = "Unable to map to the performance counter name data files. The data will be read from the registry and stored locally."
  645.     
  646.             Case PDH_UNKNOWN_LOG_FORMAT
  647.                 GetPdhReturn = "The format of the specified log file is not recognized by the PDH DLL."
  648.     
  649.             Case PDH_UNKNOWN_LOGSVC_COMMAND
  650.                 GetPdhReturn = "The specified Log Service command value is not recognized."
  651.     
  652.             Case PDH_LOGSVC_QUERY_NOT_FOUND
  653.                 GetPdhReturn = "The specified Query from the Log Service could not be found or could not be opened."
  654.     
  655.             Case PDH_LOGSVC_NOT_OPENED
  656.                 GetPdhReturn = "The Performance Data Log Service key could not be opened. This may be due to insufficient privilege or because the service has not been installed."
  657.             Case Else
  658.                 GetPdhReturn = "PDH Function could not be executed"
  659.         End Select
  660.     End If
  661. End Function
  662.  
  663.  
  664.