Jump to content

scottymiles

Members
  • Posts

    6
  • Joined

  • Last visited

scottymiles's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Finally got it all working perfect! My problem was that I didn't need to pass the path into _PDH_UpdateCounterArray(). Once I took that out it started working great! Thank you so much for your help Ascendant! You're the best! Your code has been extremely useful and is working very efficiently! Thank you again!!!! Scott.
  2. Ohhhhh... I was under the impression I was meant to use _PDH_ProcessStats() in conjunction with _PDH_UpdateCounterArray(), but this makes more sense. A few things I've run into: $aProcessArray=_PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHPIDCounterHandle,":230\784\(*)\" & $pc, 1)If I pass in the true value like you say, i get a NULL reference runtime error: The instruction at "0x64002baa" referenced memory at "0x00000004". The memory could not be "read". The debugging the exe gives me the line: 74002BAA mov ecx,dword ptr [eax+4] However, if I run the code as: $aProcessArray=_PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHPIDCounterHandle,":230\784\(*)", 1)It will compile and run fine, returning the stats of the local PC processes. Is ":230\784\(*)\" & $pc in the wrong syntax or am I doing something else wrong? Also for note: $aProcessArray=_PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHPIDCounterHandle,":230\784\(*)\" & $pc)This (without the true value) compiles and runs fine, however still returns the local stats. By the way, I have tried suplimenting $pc with both PC name and IP and always get the same results. Thanks for your help. Scott.
  3. Ummm... let's assume that I correctly declared all those variables at a class scope, instead of at a function level
  4. Ascendant, Thank you very much for putting your time into this I have only had a brief look at the code, but knowing where to start has made this a lot clearer to me! (I don't know why I didn't do a search for "init") As I said, I've only had a quick look and haven't tried to compile anything, but would something like this work: Func GetProcessList($pc) $hPDHQueryHandle=_PDH_GetNewQueryHandle() $hPDHPIDCounterHandle=_PDH_AddCounter($hPDHQueryHandle,":230\784\(*)\" & $pc) $hPDHCPUCounterHandle=_PDH_AddCounter($hPDHQueryHandle,":230\6\(*)\" & $pc) $hPDHPPIDCounterHandle=_PDH_AddCounter($hPDHQueryHandle,":230\1410\(*)\" & $pc) $hPDHMemCounterHandle=_PDH_AddCounter($hPDHQueryHandle,":230\180\(*)\" & $pc) $hPDHTimeCounterHandle=_PDH_AddCounter($hPDHQueryHandle,":230\684\(*)\" & $pc) $aProcessArray _PDH_ProcessStats($hPDHQueryHandle,$aProcessArray, _ $hPDHPIDCounterHandle,$hPDHPPIDCounterHandle,$hPDHCPUCounterHandle,$hPDHMemCounterHandle,$hPDHTimeCounterHandle,1) If @error Then Terminate("Get Process List Fail") EndIf $aProcessArray[0][0]="Process Name" $aProcessArray[0][1]="Process ID" $aProcessArray[0][2]="Parent PID" $aProcessArray[0][3]="CPU Usage" $aProcessArray[0][4]="Memory Usage" $aProcessArray[0][5]="Process Creation FileTime +\- 1 sec" $aProcessArray[0][6]="Process Creation Time +\- 1 sec" EndFunc Func UpdateProcessList($pc) _PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHPIDCounterHandle,":230\784\(*)\" & $pc) _PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHCPUCounterHandle,":230\6\(*)\" & $pc) _PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHPPIDCounterHandle,":230\1410\(*)\" & $pc) _PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHMemCounterHandle,":230\180\(*)\" & $pc) _PDH_UpdateCounterArray($hPDHQueryHandle,$hPDHTimeCounterHandle,":230\684\(*)\" & $pc) EndFunc Func WriteProcessInfo() ;Search array for required process ;Write desired info to file EndFunc Is this the best approach? (assuming that this is even remotely correct ) Thank you again for all your help! Scott.
  5. Also - If I wanted to modify this to check the same stats on a remote PC (connected on the same LAN) what would be I need to do? Thanks again. Scott.
  6. Hi, First of all, thank you very Ascendant much for providing us with this source code! I am a very primitive programmer and I am just writing a small AutoIT script that logs memory usage to a file. What you've written looks like it will do exactly what I intend, however it is so far beyond me that I don't even know where to begin :S Assuming I've included the appropriate dendancies and have a file output structure set up, what would be the simpilest way to get a string return of the PID, Mem Usage and CPU Usage of a single process (identified by Process Name). Thank you for any assistance you can provide. Scott.
×
×
  • Create New...