调用API函数设计ABOUT窗口

2008-04-09 04:42:46来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  Windows98 系统的许多软件中都包含一个windows 风格的about 窗口,它向用户反映了当前系统的一些基本信息,其中显示有关windows 及其应用软件的版本、版权和系统的工作状态等信息。笔者用VB 6.0 通过调 用API 函数设计应用系统的ABOUT 窗口。

  1、建立含有如下控件的窗体:

  控件 NAME CAPTION
  窗体 FORM1 用VB6.0 设计ABOUT 窗口
  命令按钮 COMMAND1 关于销售管理系统

  2、程序清单:


---- Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer
---- Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hwnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long

---- Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hinst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long Private 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 Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

---- Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO) Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const GWL_WNDPROC = (-4)
Private Const GWL_HINSTANCE = (-6)
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 Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1

Private Sub Command1_Click()
Dim hinst As Long
Dim icons As Long
Dim abouts As Long
Dim dispx As String
Dim dispy As String
Dim cps As String
Dim space1 As String
Dim space2 As String
hinst = GetWindowWord(Me.hwnd, GWL_HINSTANCE)
icons = ExtractIcon(hinst, "d:\fpw26\foxprow.exe", 0)
Dim sysinfo As SYSTEM_INFO
Dim cls1 As Long
Dim cls2 As Long
Dim secs As Long
Dim bytes As Long
Dim buffs As String
buff = "C:\"
x = GetDriveType(buffs)
x = GetDiskFreeSpace(buffs, secs, bytes, cls1, cls2)
cls1 = cls1 * secs * bytes
cls2 = cls2 * secs * bytes

  space1 = "C驱动器总共容量:
  " Format$(cls2/1024, "#, #") "千字节"
  space2 = "C驱动器可用容量:
  " Format$(cls1/1024, "#, #") "千字节"
  x = GetSystemMetrics(SM_CXSCREEN)
  dispx = "显示器分辨率:" Str$(x)


x = GetSystemMetrics(SM_CYSCREEN)
dispy = Str$(x)
Call GetSystemInfo(sysinfo)
Select Case sysinfo.dwProcessorType
Case 386
  cpus = "处理器类型:386"
  Case 486
  cpus = "处理器类型:486"
  Case 586
  cpus = "处理器类型:586"
  End Select
  abouts = ShellAbout(Me.hwnd, "演示程序",

  "销售管理系统V2.0版权所有[C]1998-1999蔡可训"

& Chr$(13) & Chr$(10) & space1 & Chr$(13) & Chr$(10)
& space2 & Chr$(13) & Chr$(10) & cpus " " dispx
"*" dispy , icons)
End Sub
  ---- 以上程序在Windows98,VISUAL BASIC 6.0 FOR WINDOWS 环境下运行通过. 用户可以将其加入应用系统的ABOUT 菜单项,通过菜单项调用它,效果更好。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:获得Win9X下文件的短文件名

下一篇:自制IE风格按纽控件

热门词条
热门标签