What-ho,<br><br> I'm *still* hammering away at this one...still no luck
<br><br> My idea is that I can write a little test app that goes off to a remote machine, running Windows NT4.0 and retrieve its CPU load, the same as task mangler does for your local machine. I'm trying to do it through API calls (the ADVAPI32.DLL API), using the RegCloseKey, RegConnectRegistry, RegOpenKeyEx and RegQueryValueEx functions to connect to the remote machines' HKEY_DYN_DATA key. Admitedly, under WinNT, I should be connecting to the HKEY_PERFORMANCE_DATA key, but my NT machines don't have this key and my code doesn't work either way.<br><br> If anyone can help me here, I'll buy them an e-pint
<br><br> Cheers very much,<br><br>Paul<br><br><br>Here's my code; good luck out there...<br><br>'(General)<br>Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long<br>Private Declare Function RegConnectRegistry Lib "advapi32.dll" Alias "RegConnectRegistryA" (ByVal lpMachineName As String, ByVal hKey As Long, phkResult As Long) As Long<br>Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long<br>Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long<br><br>'Defined Keys<br>Private Const HKEY_CLASSES_ROOT = &H80000000<br>Private Const HKEY_CURRENT_USER = &H80000001<br>Private Const HKEY_LOCAL_MACHINE = &H80000002<br>Private Const HKEY_USERS = &H80000003<br>Private Const HKEY_PERFORMANCE_DATA = &H80000004<br>Private Const HKEY_DYN_DATA = &H80000006<br>Private Const HKEY_CURRENT_CONFIG = &H80000005<br><br>'Constant for reading registry key<br>Private Const KEY_QUERY_VALUE = &H1<br><br><br>Private Sub Command1_Click()<br>Dim strServerName As String<br>Dim strSubKey As String<br>Dim strValueName As String<br>Dim lhRemoteRegistry As Long<br>Dim lhRemoteRegistryKey As Long<br>Dim sKeyValueBuffer As String<br>Dim lsKeyValueBufferSize As Long<br><br>' strSubKey = "PerfStats\\StopStat" & Chr(0)<br> strSubKey = "PerfStats\\StartStat" & Chr(0)<br>' strSubKey = vbNullString & Chr(0)<br>' strValueName = "" & Chr(0)<br> strValueName = "KERNEL\\CPUUsage" & Chr(0)<br> strServerName = "\\wts-gr-ws004" & Chr(0)<br> <br> lReturnCode = RegConnectRegistry(strServerName, HKEY_PERFORMANCE_DATA, lhRemoteRegistry)<br>' lReturnCode = RegConnectRegistry(strServerName, HKEY_LOCAL_MACHINE, lhRemoteRegistry)<br> Me.Label1.Caption = lReturnCode<br> Me.Label6.Caption = lhRemoteRegistry<br> <br>' lReturnCode = RegOpenKeyEx(HKEY_PERFORMANCE_DATA, strSubKey, 0&, KEY_QUERY_VALUE, lhRemoteRegistryKey)<br> lReturnCode = RegOpenKeyEx(lhRemoteRegistry, strSubKey, 0&, KEY_QUERY_VALUE, lhRemoteRegistryKey)<br> Me.Label2.Caption = lReturnCode<br> <br> sKeyValueBuffer$ = Space$(10)<br> lsKeyValueBufferSize& = Len(sKeyValueBuffer)<br> lReturnCode = RegQueryValueEx(lhRemoteRegistryKey, strValueName, 0&, 0&, ByVal sKeyValueBuffer, lsKeyValueBufferSize)<br> Me.Label3.Caption = lReturnCode<br> Me.Text1.Text = sKeyValueBuffer<br> <br> 'Close keys<br> lReturnCode = RegCloseKey(lhRemoteRegistryKey)<br> Me.Label4.Caption = lReturnCode<br> <br> lReturnCode = RegCloseKey(lhRemoteRegistry)<br> Me.Label5.Caption = lReturnCode<br><br>End Sub<br><br>Private Sub Form_Load()<br><br> Me.Label1.Caption = vbNullString<br> Me.Label2.Caption = vbNullString<br> Me.Label3.Caption = vbNullString<br> Me.Label4.Caption = vbNullString<br> Me.Label5.Caption = vbNullString<br> Me.Label6.Caption = vbNullString<br> <br><br>End Sub<br><br><br>The form is a standard form with a textbox (text1), command button (Command1) and six labels (label1 to 6) on it, in an arrangement of your choice...