CommonDialog1.ShowOpen
If Err = cdlCancel Then '“取消”按钮按下时,进行错误处理
Else
fIndex = InRecentFiles(CommonDialog1.FileName)
If fIndex > MaxRFiles Then
WriteRecentFiles CommonDialog1.FileName
Else
UpdateRecentFiles fIndex
End If
End If
End Sub
'将打开的文件路径写入注册表的子过程
Private Sub WriteRecentFiles(FileName As String)
Dim fileptr As Integer
If Len(Trim(FileName)) Then
fileptr = Val(GetSetting(A_Name, S_Name, "FirstFile", "0"))
fileptr = IIf(fileptr - 1 >= 0, fileptr - 1, MaxRFiles - 1)
SaveSetting A_Name, S_Name, "FirstFile", fileptr & ""
SaveSetting A_Name, S_Name, "File" & fileptr, FileName
ReadRecentFiles
End If
End Sub