创建一个新的最近使用(MRU)列表.
#Include <WinAPIEx.au3>
_WinAPI_CreateMRUList ( $hKey, $sSubKey [, $iMax]] )
$hKey | 当前打开的关键字句柄, 或以下存储 MRU 数据的预定义值: $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE |
$sSubKey | 存储在 MRU 的子项数据. |
$iMax | [可选参数] MRU 列表项的最大数目. 默认为 26 (A..Z). |
成功: | 返回新 MRU 列表句柄. |
失败: | 返回 0,并设置@error标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <ComboConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $hMRU, $Msg, $Button, $Combo, $Count, $Data = ''
$hMRU = _WinAPI_CreateMRUList($HKEY_CURRENT_USER, 'Software\MyProg\MRU', 5)
; 在注册表中创建 MRU 列表 (仅在首个示例的开始部分)
RegRead('HKCU\Software\MyProg\MRU', 'MRUList')
If @error Then
For $i = 5 To 1 Step -1
_WinAPI_AddMRUString($hMRU, 'String' & $i)
Next
EndIf
GUICreate('MyGUI', 320, 92)
$Combo = GUICtrlCreateCombo(_WinAPI_EnumMRUList($hMRU, 0), 10, 20, 300, 21, $CBS_DROPDOWNLIST)
$Count = _WinAPI_EnumMRUList($hMRU, -1)
For $i = 1 To $Count - 1
$Data &= _WinAPI_EnumMRUList($hMRU, $i) & '|'
Next
GUICtrlSetData(-1, $Data)
$Button = GUICtrlCreateButton('OK', 125, 58, 70, 23)
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case -3
ExitLoop
Case $Button
_WinAPI_AddMRUString($hMRU, GUICtrlRead($Combo))
ExitLoop
EndSwitch
WEnd
_WinAPI_FreeMRUList($hMRU)