A Win95 About Box

and How to Go About it...

All I need do is set this info up once, using the Options button before I make an .exe. Heck, it will even increment a version count if I so desire.

There's only one 'hole' in this elegant structure : there's no App.Icon property. This is painful in this case, as I have to get my application's icon from (presumably) its main form, then set my imgIcon Image control to that icon.

As this relies on a form name, I must change (or at least check) it every time. That's the reason for the line in bold commented out below (ie. "'Uncomment ... frmMain.Icon"). If I don't set this image control, I have it set to default to the standard Info icon.

In any event, the code is pretty self-explanatory.

  Private Type OpSysVersion
    OpSysVersionSize As Long
    MajVersion As Long
    MinVersion As Long
    BldNumber As Long
    platform As Long
    filler As String * 128
  End Type

  Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA"(lpVersionInformation As OpSysVersion) As Long
  Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Load() Dim OpSysVer As OpSysVersion Dim sComp As String, sUser As String Dim lreslt As Long Me.Caption = "About " & App.ProductName

' Uncomment and change the following line as required ' imgIcon.Picture = frmMain.Icon Label1.Caption = App.ProductName Label2.Caption = "Version "& App.Major & "." & App.Minor & "." & App.Revision Label3.Caption = App.FileDescription Label5.Caption = App.LegalCopyright Label6.Caption = App.LegalTrademarks

OpSysVer.OpSysVersionSize = Len(OpSysVer) lreslt = GetVersionEx(OpSysVer) Label12.Caption = Format$(OpSysVer.MajVersion) & "." & format$(OpSysVer.MinVersion, "00") Label13.Caption = Format$(OpSysVer.BldNumber Mod 65536) If lreslt Then Select Case OpSysVer.platform Case 0 Label11.Caption = "Win32s" Case 1 Label11.Caption = "Windows 95" Case 2 Label11.Caption = "Windows NT" End Select End If

sComp = String$(32, 0) lreslt = GetComputerName(sComp, Len(sComp)) If lreslt Then Label15.Caption = sCompName End If sUser = String$(32, 0) lreslt = GetUserName(sUser, Len(sUser)) If lreslt Then Label17.Caption = sUser End If End Sub


[HOME] [TABLE OF CONTENTS] [SEARCH]