?
Solved

Looking Within the Windows Registry

Posted on 2002-03-10
2
Medium Priority
?
252 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

765 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