VenMon - PC Monitoring Software

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VenMon - PC Monitoring Software

Post by oreopa »

Hi Ventural.

I am using Win 7 Pro, classic theming, and 100% DPI settings. If you cant get to the bottom of it, I'll try to replicate it.

EDIT: To illustrate - https://www.dropbox.com/s/cupfst6zr9bx6 ... 1.png?dl=0 - seems to occur when toggling between floating window modes.
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: VenMon - PC Monitoring Software

Post by Lord »

Nice program!

But I got two questions:

1. Where do I enable or change update intervall for processor load?
See picture #1. There is an update time (?) of 1090 seconds displayed,
but nothing happend after this time.
Image

2. What is the meaning of read only text for "Optimization" in tab "Settings"?
See picture #2 (red arrow).
Image
Is there any help file coming?
Image
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

Lord wrote: 1. Where do I enable or change update intervall for processor load?
See picture #1. There is an update time (?) of 1090 seconds displayed,
but nothing happend after this time.
1090 seconds or 18.2 minutes is the length of each cpu graph. The more processor cores, the smaller the graphs will be and shorter the time period. Regardless of the time length, it should be updating the processor info every 2 to 3 seconds. It's very strange that the cpu field is completely blank in the mini-window because I have a backup routine that should have kicked in with basic info. I'll have to look into it more when I get a chance, maybe add some debug info that will appear on the screen if the load%, handle, threads, processes are all zero.
Lord wrote: 2. What is the meaning of read only text for "Optimization" in tab "Settings"?
See picture #2 (red arrow).
Is there any help file coming?
It represents the total number of entries in each of the other dialog boxes. Not sure if I want to keep that little info box or disable it in the future. Numbers represent: Physical, Pagefile, CPU Speed, Battery %, Idle, Storage, Storage Monitor, Networks, Network Events, then a slash followed by the current limit. If the Extended box is checked in Optimizations, it jumps from 500 to 9999.

Yes, have been working on the help file, but it's not ready as I keep making changes and additions to the program.
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

oreopa wrote:Hi Ventural.

I am using Win 7 Pro, classic theming, and 100% DPI settings. If you cant get to the bottom of it, I'll try to replicate it.

EDIT: To illustrate - https://www.dropbox.com/s/cupfst6zr9bx6 ... 1.png?dl=0 - seems to occur when toggling between floating window modes.
Should be fixed in the latest version (2.15), please try it out and make sure it works on your system when you have a chance. My work PC (Windows 7 Pro) was experiencing the same issues in both Aero and Classic themes, either missing or unaligned text after going back and forth between borderless and normal a few times.
http://www.ventural.com/venmon
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: VenMon - PC Monitoring Software

Post by oreopa »

Ventural wrote:Should be fixed in the latest version (2.15), please try it out and make sure it works on your system when you have a chance. My work PC (Windows 7 Pro) was experiencing the same issues in both Aero and Classic themes, either missing or unaligned text after going back and forth between borderless and normal a few times.
http://www.ventural.com/venmon

Thanx Ventural. 2.15 fixes the issue.

I'm still experiencing problems with it not remembering the window position between runs.
Proud supporter of PB! * Musician * C64/6502 Freak
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

Updated to v2.16
http://www.ventural.com/venmon
--
Venmon 2.16 - Added: All graphs now display current values below title name.

Added: Option to remember window positions for Main and Mini with x,y locations shown in settings page.

Added: Program will switch to portable mode if cannot find Venmon.ini in the default folder and if not running from booted Windows drive.

Added: Storage Monitor will now display and save a log entry when it detects a partition size change.

Fixed: In event of lost or ejected drive, Storage Monitor will report last known Volume Serial instead of current 0000-0000.
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: VenMon - PC Monitoring Software

Post by Lord »

Hi Ventural!
Ventural wrote:Updated to v2.16
...
Fixed: In event of lost or ejected drive, Storage Monitor will report last known Volume Serial instead of current 0000-0000.
Still no fix for this: http://www.purebasic.fr/english/viewtop ... 6&start=16 ?
Image
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: VenMon - PC Monitoring Software

Post by Fred »

Nice tool !
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

Lord wrote:Hi Ventural!
Still no fix for this: http://www.purebasic.fr/english/viewtop ... 6&start=16 ?
Which OS are you using? Looks like Windows 7? My work PC is using Win7 and has an Core i5, screenshot: https://imgur.com/4DD9AAg

The cpu usage relies on Performance Data Helper (Pdh.dll), if that file is missing, disabled, or not running, the program will not be able to pull data for the processors. Not sure what you can do to fix this, quick google search and I found:

Re-register the file by opening Command Prompt with Administrator rights and run:

Code: Select all

regsvr32 C:\Windows\System32\pdh.dll
then try System file checker:

Code: Select all

sfc /scannow
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: VenMon - PC Monitoring Software

Post by Lord »

Hi Ventural!
Ventural wrote:..
Which OS are you using? Looks like Windows 7?
...
I'm using Win7 Ultimate 64 SP1.
Ventural wrote:...
My work PC is using Win7 and has an Core i5, screenshot: https://imgur.com/4DD9AAg
...
My CPU can be seen here:
Image
Ventural wrote:...
The cpu usage relies on Performance Data Helper (Pdh.dll), if that file is missing, disabled, or not running, the program will not be able to pull data for the processors. Not sure what you can do to fix this, quick google search and I found:

Re-register the file by opening Command Prompt with Administrator rights and run:

Code: Select all

regsvr32 C:\Windows\System32\pdh.dll
then try System file checker:

Code: Select all

sfc /scannow
A 'sfc /scannow' before and after a 'regsvr' didn't state any problems,
but 'RegSvr' showed this error:
[Window Title]
RegSvr32

[Content]
Das Modul C:\Windows\System32\pdh.dll wurde geladen, aber der DllRegisterServer-Eingangspunkt wurde nicht gefunden.

Stellen Sie sicher, dass C:\Windows\System32\pdh.dll eine gültige .DLL- oder .OCX-Datei ist, und wiederholen Sie den Vorgang.

[OK]
Translation by deepl.com wrote:[Window title]
RegSvr32

[Content]
The module C:\Windows\System32\pdh.dll was loaded, but the DllRegisterServer input point was not found.

Make sure that C:\Windows\System32\pdh.dll is a valid.DLL or.OCX file and repeat the operation.

[OK]
I made a quick test with this:

Code: Select all

#phd_dll = 1
If OpenLibrary(1, "pdh.dll")
  cnt1.i=CountLibraryFunctions(#phd_dll)
  cnt2.i=0
  If cnt1
    If ExamineLibraryFunctions(#phd_dll)
      While NextLibraryFunction()
        *LFAddr=LibraryFunctionAddress()
        LFName.s=LibraryFunctionName()
        *FuncAddr=GetFunction(#phd_dll, LFName)
        Debug Hex(*LFAddr)+#TAB$+LFName+#TAB$+" -> "+#TAB$+StringField("ERROR, OK", Bool(*LFAddr=*FuncAddr)+1, ",")
        cnt2+1
      Wend
      If cnt1=cnt2
        Debug "Entry count is the same"
      Else
        Debug "Entry count differs"
      EndIf
      *FuncAddr=GetFunction(#phd_dll, "PdhGetDllVersion")
      Version.l=0
      If *FuncAddr
        If CallCFunctionFast(*FuncAddr, @Version)=#ERROR_SUCCESS
          Debug "Returned version of 'pdh.dll': "+Version
        Else
          Debug "No Version"
        EndIf
      Else
        Debug "No Version"
      EndIf
    EndIf
  EndIf
  CloseLibrary(#phd_dll)
  Else
  Debug "Couldn't open 'phd.dll'"
EndIf
I think, this shows that 'phd.dll' is up and working or i'm wrong?
Is your system allover 64 bit?
Image
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

Cpu usage % test code using pdh.dll

Please try this everyone. I welcome any suggestions or improvements.
All credit should be given to Author: Ascend4nt. I simply translated it for Purebasic.

Edit: Code Updated, Memsize.l was reset to the length of last lookup which caused it to fail the 2nd attempt of PdhLookupPerfNameByIndex and my temporary workaround broke non-US computers. Oops.

Code: Select all

#PDH_NO_DATA = $A00007D5              ;For CPU Usage %
#PDH_INVALID_HANDLE = $E0000BBC       ;For CPU Usage %

Prototype PdhLookupPerfNameByIndex(szMachineName.s, dwNameIndex.l, *szNameBuffer, *pcchNameBufferSize)
Global PdhLookupPerfNameByIndex.PdhLookupPerfNameByIndex, MemSize.l

Structure PDH_FMT_COUNTERVALUE        ;For CPU Usage %
  CStatus.l; As Long
  ;  case Cardinal of
  ;    0: (longValue: Integer);
  ;    1: (doubleValue: Double);
  ;    2: (largeValue: Int64);
  ;    3: (AnsiStringValue: PChar);
  ;    4: (WideStringValue: PWideChar);
  padding.l       ; As Long
  ulValueLow.l    ; As Long
  ulValueHigh.l   ; As Long
EndStructure
  
Procedure.s PDH_CounterName(CoreNum.s = "_Total")
  
  ;Good Result for English: \Processor(0)\% Processor Time
  
  Define *LPTSTR, Temp.s
  
  MemSize.l = 1024 ;Global Variable
  *LPTSTR = AllocateMemory(MemSize)
  If *LPTSTR
    If CoreNum.s = "-1"
      CoreNum.s = "_Total"
    EndIf
    If PdhLookupPerfNameByIndex(#Null$, 238, *LPTSTR, @MemSize) = 0
      Temp.s = "\" + PeekS(*LPTSTR, MemSize) + "(" + CoreNum.s + ")\"
      ;Debug PeekS(*LPTSTR, MemSize)
    EndIf
  EndIf
  FreeMemory(*LPTSTR)
  
  MemSize.l = 1024
  *LPTSTR = AllocateMemory(MemSize)
  If *LPTSTR
    If PdhLookupPerfNameByIndex(#Null$, 6, *LPTSTR, @MemSize) = 0
      Temp.s = Temp.s + PeekS(*LPTSTR, MemSize)
      ;Debug PeekS(*LPTSTR, MemSize)
    EndIf
  EndIf
  FreeMemory(*LPTSTR)
  
  Debug Temp.s
  ProcedureReturn Temp.s
  
EndProcedure

#PerformanceLib = 88 ;Temp #

If OpenLibrary(#PerformanceLib, "pdh.dll")
CompilerIf #PB_Compiler_Unicode
  PdhLookupPerfNameByIndex = GetFunction(#PerformanceLib, "PdhLookupPerfNameByIndexW")
CompilerElse
  PdhLookupPerfNameByIndex = GetFunction(#PerformanceLib, "PdhLookupPerfNameByIndexA")
CompilerEndIf
EndIf 

hQuery.l
hCounter.l

RESULT.q = PdhOpenQuery_( 0, 1, @hQuery )

If result = ERROR_SUCCESS
  Debug Result
  Debug hQuery
  Debug "Good!"
  Debug "------"
EndIf

NewList ProcessorUsage.l()

CpuCount.l = CountCPUs(#PB_System_CPUs)

For AddC.l = 0 To CpuCount - 1
  RESULT = PdhAddCounter_(hQuery, PDH_CounterName(Str(Addc)), 0, @hCounter)
  AddElement(ProcessorUsage())
  ProcessorUsage() = hCounter
  ;If result = ERROR_SUCCESS
  ;  Debug Result
  ;  Debug hCounter
  ;  Debug "Good!"
  ;  Debug "------"
  ;EndIf
Next AddC

retcode.d
lpValue.PDH_FMT_COUNTERVALUE

RESULT = PdhCollectQueryData_(hQuery)
Delay(250)
Debug "--- Begin Tests ---"

For i=1 To 40  ;Test Loop, 40 times
  RESULT = PdhCollectQueryData_(hQuery)
  If result = ERROR_SUCCESS
    Debug "Good Query! Run # " + Str(i)
  ElseIf result = #PDH_INVALID_HANDLE
    Debug "PDH_INVALID_HANDLE"
  ElseIf result = #PDH_NO_DATA
    Debug "#PDH_NO_DATA"
  Else
    Debug "Error "+Hex(Result)
  EndIf
  megaRetcode.d = 0
  ForEach ProcessorUsage()
    hCounter = ProcessorUsage()
    PdhGetFormattedCounterValue_(hCounter, $200 | $8000, @dwType.l, @lpValue)
    CopyMemory(@lpValue\ulValueLow, @retcode, 8)
    Debug Str(Retcode) + "%"
    megaRetcode + retcode
  Next  
  Debug " = " + StrF(megaRetcode,1) + " / " + Str(CpuCount) + " = " + StrF(megaRetcode / CpuCount, 1) + "%"
  Delay(5000)
Next
Last edited by Ventural on Thu Apr 26, 2018 12:36 am, edited 1 time in total.
Helle
Enthusiast
Enthusiast
Posts: 178
Joined: Wed Apr 12, 2006 7:59 pm
Location: Germany
Contact:

Re: VenMon - PC Monitoring Software

Post by Helle »

The PDH.dll is language-sensitive! For the german-version replace in the procedure

Code: Select all

Temp.s + "% Processor Time"
with

Code: Select all

Temp.s + "Prozessorzeit (%)"
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: VenMon - PC Monitoring Software

Post by Lord »

Ventural wrote:Cpu usage % test code using pdh.dll

Please try this everyone. I welcome any suggestions or improvements.
All credit should be given to Author: Ascend4nt. I simply translated it for Purebasic.

Code: Select all

...
Returns always 0%.
Maybe Helle is right and you should compile a language-sensitive version?
(There are other languages in outer space than english :wink: )
Image
Ventural
User
User
Posts: 26
Joined: Mon Jul 17, 2017 3:51 am
Location: Cocoa Beach, FL
Contact:

Re: VenMon - PC Monitoring Software

Post by Ventural »

Thank you Helle and Lord! I've updated the cpu usage code above, please test it.

What was happening was after using PdhLookupPerfNameByIndex the value of MemSize.l went from 1024 to 10. So, when I used PdhLookupPerfNameByIndex again, it failed with a blank result and I placed a temporary workaround of Temp.s + "% Processor Time" instead of actually fixing it.
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: VenMon - PC Monitoring Software

Post by Lord »

Hm, nothing changed here. Still got CPU at 0%.
Maybe my CPU is that fast, that its load is below 1%? :D
Again: Image

Another thought: I got one CPU with 4 cores, so tab "Processors" should display "Core x" instead of "CPU x".
Or do I have 4 CPU and I didn't realized 'til now? :wink:
That would maybe explain the low CPU load? :D
(Just kidding, se my signature)
Image
Post Reply