|
-
Apr 22nd, 2001, 03:24 PM
#1
I wanna change a setting temporary in RegEdit when i start a form. Then when I close the form the Settings will go back to default value.
The changes I Wanna do when I start the form is this:
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Text\
Change this value to:
Format "TabDelimited"
I would be very greateful if anybody could help me.
-
Apr 22nd, 2001, 04:10 PM
#2
Frenzied Member
I think Megatron has the Registry API for that.
Then, put the code for changing the setting in the Form_Load, and to change it back, put the "change-back-code" in the Form_Unload.
-
Apr 22nd, 2001, 04:46 PM
#3
Thanks for you info, CyberCarsten!
Where can I find Megatron's info about that?
I need help right now.
Regards
-
Apr 22nd, 2001, 04:48 PM
#4
Frenzied Member
I think there is a copy in the articles section. Look for 'Registry'. You could also try to search on the forums.
-
Apr 22nd, 2001, 05:03 PM
#5
I have been looking, but I haven't found anything? Where?
I saw that Megatron has posted over 6600 messages.
I sent a E-Mail to him.
-
Apr 23rd, 2001, 04:07 AM
#6
Frenzied Member
-
Apr 23rd, 2001, 01:28 PM
#7
Thanks!
I still do not understand how to do?
I wanna change a setting temporary in Registry when i start a form. Then when I close the form the Settings will go back to default value.
The changes I Wanna do when I start the form is this:
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Text\
Value name: Format
Change Value Data to "TabDelimited"
-
Apr 23rd, 2001, 01:34 PM
#8
in a module:
Code:
Private Const REG_OPTION_NON_VOLATILE = 0
Private Const REG_SZ As Long = 1
Private Const REG_BINARY = 3
Private Const REG_DWORD As Long = 4
Private Const READ_CONTROL = &H20000
Private Const SYNCHRONIZE = &H100000
Private Const KEY_ALL_ACCESS As Long = &H3F
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_READ = ((READ_CONTROL Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Enum RegistryRootConstants
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_Performance_Data = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum
Private Const Error_NONE As Long = 0
Private Const Error_BADDB As Long = 1
Private Const Error_BADKEY As Long = 2
Private Const Error_CANTOPEN As Long = 3
Private Const Error_CANTREAD As Long = 4
Private Const Error_CANTWRITE As Long = 5
Private Const Error_OUTOFMEMORY As Long = 6
Private Const Error_INVALID_PARAMETER As Long = 7
Private Const Error_ACCESS_DENIED As Long = 8
Private Const Error_INVALID_PARAMETERS As Long = 87
Private Const Error_NO_MORE_ITEMS As Long = 259
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Sub SaveSetting(ByVal szRegistrySection As String, ByVal szRegistryKey As String, ByVal szRegistrySetting As String)
Dim lReturnValue As Long
Dim hKey As Long
lReturnValue = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szRegistrySection, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, lReturnValue)
lReturnValue = RegSetValueExString(hKey, szRegistryKey, 0&, REG_SZ, szRegistrySetting, Len(szRegistrySetting))
RegCloseKey hKey
End Sub
Public Function GetSetting(ByVal szRegistrySection As String, ByVal szRegistryKey As String, ByVal szDefaultRegistrySetting As String) As String
Dim szRegistrySetting As String
Dim lReturnValue As Long
Dim lData As Long
Dim hKey As Long
lReturnValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegistrySection, 0, KEY_READ, hKey)
lReturnValue = RegQueryValueExNULL(hKey, szRegistryKey, 0&, REG_SZ, 0&, lData)
szRegistrySetting = String(lData, 0)
lReturnValue = RegQueryValueExString(hKey, szRegistryKey, 0&, REG_SZ, szRegistrySetting, lData)
If lReturnValue = 0 Then
szRegistrySetting = Left(szRegistrySetting, lData - 1)
Else
szRegistrySetting = szDefaultRegistrySetting
End If
RegCloseKey hKey
GetSetting = szRegistrySetting
End Function
VBBrowser v2.2.4
in form:
Code:
SaveSetting "SOFTWARE\Microsoft\Jet\3.5\Engines\Text\", "Format", "TabDelimited"
VBBrowser v2.2.4
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 23rd, 2001, 02:38 PM
#9
Now it works for me. When i start the form the value changes in Registry.
But how do I make the code go back to the value it was before I start the form?
I'm very greateful for your help!
-
Apr 23rd, 2001, 03:11 PM
#10
in the unload event of the form:
Private Sub Form_Unload()
just call the savesetting again and put the other value back in.
if the other value changes all the time then do this:
in gen Dec section:
Dim PrevValue as String
in the form load:
PrevValue = GetSetting ("SOFTWARE\Microsoft\Jet\3.5\Engines\Text\", "Format", "")
(you can change the "" to something else...that is the default value..so if there is nothing there you can make it be something)
then do the SaveSetting to the TabDelimited
then in Unload:
SaveSetting "SOFTWARE\Microsoft\Jet\3.5\Engines\Text\", "Format", PrevValue
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 23rd, 2001, 04:02 PM
#11
Everything works now.
Thank you,geoff_xrx!
-
Apr 23rd, 2001, 04:25 PM
#12
you're Welcome
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|