|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
We stored the MRU file name in a Registry section named Settings and gave that file name the key Doc1. When the programs form first loads, then, we got the file name last stored there, if there was one, with GetSetting this way:
Private Sub Form_Load()
Dim FileName As String
FileName = GetSetting(App.Title, "Settings", "Doc1")
If FileName <> "" Then
Load mnuMRU(1)
mnuMRU(1).Caption = FileName
mnuMRU(1).Visible = True
End If
End Sub
On the other hand, when the user opens a file, we store that files name in the Windows Registry this way so we can add it to the MRU menu item later:
Private Sub mnuOpen_Click()
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "All Files (*.*)[vbar]*.*"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
If GetSetting(App.Title, "Settings", "Doc1") = "" Then
Load mnuMRU(1)
End If
mnuMRU(1).Caption = .FileName
mnuMRU(1).Visible = True
SaveSetting App.Title, "Settings", "Doc1", .FileName
End With
End Sub
And thats all there is to itusing SaveSetting and GetSetting, you can access the Windows Registry directly in a simple way. Getting All Registry SettingsYou can use the GetAllSettings to get a list of key settings and their values from a section in the Windows Registry. Heres how you use GetAllSettings: GetAllSettings( appname, section) Here are the arguments for GetAllSettings:
The GetAllSettings function returns a variant whose content is a two-dimensional array of strings, and these strings contain all the key settings in the indicated section and their values. Deleting A Registry SettingYou can delete Registry settings with the DeleteSetting statement: DeleteSetting appname, section[, key] Here are the arguments for DeleteSetting:
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |