1个回答
2013-09-13
展开全部
在函数的声明段有如下代码:
Option Explicit
Private Declare Function SHAutoComplete Lib "Shlwapi.dll" & _
(ByVal hwndEdit As Long,ByVal dwFlags As Long) As Long
Private Declare Function DllGetVersion Lib "Shell32.dll" & _
(ByRef dvi As DLLVERSIONINFO) As Long
Private Type DLLVERSIONINFO
cbSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildVersion As Long
dwPlatformID As Long
End Type
Private Const SHACF_AUTOSUGGEST_FORCE_ON = &H10000000
Private Const SHACF_AUTOSUGGEST_FORCE_OFF = &H20000000
Private Const SHACF_AUTOAPPEND_FORCE_ON = &H40000000
Private Const SHACF_AUTOAPPEND_FORCE_OFF = &H80000000
Private Const SHACF_DEFAULT = &H0
Private Const SHACF_FILESYSTEM = &H1
Private Const SHACF_URLHISTORY = &H2
Private Const SHACF_URLMRU = &H4
Private Const SHACF_URLALL = (SHACF_URLHISTORY | SHACF_URLMRU)
Private Const DLLVER_PLATFORM_WINDOWS = &H1
Private Const DLLVER_PLATFORM_NT = &H2
Private Const S_OK = &H0
Private Const NOERROR = 0
Private Sub Form_Load()
Dim dvi As DLLVERSIONINFO
dvi.cbSize = Len(dvi)
If DllGetVersion(dvi) <> NOERROR Then
MsgBox "无法检测Shlwapi.dll的版本号",vbExclamation
Exit Sub
End If
Label1.Caption = "你所用的是Shlwapi.dll" & dvi.dwMajorVersion & "." & _
dvi.dwMinorVersion & "." & dvi.dwBuildVersion
If dvi.dwMajorVersion >= 5 Then
Command1.Enabled = True
Command1.Caption = "开启自动完成功能"
Else
MsgBox "你必须使用IE5才能使用该例程",vbExclamation
End If
End Sub
Private Sub Command1_Click()
Dim dvi As DLLVERSIONINFO
dvi.cbSize = Len(dvi)
If DllGetVersion(dvi) <> NOERROR Then
MsgBox "无法检测Shlwapi.dll的版本号",vbExclamation
Exit Sub
End If
If dvi.dwMajorVersion >= 5 Then
If AutoComplete(Text1.hwnd,SHACF_DEFAULT) <> S_OK Then
MsgBox "无法开启自动完成功能",vbExclamation
Exit Sub
Ebd If
Text1.SetFocus
Text1.SelStart = Len(Text1.Text)
Command1.Enabled = False
Command1.Caption = "自动完成功能已开启"
End If
End Sub
Option Explicit
Private Declare Function SHAutoComplete Lib "Shlwapi.dll" & _
(ByVal hwndEdit As Long,ByVal dwFlags As Long) As Long
Private Declare Function DllGetVersion Lib "Shell32.dll" & _
(ByRef dvi As DLLVERSIONINFO) As Long
Private Type DLLVERSIONINFO
cbSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildVersion As Long
dwPlatformID As Long
End Type
Private Const SHACF_AUTOSUGGEST_FORCE_ON = &H10000000
Private Const SHACF_AUTOSUGGEST_FORCE_OFF = &H20000000
Private Const SHACF_AUTOAPPEND_FORCE_ON = &H40000000
Private Const SHACF_AUTOAPPEND_FORCE_OFF = &H80000000
Private Const SHACF_DEFAULT = &H0
Private Const SHACF_FILESYSTEM = &H1
Private Const SHACF_URLHISTORY = &H2
Private Const SHACF_URLMRU = &H4
Private Const SHACF_URLALL = (SHACF_URLHISTORY | SHACF_URLMRU)
Private Const DLLVER_PLATFORM_WINDOWS = &H1
Private Const DLLVER_PLATFORM_NT = &H2
Private Const S_OK = &H0
Private Const NOERROR = 0
Private Sub Form_Load()
Dim dvi As DLLVERSIONINFO
dvi.cbSize = Len(dvi)
If DllGetVersion(dvi) <> NOERROR Then
MsgBox "无法检测Shlwapi.dll的版本号",vbExclamation
Exit Sub
End If
Label1.Caption = "你所用的是Shlwapi.dll" & dvi.dwMajorVersion & "." & _
dvi.dwMinorVersion & "." & dvi.dwBuildVersion
If dvi.dwMajorVersion >= 5 Then
Command1.Enabled = True
Command1.Caption = "开启自动完成功能"
Else
MsgBox "你必须使用IE5才能使用该例程",vbExclamation
End If
End Sub
Private Sub Command1_Click()
Dim dvi As DLLVERSIONINFO
dvi.cbSize = Len(dvi)
If DllGetVersion(dvi) <> NOERROR Then
MsgBox "无法检测Shlwapi.dll的版本号",vbExclamation
Exit Sub
End If
If dvi.dwMajorVersion >= 5 Then
If AutoComplete(Text1.hwnd,SHACF_DEFAULT) <> S_OK Then
MsgBox "无法开启自动完成功能",vbExclamation
Exit Sub
Ebd If
Text1.SetFocus
Text1.SelStart = Len(Text1.Text)
Command1.Enabled = False
Command1.Caption = "自动完成功能已开启"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询