Re: Update Windows Registry w/Access

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi, Bob.

> With your application,

It's not my application. The credit goes to Danny Lesandrini of DataFast
Consulting.

> When I use <Danny's> MDB and enter in the values as listed
> above and clidk the "Query Value Key" button, I receive a message box
> "Could
> not open key".

When I tested this application, it worked fine. That was years ago and
probably on a Windows ME computer. After testing this afternoon, I can see
that his code will not work on Windows XP (and likely not Windows 2K,
either). Fortunately, I see what the problem is.

Danny's code in the CommandFunctions( ) subroutine of the form is
concatening "SOFTWARE\" to the subkey string before it is passed to the
Windows API function. This altered subkey's name doesn't exist, so the
Windows API can't find it and open it for you. You need to change all
occurrences in his code to remove this concatenated string. For example,
change:

txtValue = ReadRegValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\" & txtSubKey, txtValueName)

to:

txtValue = ReadRegValue(HKEY_LOCAL_MACHINE, _
txtSubKey, txtValueName)

But that's not the only problem. Danny's code is based upon the following
Microsoft KB article:

http://support.microsoft.com/default.aspx?id=145679

If you read the information in this article, you'll notice that it only
handles REG_SZ and REG_DWORD key sizes (if you didn't already catch this
limitation by reading Danny's code). These functions don't handle the
Windows Registry key for the Environment Path key size, which is
REG_EXPAND_SZ, a Unicode NULL-terminated string. I searched through the
Microsoft KB on how to read a REG_EXPAND_SZ subkey and only found this
Microsoft KB article:

http://support.microsoft.com/default.aspx?id=265331

Unfortunately, the example code is written for Visual Fox Pro, so it won't
work in VBA. But the example code shows that the string passed to the
Windows API function needs to be sized to the length of the key's value and
filled with spaces, so you'll need to add the following code to the
bas_E-Zone_Reg module:

In the module's Declarations section, add:

Public Const REG_EXPAND_SZ = 2

In the ReadRegValue( ) function's "Select Case lType" block, add the
following Case statement:

Case REG_EXPAND_SZ
sValue = Space(lcch)
lrc = RegQueryValueExSTRING(hKeyHandle, _
sValueName, 0&, lType, sValue, lcch)
ReadRegValue = Left(sValue, lcch - 1)

Save and compile the code and run the application to query this subkey's
value again. It should work now.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are Ripley@xxxxxxxxxxxxxxx and scott@xxxxxxxxxxxxxxxxxx


"Bob Bonta" <BobBonta@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1503E54A-3334-4CE1-A0ED-4331E530C4F3@xxxxxxxxxxxxxxxx
>I do have a syntax question, though. I'm trying to read, then modify the
>key
> you provided in an earlier post
> (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
> Manager\Environment)
>
> With your application, I defined the following as:
>
> Root=HKEY_LOCAL_MACHINE (Toggle selection)
> Subkey=SYSTEM\CurrentControlSet\Control\Session Manager\Environment
> ValueName=Path
>
> Is this correct? When I use your MDB and enter in the values as listed
> above and clidk the "Query Value Key" button, I receive a message box
> "Could
> not open key".
>
> Thanx for your assistance!
>
> --
> ~ Bob Bonta ~
>
>
> "'69 Camaro" wrote:
>
>> You're welcome!
>>
>> Gunny
>>
>> See http://www.QBuilt.com for all your database needs.
>> See http://www.Access.QBuilt.com for Microsoft Access tips.
>>
>> (Please remove ZERO_SPAM from my reply E-mail address, so that a message
>> will be forwarded to me.)
>> Beware to those who use munged addresses: known newsgroup E-mail
>> harvesters
>> for spammers are Ripley@xxxxxxxxxxxxxxx and scott@xxxxxxxxxxxxxxxxxx
>>
>>
>> "Bob Bonta" <BobBonta@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:2700FCA0-79AB-405C-91FA-41CFB0029A61@xxxxxxxxxxxxxxxx
>> > Dat's what I'm looking fer! Thanx!
>> > --
>> > ~ Bob Bonta ~
>> >
>> >
>> > "'69 Camaro" wrote:
>> >
>> >> Hi, Bob.
>> >>
>> >> > I
>> >> > am still in need of a way I can manipulate/modify the path
>> >> > statement -
>> >> > the
>> >> > environment variable.
>> >>
>> >> The Environment PATH variable can be set in the Windows Registry in
>> >> the
>> >> "Path" subkey of this Windows Registry key (all one line):
>> >>
>> >> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
>> >> Manager\Environment
>> >>
>> >> HTH.
>> >>
>> >> Gunny
>> >>
>> >> See http://www.QBuilt.com for all your database needs.
>> >> See http://www.Access.QBuilt.com for Microsoft Access tips.
>> >>
>> >> (Please remove ZERO_SPAM from my reply E-mail address, so that a
>> >> message
>> >> will be forwarded to me.)
>> >> Beware to those who use munged addresses: known newsgroup E-mail
>> >> harvesters
>> >> for spammers are Ripley@xxxxxxxxxxxxxxx and scott@xxxxxxxxxxxxxxxxxx
>> >>
>> >> - - -
>> >> When you see correct answers to your question posted in Microsoft's
>> >> Online
>> >> Community, please sign in to the Community and mark these posts as
>> >> "Answers,"
>> >> so that all may benefit by filtering on "Answered questions" and
>> >> quickly
>> >> finding the right answers to similar questions. Remember that
>> >> questions
>> >> answered the quickest are often from those who have a history of
>> >> rewarding
>> >> the contributors who have taken the time to answer questions
>> >> correctly.
>> >>
>> >>
>> >> "Bob Bonta" wrote:
>> >>
>> >> > Gunny - thanx for your quick response. While what you provided will
>> >> > help, I
>> >> > am still in need of a way I can manipulate/modify the path
>> >> > statement -
>> >> > the
>> >> > environment variable. Any thoughts - anyone?
>> >> > --
>> >> > ~ Bob Bonta ~
>> >> >
>> >> >
>> >> > "'69 Camaro" wrote:
>> >> >
>> >> > > Hi, Bob.
>> >> > >
>> >> > > > I'm looking for some generic code to read/update the system
>> >> > > > registry.
>> >> > >
>> >> > > You will find example code to read and manipulate the Windows
>> >> > > Registry in
>> >> > > this Access 97 DB file:
>> >> > >
>> >> > > http://www.amazecreations.com/datafast/GetFile.aspx?file=A97RegistryFns.zip
>> >> > >
>> >> > > HTH.
>> >> > >
>> >> > > Gunny
>> >> > >
>> >> > > See http://www.QBuilt.com for all your database needs.
>> >> > > See http://www.Access.QBuilt.com for Microsoft Access tips.
>> >> > >
>> >> > > (Please remove ZERO_SPAM from my reply E-mail address, so that a
>> >> > > message
>> >> > > will be forwarded to me.)
>> >> > > Beware to those who use munged addresses: known newsgroup E-mail
>> >> > > harvesters
>> >> > > for spammers are Ripley@xxxxxxxxxxxxxxx and
>> >> > > scott@xxxxxxxxxxxxxxxxxx
>> >> > >
>> >> > > - - -
>> >> > > When you see correct answers to your question posted in
>> >> > > Microsoft's
>> >> > > Online
>> >> > > Community, please sign in to the Community and mark these posts as
>> >> > > "Answers,"
>> >> > > so that all may benefit by filtering on "Answered questions" and
>> >> > > quickly
>> >> > > finding the right answers to similar questions. Remember that
>> >> > > questions
>> >> > > answered the quickest are often from those who have a history of
>> >> > > rewarding
>> >> > > the contributors who have taken the time to answer questions
>> >> > > correctly.
>> >> > >
>> >> > >
>> >> > > "Bob Bonta" wrote:
>> >> > >
>> >> > > > Greetings!
>> >> > > >
>> >> > > > I'm looking for some generic code to read/update the system
>> >> > > > registry.
>> >> > > > Specifically, I need to update the path (environment variable).
>> >> > > >
>> >> > > > I tried using the shell command, but "path" or "path.com" is not
>> >> > > > recognized.
>> >> > > >
>> >> > > > Any assistance would be greatly appreciated. If you like, you
>> >> > > > may
>> >> > > > forward
>> >> > > > recommendation to bob.bonta@xxxxxxxxxxx or habk24@xxxxxxxx
>> >> > > >
>> >> > > > Thank you in advance for your assistance.
>> >> > > >
>> >> > > > ~ Bob Bonta ~
>>
>>
>>


.



Relevant Pages

  • Re: problem logging off and shutting down
    ... One using the Windows OS CD ... using repar from the setup menu and another microsoft repair tool that I ran ... I have been all over the Microsoft website and internet trying to ... #1 is a String Value ...
    (microsoft.public.windowsxp.general)
  • Re: cant find page sorter tool on bottom left in print publication
    ... If you're using Windows Vista, Click on the start button, and type ... If you don't see a "ShowStatusBar" string, you'll need to create one by ... Microsoft Office Publisher 2007. ... You should see the page sorter in the lower ...
    (microsoft.public.publisher)
  • Re: Why does Tcl_AsyncDelete get called in my app? (and why does it panic?)
    ... On Windows, ... Copyright Microsoft Corp 1988-1998. ... *** Compiler has 'Pentium 0x0f fix' ...
    (comp.lang.tcl)
  • Re: Annoying MS Windows Setup screen on startup
    ... Did what you suggested and removed the Microsoft XP Professional Setup ... string and restarted...unfortunately the same black and white screen ... came up except this time my choices were Windows Default OR Microsoft ...
    (microsoft.public.windowsxp.general)
  • SecurityFocus Microsoft Newsletter #176
    ... MICROSOFT VULNERABILITY SUMMARY ... Microsoft Windows XP HCP URI Handler Arbitrary Command Execu... ... PHPNuke Category Parameter SQL Injection Vulnerability ... Microsoft Baseline Security Analyzer Vulnerability Identific... ...
    (Focus-Microsoft)