Hvala na odgovoru.
Ovo sa vb-helper sam vec probao, ali mi daje run time error "Object reference not set to an instance of an object" kada pokusam da koristim mem u GetMemory().
Ne vidim sta radim pogresno. Pokusao sam i sa
Dim mem As MEMORYSTATUS = New MEMORYSTATUS
ali i dalje isto.
Ona druga 2 primera su C#, koji za sada jos ne znam:)
Private Structure MEMORYSTATUS
Public dwLength As Long ' Size of MEMORYSTATUS
Public dwMemoryLoad As Long ' % of memory in use
Public dwTotalPhys As Long ' Total bytes of physical memory
Public dwAvailPhys As Long ' Bytes of free physical memory
Public dwTotalPageFile As Long ' Bytes in paging file
Public dwAvailPageFile As Long ' Free bytes in paging file
Public dwTotalVirtual As Long ' User bytes of address space
Public dwAvailVirtual As Long ' Free user bytes
End Structure
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (ByVal lpBuffer As MEMORYSTATUS)
Private Function GetMemory() As String
Dim mem As MEMORYSTATUS = New MEMORYSTATUS
Dim txt As String
'ovde daje gresku
GlobalMemoryStatus(mem)
With mem
txt = txt & "% used: " & _
Format$(.dwMemoryLoad, "@@@@@@@@@@@") & vbCrLf
txt = txt & "Total physical memory: " & _
Format$(.dwTotalPhys, "@@@@@@@@@@@") & vbCrLf
txt = txt & "Physical memory free: " & _
Format$(.dwAvailPhys, "@@@@@@@@@@@") & vbCrLf
txt = txt & "Total page file size: " & _
Format$(.dwTotalPageFile, "@@@@@@@@@@@") & _
vbCrLf
txt = txt & "Free page file size: " & _
Format$(.dwAvailPageFile, "@@@@@@@@@@@") & _
vbCrLf
txt = txt & "Total virtual memory: " & _
Format$(.dwTotalVirtual, "@@@@@@@@@@@") & vbCrLf
txt = txt & "Free virtual memory: " & _
Format$(.dwAvailVirtual, "@@@@@@@@@@@") & vbCrLf
End With
Return txt
End Function
All beer is good. Some beer is better.