Re: Update Windows Registry w/Access
- From: "'69 Camaro" <ForwardZERO_SPAM.To.69Camaro@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 19 Aug 2005 14:16:39 -0700
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 ~
>>
>>
>>
.
- References:
- Update Windows Registry w/Access
- From: Bob Bonta
- RE: Update Windows Registry w/Access
- From: '69 Camaro
- RE: Update Windows Registry w/Access
- From: Bob Bonta
- RE: Update Windows Registry w/Access
- From: '69 Camaro
- RE: Update Windows Registry w/Access
- From: Bob Bonta
- Re: Update Windows Registry w/Access
- From: '69 Camaro
- Re: Update Windows Registry w/Access
- From: Bob Bonta
- Update Windows Registry w/Access
- Prev by Date: Re: save the whole string into a field and use a string array to s
- Next by Date: Hourglass does not work
- Previous by thread: Re: Update Windows Registry w/Access
- Next by thread: Re: Update Windows Registry w/Access
- Index(es):
Relevant Pages
|