Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - Visualizzare
Forum - Visual Basic 6 - Visualizzare "memoria fisica" in una form

Avatar
c1rcu1tburn3r (Normal User)
Newbie


Messaggi: 2
Iscritto: 22/08/2008

Segnala al moderatore
Postato alle 20:46
Venerdì, 22/08/2008
Ciao a tutti ragazzi, sono nuovo e mi sono avvicinato al vb da poco tempo quindi non ho assolutamente padronanza del mezzo, diciamo che fin'ora mi sono limitato a scopiazzare qua e la sorgenti per tirarne fuori quello che mi serviva.
Ora avrei bisogno di un aiutino... ho la necessità di visualizzare in una form i valori presenti nel Task Manager riguardanti la "Memoria Fisica", quindi le voci:
Totale
Disponibile
Cache sistema
Guardando qua e la ho trovato questo link molto interessante: http://support.microsoft.com/kb/161151/it
Funziona ma ho un paio di problemi, il primo è che in questo sorgente non è possibile leggere anche la "cache sistema" e l'altro è che non si aggiorna, fa una lettura istantanea e stop. A me servirebbe che la lettura venisse aggiornata ogni tot, ad esempio 1 secondo...
Che direzione posso prendere? Grazie a tutti in anticipo

PM Quote
Avatar
Overflow (Normal User)
Expert


Messaggi: 334
Iscritto: 11/01/2008

Segnala al moderatore
Postato alle 12:35
Sabato, 23/08/2008
per aggiornare le informazioni basta inserire un timer(Timer1) nel form(Form1), e inserisci il codice dell'evento load del form nell'evento timer del timer1.
Codice sorgente - presumibilmente VB.NET

  1. Private Sub Timer1_Timer()
  2.         Dim msg As String         ' Status information.
  3.  
  4.         'pulisce il form
  5.         Form1.Cls
  6.        
  7.          Show
  8.          MousePointer = 11   ' Hourglass.
  9.  
  10.              ' Get operating system and version.
  11.              Dim verinfo As OSVERSIONINFO
  12.              Dim build As String, ver_major As String, ver_minor As String
  13.              Dim ret As Long
  14.              verinfo.dwOSVersionInfoSize = Len(verinfo)
  15.              ret = GetVersionEx(verinfo)
  16.              If ret = 0 Then
  17.                  MsgBox "Error Getting Version Information"
  18.                  End
  19.              End If
  20.              Select Case verinfo.dwPlatformId
  21.                  Case 0
  22.                      msg = msg & "Windows 32s "
  23.                  Case 1
  24.                      msg = msg & "Windows 95/98 "
  25.                  Case 2
  26.                      msg = msg & "Windows NT "
  27.              End Select
  28.  
  29.              ver_major = verinfo.dwMajorVersion
  30.              ver_minor = verinfo.dwMinorVersion
  31.              build = verinfo.dwBuildNumber
  32.              msg = msg & ver_major & "." & ver_minor
  33.              msg = msg & " (Build " & build & ")" & vbCrLf & vbCrLf
  34.  
  35.              ' Get CPU type and operating mode.
  36.              Dim sysinfo As SYSTEM_INFO
  37.              GetSystemInfo sysinfo
  38.              msg = msg & "CPU: "
  39.              Select Case sysinfo.dwProcessorType
  40.                  Case PROCESSOR_INTEL_386
  41.                      msg = msg & "Intel 386" & vbCrLf
  42.                  Case PROCESSOR_INTEL_486
  43.                      msg = msg & "Intel 486" & vbCrLf
  44.                  Case PROCESSOR_INTEL_PENTIUM
  45.                      msg = msg & "Intel Pentium" & vbCrLf
  46.                  Case PROCESSOR_MIPS_R4000
  47.                      msg = msg & "MIPS R4000" & vbCrLf
  48.                  Case PROCESSOR_ALPHA_21064
  49.                      msg = msg & "DEC Alpha 21064" & vbCrLf
  50.                  Case Else
  51.                      msg = msg & "(unknown)" & vbCrLf
  52.  
  53.              End Select
  54.              msg = msg & vbCrLf
  55.              ' Get free memory.
  56.              Dim memsts As MEMORYSTATUS
  57.              Dim memory As Long
  58.              GlobalMemoryStatus memsts
  59.              memory = memsts.dwTotalPhys
  60.              msg = msg & "Total Physical Memory: "
  61.              msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
  62.                        & vbCrLf
  63.              memory& = memsts.dwAvailPhys
  64.              msg = msg & "Available Physical Memory: "
  65.              msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
  66.                        & vbCrLf
  67.              memory& = memsts.dwTotalVirtual
  68.              msg = msg & "Total Virtual Memory: "
  69.              msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
  70.                        & vbCrLf
  71.              memory& = memsts.dwAvailVirtual
  72.              msg = msg & "Available Virtual Memory: "
  73.              msg = msg & Format$(memory \ 1024, "###,###,###") & "K" _
  74.                        & vbCrLf & vbCrLf
  75.  
  76.          Print msg
  77.          MousePointer = 0
  78.  
  79. End Sub
  80.  
  81. 'evento load del form
  82. Private Sub Form_Load()
  83. Timer1.Enabled = True
  84. Timer1.Interval = 1000
  85. End Sub


per l'altro problema cercherò un po.

Ultima modifica effettuata da Overflow il 23/08/2008 alle 12:35
PM Quote
Avatar
c1rcu1tburn3r (Normal User)
Newbie


Messaggi: 2
Iscritto: 22/08/2008

Segnala al moderatore
Postato alle 16:36
Sabato, 23/08/2008
Grazie mille! Non ci avevo pensato al Timer...ora funziona perfettamente, mi rimane il problema che non riesco a trovare il comando per visualizzare la quantità di memoria cache. Le da tutte meno che quella 8-|
Mi sembra strano che non ci sia un comando anche per questa voce...

PM Quote