www.pudn.com > 645-485.rar > MyAbout.frm, change:2007-09-27,size:10298b


VERSION 5.00 
Begin VB.Form MyAbout  
   BorderStyle     =   0  'None 
   Caption         =   "关于我的应用程序" 
   ClientHeight    =   3825 
   ClientLeft      =   4230 
   ClientTop       =   3885 
   ClientWidth     =   7125 
   ClipControls    =   0   'False 
   LinkTopic       =   "Form2" 
   LockControls    =   -1  'True 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   Picture         =   "MyAbout.frx":0000 
   ScaleHeight     =   2640.083 
   ScaleMode       =   0  'User 
   ScaleWidth      =   6690.743 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   1  '所有者中心 
   Begin VB.CommandButton cmdOK  
      Cancel          =   -1  'True 
      Caption         =   "确定" 
      Default         =   -1  'True 
      Height          =   345 
      Left            =   5280 
      TabIndex        =   0 
      Top             =   2625 
      Width           =   1500 
   End 
   Begin VB.CommandButton cmdSysInfo  
      Caption         =   "系统信息(&S)..." 
      Height          =   345 
      Left            =   5280 
      TabIndex        =   1 
      Top             =   3075 
      Width           =   1485 
   End 
   Begin VB.Line Line1  
      BorderColor     =   &H00808080& 
      BorderStyle     =   6  'Inside Solid 
      Index           =   1 
      X1              =   3267.9 
      X2              =   6423.114 
      Y1              =   1687.583 
      Y2              =   1687.583 
   End 
   Begin VB.Label lblDescription  
      BackStyle       =   0  'Transparent 
      Caption         =   "本程序针对645规约以及部分扩展规约编制,不适用于所有情形,规约格式中,关于写操作的,请谨慎添加,如有不清楚,询问软件作者!" 
      ForeColor       =   &H00000000& 
      Height          =   810 
      Left            =   3600 
      TabIndex        =   2 
      Top             =   1560 
      Width           =   3165 
   End 
   Begin VB.Label lblTitle  
      BackStyle       =   0  'Transparent 
      Caption         =   "抄表程序" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   24 
         Charset         =   134 
         Weight          =   700 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H00800000& 
      Height          =   600 
      Left            =   4560 
      TabIndex        =   3 
      Top             =   360 
      Width           =   2085 
   End 
   Begin VB.Line Line1  
      BorderColor     =   &H00FFFFFF& 
      BorderWidth     =   2 
      Index           =   0 
      X1              =   3380.586 
      X2              =   5310.337 
      Y1              =   1697.936 
      Y2              =   1697.936 
   End 
   Begin VB.Label lblVersion  
      BackStyle       =   0  'Transparent 
      Caption         =   "版本" 
      Height          =   225 
      Left            =   5520 
      TabIndex        =   4 
      Top             =   960 
      Width           =   1005 
   End 
End 
Attribute VB_Name = "MyAbout" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
'**************************************************************************** 
'人人为我,我为人人 
'枕善居收藏整理 
'发布日期:2007/09/27 
'描    述:电表业645规约的电表485通讯代码 
'网    站:http://www.Mndsoft.com/  (VB6源码博客) 
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005) 
'e-mail  :Mndsoft@163.com 
'e-mail  :Mndsoft@126.com 
'OICQ    :88382850 
'          如果您有新的好的代码别忘记给枕善居哦! 
'**************************************************************************** 
 
Option Explicit 
 
' 注册表关键字安全选项... 
Const READ_CONTROL = &H20000 
Const KEY_QUERY_VALUE = &H1 
Const KEY_SET_VALUE = &H2 
Const KEY_CREATE_SUB_KEY = &H4 
Const KEY_ENUMERATE_SUB_KEYS = &H8 
Const KEY_NOTIFY = &H10 
Const KEY_CREATE_LINK = &H20 
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _ 
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _ 
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL 
                      
' 注册表关键字 ROOT 类型... 
Const HKEY_LOCAL_MACHINE = &H80000002 
Const ERROR_SUCCESS = 0 
Const REG_SZ = 1                         ' 独立的空的终结字符串 
Const REG_DWORD = 4                      ' 32位数字 
 
Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location" 
Const gREGVALSYSINFOLOC = "MSINFO" 
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO" 
Const gREGVALSYSINFO = "PATH" 
 
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long 
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long 
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long 
 
Const RGN_OR = 2 
 
 
Private Sub cmdSysInfo_Click() 
  Call StartSysInfo 
End Sub 
 
Private Sub cmdOK_Click() 
  Unload Me 
End Sub 
 
Private Sub Form_Load() 
    Me.Caption = "关于 " & App.Title 
    lblVersion.Caption = "版本 " & App.Major & "." & App.Minor & "." & App.Revision 
    Me.Icon = App_Main.Icon 
    RMe 
End Sub 
 
Public Sub StartSysInfo() 
    On Error GoTo SysInfoErr 
   
    Dim rc As Long 
    Dim SysInfoPath As String 
     
    ' 试图从注册表中获得系统信息程序的路径及名称... 
    If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then 
    ' 试图仅从注册表中获得系统信息程序的路径... 
    ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then 
        ' 已知32位文件版本的有效位置 
        If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then 
            SysInfoPath = SysInfoPath & "\MSINFO32.EXE" 
             
        ' 错误 - 文件不能被找到... 
        Else 
            GoTo SysInfoErr 
        End If 
    ' 错误 - 注册表相应条目不能被找到... 
    Else 
        GoTo SysInfoErr 
    End If 
     
    Call Shell(SysInfoPath, vbNormalFocus) 
     
    Exit Sub 
SysInfoErr: 
    MsgBox "此时系统信息不可用", vbOKOnly 
End Sub 
 
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean 
    Dim i As Long                                           ' 循环计数器 
    Dim rc As Long                                          ' 返回代码 
    Dim hKey As Long                                        ' 打开的注册表关键字句柄 
    Dim hDepth As Long                                      ' 
    Dim KeyValType As Long                                  ' 注册表关键字数据类型 
    Dim tmpVal As String                                    ' 注册表关键字值的临时存储器 
    Dim KeyValSize As Long                                  ' 注册表关键自变量的尺寸 
    '------------------------------------------------------------ 
    ' 打开 {HKEY_LOCAL_MACHINE...} 下的 RegKey 
    '------------------------------------------------------------ 
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' 打开注册表关键字 
     
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' 处理错误... 
     
    tmpVal = String$(1024, 0)                             ' 分配变量空间 
    KeyValSize = 1024                                       ' 标记变量尺寸 
     
    '------------------------------------------------------------ 
    ' 检索注册表关键字的值... 
    '------------------------------------------------------------ 
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _ 
                         KeyValType, tmpVal, KeyValSize)    ' 获得/创建关键字值 
                         
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' 处理错误 
     
    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 外接程序空终结字符串... 
        tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null 被找到,从字符串中分离出来 
    Else                                                    ' WinNT 没有空终结字符串... 
        tmpVal = Left(tmpVal, KeyValSize)                   ' Null 没有被找到, 分离字符串 
    End If 
    '------------------------------------------------------------ 
    ' 决定转换的关键字的值类型... 
    '------------------------------------------------------------ 
    Select Case KeyValType                                  ' 搜索数据类型... 
    Case REG_SZ                                             ' 字符串注册关键字数据类型 
        KeyVal = tmpVal                                     ' 复制字符串的值 
    Case REG_DWORD                                          ' 四字节的注册表关键字数据类型 
        For i = Len(tmpVal) To 1 Step -1                    ' 将每位进行转换 
            KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' 生成值字符。 By Char。 
        Next 
        KeyVal = Format$("&h" + KeyVal)                     ' 转换四字节的字符为字符串 
    End Select 
     
    GetKeyValue = True                                      ' 返回成功 
    rc = RegCloseKey(hKey)                                  ' 关闭注册表关键字 
    Exit Function                                           ' 退出 
     
GetKeyError:      ' 错误发生后将其清除... 
    KeyVal = ""                                             ' 设置返回值到空字符串 
    GetKeyValue = False                                     ' 返回失败 
    rc = RegCloseKey(hKey)                                  ' 关闭注册表关键字 
End Function 
 
 
 
Public Sub RMe() 
 
Dim Regn As Long 
Dim CER As Long 
Dim X1, Y1 As Long 
 
X1 = Me.Width / 15 
Y1 = Me.Height / 15 
 
Regn = CreateRectRgn(0, 5, X1, Y1 - 5) 
CER = CreateRectRgn(5, 0, X1 - 5, Y1) 
CombineRgn Regn, Regn, CER, RGN_OR 
 
CER = CreateEllipticRgn(-2, 0, 15, 35) 
CombineRgn Regn, Regn, CER, RGN_OR 
CER = CreateEllipticRgn(X1 - 15, 0, X1 + 2, 20) 
CombineRgn Regn, Regn, CER, RGN_OR 
CER = CreateEllipticRgn(-1, Y1 - 20, 10, Y1) 
CombineRgn Regn, Regn, CER, RGN_OR 
CER = CreateEllipticRgn(X1 - 20, Y1 - 40, X1 + 3, Y1 + 4) 
CombineRgn Regn, Regn, CER, RGN_OR 
Call SetWindowRgn(Me.hWnd, Regn, True) 
 
End Sub