Results 1 to 4 of 4

Thread: Who knows how to get PC's info such as diskspace,speed,etc.

  1. #1

    Thread Starter
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963

    Question

    Who knows the code on how to get PC's info and how to check wether A file or B file is exist or not.

    Hopefully you all can help me

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    File exists or not:
    Code:
    Function Existfile(ByVal sFile As String) As Boolean
       Dim szResults As String
    
       On Error GoTo Not_ExistFile
    
       szResults = Dir$(sFile)
       If szResults = "" Then
          Existfile = False
       Else
          Existfile = True
       End If
    
       Exit Function
    
    Not_ExistFile:
       Existfile = False
       Exit Function
    
    End Function
    The info about the drive:
    Code:
    '// Make a New project. Add a module. To the form Add a Command button. 
    
    '// Code:
    '// Add this code To the module:
    
    Option Explicit
    
    Public Type DRIVE_INFO
      DrvSectors                 As Long
      DrvBytesPerSector       As Long
      DrvFreeClusters         As Long
      DrvTotalClusters        As Long
      DrvSpaceFree            As Long
      DrvSpaceUsed            As Long
      DrvSpaceTotal           As Long
    End Type
    
    Public Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" _ (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    
    Public Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" _ (ByVal lpRootPathName As String, _ lpSectorsPerCluster As Long, _ lpBytesPerSector As Long, _ lpNumberOfFreeClusters As Long, _ lpTotalNumberOfClusters As Long) As Long
    
    '// Add this code To the Command button:
    
    Private Sub Command1_Click()
    Dim RDI As DRIVE_INFO 
    Dim r As Long 
    Dim RootPathName As String
    
    RootPathName$ = "C:\"
    r& = rgbGetDiskFreeSpaceRDI(RootPathName$, RDI)
    Cls 
    Print 
    Print " Drive Statistics for ", ": "; UCase$(RootPathName$) 
    Print 
    Print " No of Sectors", ": "; RDI.DrvSectors
    Print " Bytes per sector", ": "; RDI.DrvBytesPerSector 
    Print " Clusters Free", ": "; RDI.DrvFreeClusters 
    Print " Total Clusters", ": "; RDI.DrvTotalClusters 
    Print " Drive Space Used", ": "; Format$(RDI.DrvSpaceUsed, "###,###,###,##0") & " bytes"
    Print " Drive Space Free", ": "; Format$(RDI.DrvSpaceFree, "###,###,###,##0") & " bytes"
    Print " Total Drive Size", ": "; Format$(RDI.DrvSpaceTotal, "###,###,###,##0") & " bytes"
    End Sub
    
    '// Add this code To the form's General Declarations procedure:
    
    Private Function rgbGetDiskFreeSpaceRDI(RootPathName$, RDI As DRIVE_INFO) As Long
    
    Dim r As Long 
    r& = GetDiskFreeSpace(RootPathName$, RDI.DrvSectors, RDI.DrvBytesPerSector, RDI.DrvFreeClusters, RDI.DrvTotalClusters) RDI.DrvSpaceTotal = (RDI.DrvSectors * RDI.DrvBytesPerSector * RDI.DrvTotalClusters) 
    RDI.DrvSpaceFree = (RDI.DrvSectors * RDI.DrvBytesPerSector * RDI.DrvFreeClusters) 
    RDI.DrvSpaceUsed = RDI.DrvSpaceTotal - RDI.DrvSpaceFree rgbGetDiskFreeSpaceRDI& = r&
    End Function

  3. #3
    Guest
    there is a control that ships with VB6 Pro, called SysInfo (i think) that lets you get all sorts of data about your system.

  4. #4
    Guest
    Retrieve OS info:

    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width