#include <windows.h>
#include <stdio.h>
#include <string.h>																		 

char *keyname = "ProductDir";
char *rootname = "SOFTWARE\\Microsoft\\DevStudio\\6.0\\Products\\Microsoft Visual C++";


int main (int argv,char **argc)
{
	long retval;
	DWORD dispos;
	HKEY rootkey;
	DWORD datatype;
	char *data;
	DWORD datasize;
	FILE *thefile;

	retval = RegCreateKeyEx (HKEY_LOCAL_MACHINE,(LPCSTR) rootname,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&rootkey,&dispos);

	RegQueryValueEx (rootkey,keyname,0,&datatype,NULL,&datasize);

	data = new char[datasize+200];

	RegQueryValueEx (rootkey,keyname,0,&datatype,(unsigned char *) data,&datasize);


	RegCloseKey (rootkey);

	strcat (data,"\\include");
	thefile = fopen ("stl_inc_find.hpp","r");
	if (thefile)
		return 0;
	thefile = fopen ("stl_inc_find.hpp","w");
	if (!thefile)
		return 1;
	fprintf (thefile,"#pragma once\n");
	fprintf (thefile,"#ifndef __STL_INC_FINDHPP__\n");
	fprintf (thefile,"#define __STL_INC_FINDHPP__\n");
	fprintf (thefile,"#define __PLACEMENT_NEW_INLINE\n");
	fprintf (thefile,"void *operator new(size_t, void *_P);\n");
																					 
	fprintf (thefile,"#define __STL_NATIVE_HEADER(x) <%s/##x>\n",data);
	fprintf (thefile,"#define __STL_NATIVE_C_HEADER(x) <%s/##x>\n",data);
	fprintf (thefile,"#define __STL_NATIVE_CPP_C_HEADER(x) <%s/##x>\n",data);
	fprintf (thefile,"#endif\n");
	fclose (thefile);
	delete[] data;
	return 0;
}