Solved

Looking Within the Windows Registry

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 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

21 Experts available now in Live!

Get 1:1 Help Now