Solved

Looking Within the Windows Registry

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now