[wpkg-users] [Bug 12] The registry "exists" check failes on keys, only works for values
bugzilla-daemon at wpkg.org
bugzilla-daemon at wpkg.org
Sat Sep 2 10:17:18 CEST 2006
Please reply using this URL only: http://bugs.wpkg.org/show_bug.cgi?id=12
------- Additional Comments From djf at assetsw.com 2006-09-02 10:17 -------
(In reply to comment #5)
> Hi, I tried it and it doesn't work for me :)
>
> I have the following packages.xml entry, which launches notepad:
>
> <package id="notepad" name="notepad">
> <check type="registry" condition="exists"
> path="HKLM\HARDWARE\DESCRIPTION\System" />
> <install cmd='notepad' />
> </package>
>
> As you can see on the screenshot, it exists:
>
> http://wpkg.org/regedit.png
>
> However:
>
> Checking presence of notepad; registry check condition failed !
> Installing notepad...
>
> Of course, if I change it to the "full key"
> ("HKLM\HARDWARE\DESCRIPTION\System\Identifier"), it's recognized properly.
>
>
> Other option is I don't understand the idea of it :)
>
> (well, I currently run WPKG in Wine on Linux, so it may not work as on Windows
> natively, too).
You're specifying a key without a value assigned to it. If you open regedit and look at any key (not value) that key will have an entry called (Default). This entry determines whether there is a value associated with the key or not. If the (Default) says (value not set) it means there's no corresponding default value for the key itself.
Here's a VB function that was posted by one of the MS MVP guys on USENET that checks for the existence of a key:
Function RegKeyExists(ByVal sRegKey)
' Returns True or False based on the existence of a registry key.
Dim sDescription, oShell
Set oShell = CreateObject("WScript.Shell")
RegKeyExists = True
sRegKey = Trim (sRegKey)
If Not Right(sRegKey, 1) = "\" Then
sRegKey = sRegKey & "\"
End If
On Error Resume Next
oShell.RegRead "HKEYNotAKey\"
sDescription = Replace(Err.Description, "HKEYNotAKey\", "")
Err.Clear
oShell.RegRead sRegKey
RegKeyExists = sDescription <> Replace(Err.Description, sRegKey, "")
On Error Goto 0
End Function
Since I'm not much of a VB scripter myself, although I've been writing Windows apps since the 1.x days of Windows, I can't completely verify that it works. Based on my crude understanding of VB, though, it does a test failure, strips the key from the error description, tests the key you're looking for, strips the key from that error description, then compares the two error descriptions. Seems a bit like overkill to me (since in the Win32 API you just call RegQueryKey() and then test for failure) but it looks like it works.
--
Configure bugmail: http://bugs.wpkg.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users
More information about the wpkg-users
mailing list