Log in

View Full Version : check storage size full or not before copy!


albertkhor
10-20-2005, 03:19 AM
hope to check the free space?
can anyone provide code for me?

iroot
10-27-2005, 11:21 PM
Imports System.Runtime.InteropServices

Public Structure MEMORYSTATUS
Public dwLength As UInt32
Public dwMemoryLoad As UInt32
Public dwTotalPhys As UInt32
Public dwAvailPhys As UInt32
Public dwTotalPageFile As UInt32
Public dwAvailPageFile As UInt32
Public dwTotalVirtual As UInt32
Public dwAvailVirtual As UInt32
End Structure 'MEMORYSTATUS

<DllImport("coredll.dll")> _
Private Shared Sub GlobalMemoryStatus(ByRef ms As MEMORYSTATUS)
End Sub

<DllImport("CoreDll.dll")> _
Public Shared Function GetSystemMemoryDivision( _
ByRef lpdwStorePages As UInt32, _
ByRef lpdwRamPages As UInt32, _
ByRef lpdwPageSize As UInt32) As Integer
End Function

Public Shared Sub Test()
Dim storePages As UInt32
Dim ramPages As UInt32
Dim pageSize As UInt32
Dim res As Integer = GetSystemMemoryDivision(storePages, ramPages, pageSize)

Dim memStatus As New MEMORYSTATUS
GlobalMemoryStatus(memStatus)
End Sub 'Test



I havn't used it yet, but i have it in my "Research" folder for the future cuz i will need something like this to complete my "SimpleOS" project http://simpleos.iroot.ca