#include <io.h> #include <stdlib.h> HMODULE hModule = GetModuleHandle(NULL); TCHAR szFilename[MAX_PATH]; TCHAR Drive[_MAX_DRIVE]; TCHAR Path[_MAX_DIR]; TCHAR Filename[_MAX_FNAME]; TCHAR Ext[_MAX_EXT]; GetModuleFileName(NULL, szFilename, sizeof(szFilename)); _tsplitpath_s(szFilename, Drive, _MAX_DRIVE, Path, _MAX_DIR, Filename, _MAX_FNAME, Ext, _MAX_EXT); TCHAR szFile[MAX_PATH]; // Extract "file.fnt" _stprintf_s(szFile, MAX_PATH, _T("%s%sfile.fnt"), Drive, Path); if( (_waccess( szFile, 0 )) == -1 ) // 파일이 존재하지 않을 경우 { HRSRC hrsrc = FindResource(hModule, (LPCTSTR)IDR_MY_FONT, _T("MyFILE")); DWORD dwSize = SizeofResource(hModule, hrsrc); HGLOBAL hGlobal = LoadResource(hModule, hrsrc); CHAR *pData = (CHAR *) LockResource(hGlobal); CFile file; CFileException e; if (file.Open(szFile, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary, &e)) { file.Write(pData, dwSize); file.Close(); } else { TCHAR szErr[1024]; e.GetErrorMessage(szErr, 1024); AfxMessageBox(szErr); } DeleteObject(hGlobal); } // Extract "file.dat" _stprintf_s(szFile, MAX_PATH, _T("%s%sfile.dat"), Drive, Path); if( (_waccess( szFile, 0 )) == -1 ) // 파일이 존재하지 않을 경우 { HRSRC hrsrc = FindResource(hModule, (LPCTSTR)IDR_MY_DATA, _T("MyFILE")); DWORD dwSize = SizeofResource(hModule, hrsrc); HGLOBAL hGlobal = LoadResource(hModule, hrsrc); CHAR *pData = (CHAR *) LockResource(hGlobal); CFile file; CFileException e; if (file.Open(szFile, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary, &e)) { file.Write(pData, dwSize); file.Close(); } else { TCHAR szErr[1024]; e.GetErrorMessage(szErr, 1024); AfxMessageBox(szErr); } DeleteObject(hGlobal); }