All pastes #187402 Raw Edit

Something

public cpp v1 · immutable
·published 2006-10-01 01:50 UTC
rendered paste body
// ExecutableRunner.cpp : Defines the entry point for the console application.//#define UNICODE#include "stdafx.h"#include <windows.h>#include <stdio.h>#include <TCHAR.h>#include <string>#include <mbstring.h>#include <shellapi.h>#include <sys/types.h>#include <sys/stat.h>#include <errno.h>using namespace std;#define PATH_SIZE 512// Headersvoid RunExecutable(_TCHAR* path, _TCHAR* program);bool IsDotNet2Installed();int _tmain(int argc, _TCHAR* argv[]){    _TCHAR path[PATH_SIZE];	// find the index of the last "\" or "/"	int length = _tcsclen(argv[0]);    int endOfPath = -1;	for(int i = length-1; i > -1; i--)	{		if(argv[0][i] == _T('/') || argv[0][i] == _T('\\'))		{			endOfPath = i;			argv[0][i] = _T('\0');			break;		}	}	// this can be called without the PATH_SIZE - why?  	_tcscpy_s(path, PATH_SIZE, argv[0]);	RunExecutable(path, _T("dotnetfx.exe"));	return 0;}// Runs an executable.  The path should have enough room to append// the program name at the end of it.  This may be changed in future// versions, but for now, this is a small program, and this will work finevoid RunExecutable(_TCHAR* path, _TCHAR* program){	_tcscat(path, _T("\\"));	_tcscat(path, program);	ShellExecute(NULL, _T("open"), path, _T(""), _T(""), SW_SHOW);}bool IsDotNet2Installed(){	struct _tstat buffer;	_TCHAR* pathOfInterest = _T("%systemroot%\\Microsoft.NET\\Framework\\v2.0.50727");	bool exists = _tstat ( "filename", &buffer );	return exists;}