Visual Basic Tip: 01/15/96

Windows API's: WinHelp, disk space, system-modal, read-only text.

- Open a Windows help file's contents.


   Global Const HELP_INDEX = &H3   ' Display index
   Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData As Any) As Integer


   x% = WinHelp(hWnd, "C:\windows\calc.hlp", HELP_INDEX, a$)

- Disk free space (in SETUPKIT.DLL).

    Declare Function DiskSpaceFree Lib "SETUPKIT.DLL" () As Long


    Function GetDiskSpaceFree (drive As String) As Long
     ChDrive drive
     GetDiskSpaceFree = DiskSpaceFree()
    End Function

- Set a window to be system-modal, such as for a screen saver's 
  password dialog box.


    Declare Function SetSysModalWindow Lib "User" (ByVal hWnd As Integer) As Integer

    x% = SetSysModalWindow(hwnd)

- Make a text box read-only.  Set the text1 MultiLine property
  to true at design time.


    Global Const WM_USER = &H400
    Global Const EM_SETREADONLY = (WM_USER + 31)
    Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Any) As Long


    Open "C:\CONFIG.SYS" For Input As #1
    While Not EOF(1)
      Line Input #1, TmpStr$
      KeepStr$ = KeepStr$ & TmpStr$ & Chr$(13) & Chr$(10)
    text1.Text = KeepStr$

    ' Set the text box to read-only mode:
    ret& = SendMessage(text1.hWnd, EM_SETREADONLY, True, 0&)
    If ret& = 0 Then MsgBox "Couldn't Set Text Box to Read-Only."

Return to Phil's Web Page

Created by: Phili