|
/*
Copyright(C) Nishant Sivakumar 2005. All Rights Reserved.
Contact Email : nish@voidnish.com
URLs : www.voidnish.com, blog.voidnish.com
Demo app for the CDetectDotNet class
13-11-05 adapted by Will.Stott@iee.org (WPQS) to allow test for a specific version of CLR
*/
#include "stdafx.h"
#include<conio.h>
#include "DetectDotNet.h"
//******************************************************************************************************
//comment added by WPQS
//program takes an optional single parameter, the version of CLR to find. The program returns 0 (success)
//if this version of CLR is found, otherwise it returns -1 (fail). If no parameter is given the program
//returns 0 (success).
//
// examples:
// c:\>DetectDotNet 1.2.4455 //returns 0 if version 1.2.4455 is found
// c:\>DetectDotNet 2.0* //returns 0 if any version 2.0 of CLR is found
// c:\>DetectDotNet 1.* //returns 0 if any version 1. of CLR is found
// c:\>DetectDotNet * //returns 0 if any version of CLR is found
// c:\>DetectDotNet //returns 0 whether a version of CLR is found or not
//******************************************************************************************************
int _tmain(int argc, _TCHAR* args[]) //line edited by WPQS; was originally _tmain (int, _TCHAR**)
{
int rc = 0; //line added WPQS
size_t matchLen = 0; //line added WPQS
CDetectDotNet detect;
if ( argc > 1 ) //block added WPQS
{
matchLen = _tcslen(args[1]);
for ( size_t x = 0; x < matchLen; x++ )
{
if ( args[1][x] == '*' )
{
matchLen = x;
args[1][x] = '\0';
}
}
cout << "searching for v" << args[1] << endl;
rc = -1; //program fails, if not found
}
vector<string> CLRVersions;
cout << "Is .NET present : "
<< (detect.IsDotNetPresent() ? "Yes" : "No") << endl;
TCHAR szPath[300];
cout << "Root Path : "
<< (detect.GetInstallRootPath(szPath, 299) ? szPath : "") << endl;
cout << "Number of CLRs detected : "
<< (int)detect.EnumerateCLRVersions(CLRVersions) << endl;
cout << "CLR versions available :-" << endl;
for(vector<string>::iterator it = CLRVersions.begin();
it < CLRVersions.end(); it++)
{
cout << *it << endl;
if ( rc == -1) //block added WPQS
{
if ((*it).compare(0,matchLen,args[1]) == 0)
{
cout << "matching CLR found" << endl;
rc = 0;
}
}
}
// cout << "Press any key..." << endl; //line removed by WPQS
// getch(); //line removed by WPQS
return rc; //line edited by WPQS, orginally return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here