Changing Registry Values Directly 
Author Message
 Changing Registry Values Directly

Using Windows 95, VB4/32:

I'm trying to write directly to the Windows registry to retrieve and change
the value of the key

        HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\
        Explorer\NoSaveSettings

which takes a binary 1 or 0. I have tried various macerations of the
GetSetting and SaveSetting functions to no avail. I guess that I am either
not using the correct syntax or these functions are intended only for use
with specific applications and cannot be used in this context. If they can
be used what are the correct appname, section and key strings for the above
registry entry? If they can't be used do I have any alternatives? Is there
a good reference pertaining to this issue?

Thanks,

Dave Ross



Sat, 16 Jan 1999 03:00:00 GMT  
 Changing Registry Values Directly


Quote:
>I'm trying to write directly to the Windows registry to retrieve and change
>the value of the key

>    HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\
>    Explorer\NoSaveSettings

>which takes a binary 1 or 0. I have tried various macerations of the
>GetSetting and SaveSetting functions to no avail. I guess that I am either

The convenient GetSetting and SaveSetting only save within a Visual Basic
subtree of the Registry.

To get to any arbitrary Registry key, you need to use lower level Win32 API
calls.  Unfortunately, I do not know what the actual API calls are.

-- Rick
--

(Rick Rutt is a system architect living and working in Midland, Michigan.)



Sun, 17 Jan 1999 03:00:00 GMT  
 Changing Registry Values Directly

This gets the win95 "registerd user & company", and will give you the
basics....

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 RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String,
ByVal lpReserved As Long, ByVal lpType As Long, ByVal lpData As Any,
lpcbData As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey
As Long) As Long

Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_CURRENT_USER = &H80000001

Private Const READ_CONTROL = &H20000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const SYNCHRONIZE = &H100000

Private Const ERROR_SUCCESS = 0&
Private Const ERROR_MORE_DATA = 234

Private Const REG_SZ = 1
Private Const KEY_READ = ((READ_CONTROL Or KEY_QUERY_VALUE Or
KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))

Private Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))

r& = RegOpenKeyEx&(HKEY_LOCAL_MACHINE, _
        "SOFTWARE\Microsoft\Windows\CurrentVersion", _
         0, KEY_EXECUTE, hKey&)

If r& = ERROR_SUCCESS Then

  User$ = Space$(100)
  sizeData& = Len(User$)
  r& = RegQueryValueEx&(hKey&, "RegisteredOwner", 0, 0&, User$, sizeData&)
  Label1 = Left$(User$, sizeData& - 1)

  Company$ = Space$(100)
  sizeData& = Len(Company$)
  r& = RegQueryValueEx&(hKey&, "RegisteredOrganization", 0, 0&,
Company$, sizeData&)
  Label2 = Left$(Company$, sizeData& - 1)

End If



Mon, 18 Jan 1999 03:00:00 GMT  
 Changing Registry Values Directly



Quote:
>Using Windows 95, VB4/32:

>I'm trying to write directly to the Windows registry to retrieve and change
>the value of the key

>    HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\
>    Explorer\NoSaveSettings

>which takes a binary 1 or 0. I have tried various macerations of the
>GetSetting and SaveSetting functions to no avail. I guess that I am either
>not using the correct syntax or these functions are intended only for use
>with specific applications and cannot be used in this context. If they can
>be used what are the correct appname, section and key strings for the above
>registry entry? If they can't be used do I have any alternatives? Is there
>a good reference pertaining to this issue?

>Thanks,

>Dave Ross


Check out MSKB article Q145679. The SUBs it gives you are OK, but can
definitly be improved upon. I myself use a modified version of the
code sample they give, so it's a good base.

Scott



Mon, 18 Jan 1999 03:00:00 GMT  
 Changing Registry Values Directly

Quote:
> I'm trying to write directly to the Windows registry to retrieve and
change
> the value of the key

>    HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Policies\
>    Explorer\NoSaveSettings

> which takes a binary 1 or 0. I have tried various macerations of the
> GetSetting and SaveSetting functions to no avail. I guess that I am
either
> not using the correct syntax or these functions are intended only for use
> with specific applications and cannot be used in this context. If they
can
> be used what are the correct appname, section and key strings for the
above
> registry entry? If they can't be used do I have any alternatives? Is
there
> a good reference pertaining to this issue?

Here are the functions needed to access the registry.

'<Reqistry Functions>

    Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA"
(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String,
lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, ByVal
lpData As String, lpcbData As Long) As Long

    Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
lpReserved As Long, lpType As Long, ByVal lpData As Any, lpcbData As Long)
As Long

    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

    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As
Long

    Declare Function RegSetValueEx Lib "advapi32.dll" Alias
"RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As
Long) As Long

'<End Registry>

They are rather lengthy aren't they???

                                                -Jon



Tue, 19 Jan 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Change Value of Application Variable directly from VB 6

2. Change value in Registry of Windows with program

3. Changing registry values

4. Change DWord Value in Registry with Vb5 or Vb6

5. change system values in NT registry

6. Change Registry values

7. How to change NT Registry values?

8. Changing Registry Binary Value

9. Change a registry value

10. Change registry values in VB/VBA

11. change registry value on remote workstation via code

12. Change Value Registry

 

 
Powered by phpBB® Forum Software