;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Function: Demo the method to call AutoComplete function ; Author: Purple Endurer ; DevEnv: Windows 2000 + Masm32 V8 ; ; log ; ------------------------------------------------------- ; 2006.10.11 Created! ; Note: ; 1. Need call CoInitialize() & CoUninitialize() ; 2. If using shlwapi.inc(include SHAutoComplete) ; & msi.inc(include DllGetVersion) included in MASM32, ; then the version of shlwapi.dll will be 3.1.4000, ; so this program can not demo the function. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< .386 .model flat, stdcall option casemap: none include /masm32/ include/windows.inc include /masm32/ include/user32.inc include /masm32/ include/kernel32.inc include /masm32/ include/gdi32.inc include /masm32/ include/ole32.inc includelib /masm32/ lib/gdi32.lib includelib /masm32/ lib/user32.lib includelib /masm32/ lib/kernel32.lib includelib /masm32/ lib/ole32.lib WinMain PROTO : DWORD, : DWORD, : DWORD, : DWORD IDC_CkbOpen equ 103 IDC_EdtCmd equ 105 c_WinWidth equ 400 c_WinHeight equ 210 c_EditDemoTop equ 5 c_EditDemoLeft equ 2 c_EditDemoWidth equ 250 c_EditDemoHeight equ 20 c_CkbOpenTop equ c_EditDemoTop c_CkbOpenLeft equ (c_EditDemoLeft+c_EditDemoWidth+5) c_CkbOpenWidth equ 130 c_CkbOpenHeight equ c_EditDemoHeight SHACF_AUTOSUGGEST_FORCE_ON = 10000000h ;忽略注册表的设置并且打开autosuggest特性。它必须和SHACF_FILESYSXXX或者SHACF_URLXXX联合使用 SHACF_AUTOSUGGEST_FORCE_OFF = 20000000h ;忽略注册表的设置并且关闭autosuggest特性。它必须和SHACF_FILESYSXXX或者SHACF_URLXXX联合使用 SHACF_AUTOAPPEND_FORCE_ON = 40000000h ;忽略注册表的设置并且打开autoappend特性,它必须和SHACF_FILESYSXXX或者SHACF_URLXXX联合使用 SHACF_AUTOAPPEND_FORCE_OFF = 80000000h ;忽略注册表的设置并且关闭autoappend特性,它必须和SHACF_FILESYSXXX或者SHACF_URLXXX联合使用 SHACF_DEFAULT = 0h ;缺省设置。它和SHACF_FILESYSTE|SHACF_URLALL等价。不能和任何标志值联合使用 SHACF_FILESYSTEM = 1h ;包含文件系统和虚拟文件夹(比如桌面或是控制面板) SHACF_URLHISTORY = 2h ;包含历史记录的URL列表 SHACF_URLMRU = 4h ;包含最近使用过的URL列表 SHACF_URLALL = (SHACF_URLHISTORY or SHACF_URLMRU) DLLVER_PLATFORM_WINDOWS = 1h ;函数适合于任何Windows平台 DLLVER_PLATFORM_NT = 2h ;函数适合于Windows NT平台 m_m2m MACRO d1, d2 push d2 pop d1 ENDM .data g_szClsName db "AutoCompleteCls", 0 g_szFailOpen db "无法开启" g_szAppName db "自动完成功能演示", 0 g_szEditCls db "EDIT", 0 g_szBtnCls db "button", 0 g_szCkbOpenText db "开启自动完成功能", 0 g_szFailGetVerNo db "无法检测Shlwapi.dll的版本号", 0 g_szVerFmt db "Shlwapi.dll版本:%d.%d.%d", 0 g_szNeedIE5 db "自动完成功能需要使用IE5以上版本", 0 g_FailLoadDLL db "不能装载" g_szShlwapiDLL db "shlwapi.dll", 0 g_FailGetProcAddr db "不能获取函数" g_szDllGetVersion db "DllGetVersion", 0 g_szSHAutoComplete db "SHAutoComplete", 0 .data? g_hInstance HINSTANCE ? g_hWndMain HANDLE ? g_hEditDemo HANDLE ? g_hCkbOpen HANDLE ? g_Buf1 db 256 dup (?) g_dvi DLLVERSIONINFO <> g_lpfnDllGetVersion DWORD ? g_lpfnSHAutoComplete DWORD ? g_hDll HANDLE ? .code start: invoke GetModuleHandle, NULL mov g_hInstance, eax invoke LoadLibrary, ADDR g_szShlwapiDLL mov g_hDll, eax .if eax==NULL xor eax, eax jz @F .endif invoke GetProcAddress, g_hDll, ADDR g_szDllGetVersion .if eax==NULL xor eax, eax jz @FreeDll .endif mov g_lpfnDllGetVersion, eax invoke GetProcAddress, g_hDll, ADDR g_szSHAutoComplete .if eax==NULL xor eax, eax jz @FreeDll .endif mov g_lpfnSHAutoComplete, eax invoke WinMain, g_hInstance, NULL, NULL, SW_SHOWDEFAULT @FreeDll: invoke FreeLibrary, g_hDll @@: invoke ExitProcess, eax WinMain proc hInst: DWORD, hPrevInst: DWORD, CmdLine: DWORD, CmdShow: DWORD LOCAL wc: WNDCLASSEX LOCAL msg: MSG LOCAL hwnd: HWND m_m2m wc.cbSize, SIZEOF WNDCLASSEX m_m2m wc.style, CS_HREDRAW or CS_VREDRAW m_m2m wc.lpfnWndProc, OFFSET WndProc m_m2m wc.cbClsExtra, NULL m_m2m wc.cbWndExtra, NULL m_m2m wc.hInstance, g_hInstance m_m2m wc.hbrBackground, COLOR_APPWORKSPACE m_m2m wc.lpszMenuName, NULL ;IDR_MAINMENU m_m2m wc.lpszClassName, OFFSET g_szClsName invoke LoadIcon, NULL, IDI_APPLICATION mov wc.hIcon, eax mov wc.hIconSm, eax invoke LoadCursor, NULL, IDC_ARROW mov wc.hCursor, eax invoke RegisterClassEx, addr wc invoke CreateWindowEx, WS_EX_TOPMOST, ADDR g_szClsName, ADDR g_szAppName,/ WS_OVERLAPPEDWINDOW+WS_VISIBLE, CW_USEDEFAULT,/ CW_USEDEFAULT, c_WinWidth, c_WinHeight, NULL, NULL,/ hInst, NULL mov hwnd, eax .while TRUE invoke GetMessage, ADDR msg, NULL, 0, 0 .BREAK .IF (! eax) invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg .endw mov eax, msg.wParam ret WinMain endp WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM .if uMsg==WM_CREATE m_m2m g_hWndMain, hWnd ; Create demo editbox ;-------------------------- invoke CreateWindowEx, WS_EX_CLIENTEDGE, addr g_szEditCls, NULL,/ WS_CHILD + WS_VISIBLE + ES_AUTOHSCROLL,/ c_EditDemoLeft, c_EditDemoTop, c_EditDemoWidth, c_EditDemoHeight, hWnd, IDC_EdtCmd, g_hInstance, NULL mov g_hEditDemo, eax ; Create autocheckbox ;-------------------------- invoke CreateWindowEx, NULL, addr g_szBtnCls, addr g_szCkbOpenText,/ WS_CHILD+WS_VISIBLE+BS_AUTOCHECKBOX, c_CkbOpenLeft, c_CkbOpenTop, c_CkbOpenWidth, c_CkbOpenHeight,/ hWnd, IDC_CkbOpen, g_hInstance, NULL mov g_hCkbOpen, eax ; Get the version of Shlwapi.dll ;-------------------------- m_m2m g_dvi.cbSize, SIZEOF g_dvi ;invoke DllGetVersion, addr g_dvi push OFFSET g_dvi call g_lpfnDllGetVersion .if eax != 0 invoke MessageBox, hWnd, ADDR g_szFailGetVerNo, ADDR g_szAppName, MB_ICONERROR+MB_OK xor eax, eax jz @F .endif invoke wsprintf, ADDR g_Buf1, ADDR g_szVerFmt, g_dvi.dwMajorVersion, g_dvi.dwMinorVersion, g_dvi.dwBuildNumber invoke SetWindowText, g_hEditDemo, ADDR g_Buf1 .if g_dvi.dwMajorVersion < 5 invoke MessageBox, hWnd, ADDR g_szNeedIE5, ADDR g_szAppName, MB_ICONERROR+MB_OK @@: invoke PostQuitMessage, NULL ret .endif invoke CoInitialize, NULL .elseif uMsg==WM_COMMAND .if lParam!=0 mov eax, wParam .IF ax==IDC_CkbOpen shr eax, 16 .if ax==BN_CLICKED invoke SendMessage, g_hCkbOpen, BM_GETCHECK, NULL, NULL ;invoke SHAutoComplete, g_hEditDemo, SHACF_DEFAULT .if eax==BST_CHECKED push SHACF_DEFAULT .else push SHACF_AUTOSUGGEST_FORCE_OFF+SHACF_FILESYSTEM+SHACF_URLALL .endif push g_hEditDemo call g_lpfnSHAutoComplete .if eax!=0 invoke MessageBox, hWnd, ADDR g_szFailOpen, addr g_szAppName, MB_ICONERROR+MB_OK xor eax, eax jz @B .endif invoke SetFocus, g_hEditDemo .endif .ENDIF .endif .elseif uMsg==WM_DESTROY invoke CoUninitialize invoke PostQuitMessage, NULL .else invoke DefWindowProc, hWnd, uMsg, wParam, lParam ret .endif xor eax, eax ret WndProc endp end start ----------------------------------- ©著作权归作者所有:来自51CTO博客作者PurpleEndurer的原创作品,请联系作者获取转载授权,否则将追究法律责任 MASM32编程使用自动完成功能 https://blog.51cto.com/endurer/5856446