Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Sleep 1000 '暂停1秒
'Dim nowtime As Date
'nowtime = Now()
'While (DateDiff("s", nowtime, Now()) < 3)
'DoEvents
'Wend
'
''MsgBox "暂停3秒了已经"
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal LpApplicationName As String, ByVal LpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal LpApplicationName As String, ByVal LpKeyName As Any, ByVal LpString As Any, ByVal lpFileName As String) As Long
'---------------------------------------------------------------------------------
'--------------------------------------------------------------------------------
Public Const LoginURL = "http://login.sina.com.cn/hd/signin.php?entry=blog&r=http%3A%2F%2Fcontrol.blog.sina.com.cn%2Fadmin%2Farticle%2Farticle_add.php%3Findex"
Public Function GetINI(ApplicationName As String, KeyName As String, Optional ByVal Default As String = "", Optional ByVal FileName As String = "config.ini") As String
Dim Retval As Long
Dim Value As String
FileName = IIf(Mid(FileName, 2, 2) = ":/", FileName, Replace(App.Path & "/" & FileName, "//", "/"))
Value = Space(128)
Retval = GetPrivateProfileString(ApplicationName, KeyName, Default, Value, Len(Value), FileName)
GetINI = Left(Trim(Value), Len(Trim(Value)) - 1)
End Function
Public Sub WriteINI(ApplicationName As String, KeyName As String, Value As String, Optional ByVal FileName As String = "config.ini")
Dim Retval As Long
FileName = IIf(Mid(FileName, 2, 2) = ":/", FileName, Replace(App.Path & "/" & FileName, "//", "/"))
Retval = WritePrivateProfileString(ApplicationName, KeyName, Value, FileName)
End Sub
'ApplicationName是INI里的 [xxxx]
'KeyName 就是INI里的 xxx=1231232
'FileName是文件名
'例如
'Private Sub Form_Load()
'FormSetting.TextUserName = GetINI("LogConfig", "u", , "c:/a.ini")
'
'FormSetting.TextPassWord = GetINI("LogConfig", "p", , "c:/a.ini")
'
'
'End Sub
'Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'WriteINI "LogConfig", "u", FormSetting.TextUserName, "c:/a.ini"
'WriteINI "LogConfig", "p", FormSetting.TextPassWord, "c:/a.ini"
'End Sub