similar" Case 6 KeyType = "Nokia 9140 or similar" Case 7 KeyType = "Japan Keyboard" End Select End Function ___________________________________________________________________________ Function Initial() Form1.Left = Val(StringFormINI("Form", "left", "0 ", "c:\windows\demo.ini")) Form1.Top = Val(StringFormINI("Form", "top", "0 ","c:\windows\demo.ini" )) Form1.WindowState = Val(StringFormINI("Form", "windowstate", "0 "," c:\windows\demo.ini")) End Function _______________________________________________________________________ Function SaveInfor() x = WritePrivateProfileString("Form", "left", Str$(Form1.Left), "c:\windows\demo.ini") x = WritePrivateProfileString("Form", "top", Str$(Form1.Top), "c:\windows\demo.ini") x = WritePrivateProfileString("Form", "windowstate", Str$ (Form1.WindowState), "c:\windows\demo.ini") End Function ___________________________________________________________________________ Function StringFormINI(SectionName As String, KeyName As String, Default As String, FileName As String) As String MaxStringLen% = 255 returnedstr$ = Space$(MaxStringLen%) Result% = GetPrivateProfileString(SectionName, KeyName, Default, returnedstr$, MaxStringLen%, FileName) returnedstr$ = LTrim$(RTrim$(returnedstr$)) returnedstr$ = Left$(returnedstr$, Len(returnedstr$) - 1) StringFormINI = returnedstr$ End Function __________________________________________________________________________ Function WinVer() ver& = GetVersion() winhigh = ver& Mod 256 winlow = Int(ver& / 256) Mod 256 WinVer = ((winhigh * 100) + winlow) / 100 End Function ___________________________________________________________________________
Function DosVer() ver& = GetVersion() Temp = ver& / 65536 doshigh = Int(Temp / 256) Mod 256 doslow = Temp Mod 256 DosVer = ((doshigh * 100) + doslow) / 100 End Function ___________________________________________________________________________ Function CPU() Flags&=GetWinFlags() Match=1 Select Case Match Case (Flags& And &H8)\&H8
CPU=486 Case (Flags& And &H4)\&H4
CPU=386 End Select End Function ___________________________________________________________________________ Function Mode() Flags&=GetWinFlags() If flags& And &H20 Then Mode="Enhanced" Else Mode="Standard" End If End Function
( 二) 建 立 窗 体 文 件Form1.frm Form1.Caption="System Information" Sub Form_Paint() Cls Print Print , "System Information" Print Print , "WindowsDir: ", WinDir() Print , "SystemDir: ", SysDir() Print , "WindowsVersion: ", WinVer() Print , "DosVersion: ", DosVer() Print , "KeyboardType: ", KeyType() End Sub Sub Form_Load() x = Initial()
End Sub Sub Form_Unload(Cancel As Integer) x = SaveInfor() End Sub
( 三) 运 行 本 程 序。( 本 程 序 在486 兼 容 机Windows3.1 下 通 过) 本 程 序 能 够 检 测 当 前 部 分 系 统 信 息, 在 退 出 时 能 将 窗 口 的 左、 上 位 置 及 窗 口 状 态 记 录 在DEMO.INI 文 件 中, 待 下 次 运 行 时, 窗 口 能 保 持 上 次 退 出 时 的 位 置 和 状 态。 注: 需 要 用 文 本 编 辑 器 编 辑DEMO.INI
[Form] Left=100 Top=100 Windowstate=0
并 存 在 当 前 系 统Windows 目 录 下。 本 文 仅 仅 是 介 绍 了 一 下API 函 数 的 使 用 方 法, 以 作 抛 砖 引 玉 之 用。 真 正 的 应 用API 函 数, 还 需 要 更 详 尽 的 资 料 和 读 者 更 大 的 努 力。 【 参 考 书 目】 《Windows3.1 API 函 数、 数 据 结 构 和 消 息 详 解》
上一页 [1] [2] [系统软件]Visual Studio 2005 Express Beta Products 下载链… [系统软件]Visual FoxPro9.0中扩展报表系统功能 [系统软件]Visual FoxPro:我是旁观者 [系统软件]Visual Studio 2005 Express Editions Beta 2 下载… [系统软件]Boost库在XP+Visual C++.net中的安装 [系统软件]Visual Studio 2005 Express Edition 正式版下载地… [常用软件]Visual Foxpro通用报表打印程序 [常用软件]Visual FoxPro 6.0与大型数据库的无数据源连接 [常用软件]Visual Foxpro 的一个BUG [VB.NET程序]Visual Basic 6 逆向工程与反逆向工程 (2)
|