#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>

char szComputerName[17] = {0,};
char szUserName[17] = {0,};

void main()
{
	const char* dat_file = "prebuild.dat";
	const char* build_file = "build.h";
	FILE* fp = NULL;
	fp = fopen( dat_file, "rb" );
	if ( NULL == fp )
	{
		int init_build = 0;
		fp = fopen( dat_file, "wb" );
		fwrite(&init_build, sizeof(int), 1, fp);
		fclose( fp );
		fp = fopen( dat_file, "rb" );
	}

	int new_build = 0;
	fread(&new_build, sizeof(int), 1, fp);
	fclose( fp );

	new_build++;

	fp = fopen( dat_file, "wb" );
	fwrite(&new_build, sizeof(int), 1, fp);
	fclose( fp );

	fp = fopen( build_file, "wt" );
	fprintf(fp, "#define __BUILD_COUNT__ %d\n", new_build);
	DWORD nSize = MAX_COMPUTERNAME_LENGTH + 1;		
	::GetComputerName(szComputerName, &nSize);
	::GetUserName(szUserName, &nSize);
	fprintf(fp, "#define __BUILD_COMPUTER__ L\"%s\"\n", szComputerName);
	fprintf(fp, "#define __BUILD_USER__ L\"%s\"\n", szUserName);
	time_t timer;
	struct tm *t;
	timer = time(NULL);
	t = localtime(&timer);
	fprintf(fp, "#define __BUILD_TIME__ L\"%d월 %d일 %d시 %d분\"\n", t->tm_mon+1, t->tm_mday, t->tm_hour+1, t->tm_min);
	fclose(fp);
}
- 개선할 점 : 옵션처리( ansi / unicode / 추가 텍스트 ).
Posted by ngcbbs
,