PDA

Click to See Complete Forum and Search --> : how to get info about my comp.


lirlir
Jul 27th, 2000, 06:23 AM
i want to get info about my system :
(freediskspace,globlsize,OperatingSystem,OperatingSysVer,
VirtualDisks...)

how can i get all that info by API function.

nevyn
Jul 28th, 2000, 02:20 AM
Following site offers an overview of the most common used api functions:
http://www.vbapi.com

Or if you want good examples:
http://www.mvps.org/vb/

I know for certain that you can use
GetDiskFreeSpaceEx to obtain the free disk space

I hope this helps

Jul 28th, 2000, 01:27 PM
Try this. Put this code into a Form with a CommandButton.


Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32.dll" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As ULARGE_INTEGER, lpTotalNumberOfBytes As ULARGE_INTEGER, lpTotalNumberOfFreeBytes As ULARGE_INTEGER) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Type ULARGE_INTEGER
LowPart As Long
HighPart As Long
End Type

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Dim OsInfo As OSVERSIONINFO
Dim tmp As String
Dim FreeUser As ULARGE_INTEGER
Dim Total As ULARGE_INTEGER
Dim FreeSys As ULARGE_INTEGER
Dim Temp As Currency
Dim fTemp As Currency

Private Sub Command1_Click()

'Get OS Info
OsInfo.dwOSVersionInfoSize = Len(OsInfo)
retval = GetVersionEx(OsInfo)

Select Case OsInfo.dwPlatformId
Case 0
tmp = "Windows 3.x"
Case 1
tmp = "Windows 95/98"
Case 2
tmp = "Windows NT"
End Select

Print "Version: " & OsInfo.dwMajorVersion & "." & OsInfo.dwMinorVersion
Print "Build: " & OsInfo.dwBuildNumber
Print "Platform: " & tmp

'Get DiskSpace
GetDiskFreeSpaceEx "C:\", FreeUser, Total, FreeSys
CopyMemory Temp, Total, 8
CopyMemory fTemp, FreeUser, 8
Print "Total Space: " & (CCur(Temp) * 10000) / 1000000000 & " GB"
Print "Free Space: " & (CCur(fTemp) * 10000) / 1000000000 & " GB"

End Sub

Jul 28th, 2000, 02:37 PM
If you want to view info like from System Information.

Shell "C:\Program Files\Common Files\Microsoft Shared\MSINFO\MSINFO32.EXE", VbNormalFocus

Jul 28th, 2000, 03:18 PM
The SysInfo Control will also work, but the API method is a little more flexible.


Private Sub Command1_Click()

'Print the version of the OS
Print SysInfo1.OSVersion

End Sub