Solved

Looking Within the Windows Registry

Posted on 2002-03-10
2
243 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

749 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