Solved

Looking Within the Windows Registry

Posted on 2002-03-10
2
247 Views
Last Modified: 2010-05-18
I am needing to determine (boolean) if a certain program (such as Internet Explorer 5.0) is listed in the Windows registry.  How is this done?  I found a function RegQueryValue() within help but am not sure if this is the correct function or not.

Please list #include files and short code example.  Also, how do I differentiate between  different versions of the same software and look for the latest version?  Is there a difference between the registries for NT and 98/XP that I need to consider in the code?
0
Comment
Question by:Bilbrey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
Triskelion earned 200 total points
ID: 6855074
Using Win2K, MSVC 5.0
The registry key will be the same in 85/98/NT/2000.


#include <afx.h>

BOOL     IsIeInstalled(void)
{
     HKEY hRegKey = NULL;
     //_tcscpy(szKey, _T("SOFTWARE\\Your Company\\Your Program\\"));
     static     char * szKey = "SOFTWARE\\MICROSOFT\\INTERNET EXPLORER";
     static     char     strVersion[16];
     memset(&strVersion, 0, sizeof(strVersion));
     if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,
          szKey, 0, KEY_QUERY_VALUE, &hRegKey))
          {
          return FALSE;
          }
     DWORD dwType = REG_SZ;
     DWORD     dwLength=(sizeof(strVersion)-1);
     if (ERROR_SUCCESS != RegQueryValueEx(hRegKey, _T("Version"),
          NULL, &dwType, (BYTE*)strVersion, &dwLength))
          {
          return FALSE;
          }
     return TRUE;
}

void main(void)
{
     printf ("Internet Explorer %s installed.", (IsIeInstalled() ? "is" : "is not"));
}
0
 

Author Comment

by:Bilbrey
ID: 6855342
Thanks very much.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question