ini.bas

来自「一个ERP系统可以用来学习之用」· BAS 代码 · 共 47 行

BAS
47
字号
Attribute VB_Name = "ini"
Sub main()
   server = GetKey(App.Path + "\setup.ini", "server")
   UserName = GetKey(App.Path + "\setup.ini", "username")
   Password = GetKey(App.Path + "\setup.ini", "password")
   
   If server = "" Then
    frmmanageuse.lblusermanage.Enabled = False
    frmmanageuse.lbldatabaseset.Enabled = False
    frmmanageuse.lbldatabasemanage.Enabled = False
   End If
   
   frmWait.Show
     
End Sub


Function FileExist(fname As String) As Boolean
    On Local Error Resume Next
        FileExist = (Dir(fname) <> "")
End Function

Public Function GetKey(Tmp_file As String, Tmp_key As String) As String
        Dim File As Long
        File = FreeFile
    
        If FileExist(Tmp_file) = False Then
            GetKey = ""
            Call WritePrivateProfileString("setup information", "server", "", App.Path + "\setup.ini")
            Call WritePrivateProfileString("setup information", "username", "", App.Path + "\setup.ini")
            Call WritePrivateProfileString("setup information", "password", "", App.Path + "\setup.ini")
            
            Exit Function
        End If
        
        Open Tmp_file For Input As File
            Do While Not EOF(1)
                Line Input #File, buffer
                If Left(buffer, Len(Tmp_key)) = Tmp_key Then
                    pos = InStr(buffer, "=")
                    GetKey = Trim(Mid(buffer, pos + 1))
                End If
            Loop
            Close File
       
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?