Automatic completion of the text box with the SHLWAPI.DLL that comes with IE

zhaozj2021-02-08  199

There are many ways to implement the automatic completion of the text box. Here is a method of implementing SHLWAPI.dll with IE.

First, introduce shlwapi.dllshlwapi.dll and comctl32.dll, shell32.dll is the same as IE, so if you want to get the latest version, you must download the latest version of IE. Among them, the initial version of Shell32.dll and ComctL32.dll is version 4.0, she is distributed with Windows 95 and Windows NT; the initial version of SHLWAPI.dll is 4.71, which is distributed with IE4. In order to get the specific version number, you must use the DllgetVersion function (which is defined in shell32.dll).

Second, the function declaration 1. Declare function Dllgetversion lib "shell32.dll" & _ (byref DVI as dllversionInfo) AS long This function is to get the version number of the DLL file 2. Declare function shautocomplete lib "shlwapi.dll" & _ (Byval HWndIt as long, byval dwflags as long) AS long This function implements the automatic completion of the text box.

Third, constant declaration 1. The constant used by the dllgetversion function is as follows: (1) const dllver_platform_windows = & h1 function is suitable for any Windows platform (2) const dllver_platform_nt = & h2 function is suitable for Windows NT platform

2. The constant used by the ShautoComplete function is shown below (1) const shacf_autosuggest_force_on = & h10000000 ignore the settings of the registry and open the AutoSuggest property. It must be combined with SHACF_FILESYSXXX or SHACF_URLXXX (2) const shacf_autosuggest_force_off = & h20000000 ignore the settings of the registry and turn off the AutoSuggest property. It must SHACF_FILESYSXXX or SHACF_URLXXX in combination (3) Const SHACF_AUTOAPPEND_FORCE_ON = & provided H40000000 ignore the registry and opens autoappend properties, it must SHACF_FILESYSXXX or SHACF_URLXXX in combination (4) Const SHACF_AUTOAPPEND_FORCE_OFF = & H80000000 Ignored registry and closes autoappend characteristics, It must be combined with SHACF_FILESYSXXX or SHACF_URLXXX (5) const shacf_default = & h0 default settings. It and shacf_filesyste | shacf_urlall equivalent. Uncise with any flag value (6) const shacf_filesystem = & H1 Contains file system and virtual folders (such as desktop or control panel) (7) const shacf_urlhistory = & h2 Contains history URL list (8) const shacf_urlmru = & h4 Recently used URL list (9) const shacf_urlall = (shacf_urlhistory | shacf_urlmru) (this is not used to explain)

3. Return Value (1) Call DLLgetVersion successfully returns noError, it is defined as 0: const noerror = 0 (2) Call SHAUTOCOMPLETE successfully returns S_OK, it is defined as & H0: const S_ok = & H0 4, type function Dllgetversion DLLVERSIONINFO used type, which is defined as follows: type DLLVERSIONINFO cbSize as Long dwMajorVersion as Long dwMinorVersion as Long dwBuildVersion as Long dwPlatformID as LongEnd type (1) cbSize: type length, you must set a value (2) dwMajorVersion before calling DllGetVersion: Main version number (3) DWMINORVERSION: Supreme version number (4) DWBUILDVERSION: Correction Number (5) DWPLATFORMID: The platform used by DLL. Its value is DLLVER_PLATFORM) Windows or Dllver_Platform_NT

5. The code example has the following code in the declaration of the function: Option Explicit

Private Declare Function SHAutoComplete Lib "Shlwapi.dll" & _ (ByVal hwndEdit As Long, ByVal dwFlags As Long) As LongPrivate Declare Function DllGetVersion Lib "Shell32.dll" & _ (ByRef dvi As DLLVERSIONINFO) As LongPrivate Type DLLVERSIONINFO cbSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildVersion As Long dwPlatformID As LongEnd TypePrivate Const SHACF_AUTOSUGGEST_FORCE_ON = & H10000000Private Const SHACF_AUTOSUGGEST_FORCE_OFF = & H20000000Private Const SHACF_AUTOAPPEND_FORCE_ON = & H40000000Private Const SHACF_AUTOAPPEND_FORCE_OFF = & H80000000Private Const SHACF_DEFAULT = & H0Private Const SHACF_FILESYSTEM = & H1Private Const SHACF_URLHISTORY = & H2Private Const SHACF_URLMRU = & H4Private Const SHACF_URLALL = (SHACF_URLHISTORY | SHACF_URLMRU) private const dllver_platform_windows = & h1private const dllver_platform_nt = & h2private const norror = 0

Private Sub Form_Load () DIM DVI AS DLLVERSIONFO

Dvi.cbsize = len (DVI) IF DLLGETVERSION (DVI) <> noerror dam = version number " & "& _ DVi.dwminorversion &". "& DVI.dwbuildversion if Dvi.dwmajorversion> = 5 THEN command1.enabled = true command1.caption =" Enable Auto Complete Function "Else Msgbox" You must use IE5 to use Routine, Vbexclamation end iFend Sub

Private submmand1_click () DIM DVI AS DLLVERSIONFO

Dvi.cbsize = len (DVI) IF DLLGETVERSION (DVI) <> noerror the msgbox "Unable to detect SHLWAPI.DLL version number", Vbexclamation EXIT SUB End IF

If DVI.DWMAJORVERSION> = 5 Then if AutoComplete (Text1.hwnd, Shacf_Default) <> S_OK TEN MSGBOX "Unable to turn on Auto Fin", Vbexclamation Exit Sub EBD IF

Text1.setfocus text1.selstart = len (Text1.text)

Command1.enabled = false command1.caption = "Auto-completion function has been enabled" End IFEND SUB

Sixth, the unexpected problem is here I have a problem, I hope that the high-end pointing is one or two. Because you want to use the dllgetversion function, you must use the 4.71 version of Shell32.dll, but only the Windows NT of Windows 2000 or the Windows NT with IE4 or the above version is or Windows 98 has this version of shell32.dll (indicated in MSDN) ), So I must first know the version of shell32.dll, such, how can I get the version number of shell32.dll? ?

转载请注明原文地址:https://www.9cbs.com/read-3081.html

New Post(0)