[Insight-developers] List Windows registry sub-keys using CMake

David Cole david.cole at kitware.com
Tue Jun 14 10:23:09 EDT 2011


On Tue, Jun 14, 2011 at 8:49 AM, Brad King <brad.king at kitware.com> wrote:

> On 06/14/2011 08:28 AM, Dan Mueller wrote:
> > Just wondering if it is possible to use CMake to list Windows registry
> sub-keys?
> >
> > For example I have the following keys:
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.2]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.8]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.7]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.4]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.3]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.1]
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6]
> >
> > Is it possible to perform some form of globbing expression on
> >     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono]
> > to find all the sub-keys e.g. 2.10.2, 2.8, 2.6.7, 2.6.4, 2.6.3, 2.6.1,
> 2.6?
> >
> > At the moment I am simply testing known versions (which seems tedious
> > and is not future proof).
>
> Currently this is not possible.  It may be tricky to define an intuitive
> but correct interface for this because registry keys may be named using
> most glob meta-characters like '*', '[', ']', etc.  Furthermore, globbing
> may not naturally define an ordering.
>
> The same problem is faced when searching directory paths containing
> version components.  Currently only find_package deals with that, and
> then only for certain documented cases.
>
> -Brad
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>

You can however, use execute_process with the Windows "reg" command line
tool.

  reg query HKLM\SOFTWARE /f * /k

produces output that looks to be fairly easily parse-able.

Something like:

if(WIN32)
  execute_process(COMMAND reg query HKLM\\SOFTWARE /f * /k OUTPUT_VARIABLE
output)
endif()

should work ok...


HTH,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110614/b9063e3a/attachment.htm>


More information about the Insight-developers mailing list