?? modulemod.bas
字號:
Attribute VB_Name = "ModMain"
Option Explicit
Public autozl As Boolean '是否自動轉為整理房
Public bOrg As Boolean
Public bSyn As Boolean
Public cnn As New ADODB.Connection
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 Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Type NOTIFYICONDATA
cbSize As Long '結構的長度
hwnd As Long '消息接收窗口的句柄
uID As Long '圖標的標識
uFlags As Long '設置參數(shù)
uCallbackMessage As Long '回調(diào)消息的值
hicon As Long '圖標句柄
szTip As String * 64 '提示字符串
End Type
Public Const NIM_ADD = 0 '添加圖標
Public Const NIM_MODIFY = 1 '修改圖標
Public Const NIM_DELETE = 2 '刪除圖標
Public Const NIF_MESSAGE = 1 '當有鼠標事件發(fā)生時產(chǎn)生消息
Public Const NIF_ICON = 2 '
Public Const NIF_TIP = 4 '圖標有提示字符串
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_USER = &H400
Public Const WM_NOTIFYICON = WM_USER + &H100
Public Const GWL_WNDPROC = (-4)
Global lproc As Long
Global dbPath As String
Global strServeName As String
Function Icon_Del(ihwnd As Long) As Long
Dim ano As NOTIFYICONDATA
Dim l As Long
ano.hwnd = ihwnd
ano.uID = 0
ano.cbSize = Len(ano)
Icon_Del = Shell_NotifyIcon(NIM_DELETE, ano)
End Function
Function Icon_Add(ihwnd As Long, hicon As Long) As Long
Dim ano As NOTIFYICONDATA
Dim astr As String
astr = frmmain.Caption
ano.szTip = astr + Chr$(0)
ano.hwnd = ihwnd
ano.uID = 0
ano.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
ano.hicon = hicon
ano.cbSize = Len(ano)
ano.uCallbackMessage = WM_NOTIFYICON
Icon_Add = Shell_NotifyIcon(NIM_ADD, ano)
End Function
Function DialogProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_NOTIFYICON
Select Case lParam
Case WM_LBUTTONUP
SetWindowLong frmmain.hwnd, GWL_WNDPROC, lproc
frmmain.Show
Icon_Del hwnd
Case Else
End Select
Case Else
DialogProc = False
End Select
DialogProc = True
End Function
Sub Main()
If App.PrevInstance Then End
On Error GoTo err
Dim iniPath As String
iniPath = App.Path & "\dscbar.ini"
Dim Temp As String
'******************** 壓縮數(shù)據(jù)庫 *************************
Dim strCompact1 As String, strCompact2 As String
strCompact1 = readini("parameters", "strCompact1", iniPath)
strCompact2 = readini("parameters", "strCompact2", iniPath)
If Len(strCompact1) > 0 Then
InitializeDB strCompact1
End If
If Len(strCompact2) > 0 Then
InitializeDB strCompact2
End If
'***********************************************************
dbPath = readini("parameters", "servername", iniPath)
If dbPath = "" Then
dbPath = App.Path & "\data1"
End If
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & _
dbPath & "\qdjxc.mdb;Jet OLEDB:Database Password=fjzyq1980"
Temp = readini("parameters", "bOrg", iniPath)
If Temp = "" Or Temp = "0" Then
bOrg = False
Else
bOrg = True
End If
Temp = readini("parameters", "autozl", iniPath)
If Temp = "" Or Temp = "0" Then
autozl = False
Else
autozl = True
End If
Dim FreshInterval As Long
Temp = readini("parameters", "FreshInterval", iniPath)
If Temp = "" Then
FreshInterval = 5000
Else
FreshInterval = Val("" & Temp) * 1000
End If
Temp = readini("parameters", "bSyn", iniPath)
If Temp = "" Then
bSyn = 5000
Else
bSyn = Val("" & Temp) * 1000
End If
If bSyn = True Then
Shell "net time \\lhkj /yes /set", vbHide
End If
Load frmmain
frmmain.Timer1.Interval = FreshInterval
Exit Sub
err:
MsgBox dbPath & "\qdjxc.mdb文件未找到,或 Access 未正確安裝。"
End
End Sub
Public Function readini(appname, KeyName As String, FileName As String) As String
Dim inireturn As String
inireturn = String(255, Chr(0))
readini = Left(inireturn, GetPrivateProfileString(appname, ByVal KeyName, "", inireturn, Len(inireturn), FileName))
End Function
Private Sub InitializeDB(ByVal dbPath As String)
Dim oldName As String, newName As String
On Error GoTo errexit
If Right(dbPath, 1) <> "\" Then dbPath = dbPath & "\"
oldName = dbPath & "qdjxc.mdb"
newName = dbPath & "temp.mdb"
DBEngine.CompactDatabase oldName, newName
Kill oldName
Name newName As oldName
Exit Sub
errexit:
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -