Sunday, 18 March 2012

The FlashWindow, GetsystemDirectory and GetSystemInfo Api Call

The FlashWindow function flashes a window to a user. The GetSystemDirecoty prints the present system directory and the GetSystemInfo function presents the system information to the user.
Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
Private Sub Timer1_Timer()
Dim nReturnValue As Long
nReturnValue = FlashWindow(Form1.hWnd, True)
End Sub

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
    Dim sSave As String, Ret As Long
    'Create a buffer
    sSave = Space(255)
    'Get the system directory
    Ret = GetSystemDirectory(sSave, 255)
    'Remove all unnecessary chr$(0)'s
    sSave = Left$(sSave, Ret)
    'Show the windows directory
    MsgBox "Windows System directory: " + sSave
End Sub

Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Type SYSTEM_INFO
    dwOemID As Long
    dwPageSize As Long
    lpMinimumApplicationAddress As Long
    lpMaximumApplicationAddress As Long
    dwActiveProcessorMask As Long
    dwNumberOrfProcessors As Long
    dwProcessorType As Long
    dwAllocationGranularity As Long
    dwReserved As Long
End Type
Private Sub Form_Load()
    Dim SInfo As SYSTEM_INFO
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Get the system information
    GetSystemInfo SInfo
    'Print it to the form
    Me.Print "Number of procesor:" + Str$(SInfo.dwNumberOrfProcessors)
    Me.Print "Processor:" + Str$(SInfo.dwProcessorType)
    Me.Print "Low memory address:" + Str$(SInfo.lpMinimumApplicationAddress)
    Me.Print "High memory address:" + Str$(SInfo.lpMaximumApplicationAddress)
End Sub


 

No comments:

Post a Comment