static bool FreeSys(HINSTANCE hinst) { bool bSuccess = false; if(IsFileExist(SYSNAME)) { PRINT("[%s]msg : %s is Alread Existed!\n",\ __func__,SYSNAME); //if(!DelSys()) //若使用DelSys则不会成功删除文件,因为此时共享计数等于1 //不会删除文件。 if(!DeleteFile(SYSNAME)) { PRINT("[%s]msg : Del Old %s File Failed!\n",\ __func__,SYSNAME); return false; } } HRSRC hRes = FindResource(hinst,MAKEINTRESOURCE(SYSBIN),\ RT_RCDATA); if(hRes != 0) { unsigned FileSize = SizeofResource(hinst,hRes); if(FileSize) { byte *pRes = LockResource(LoadResource(hinst,hRes)); if(pRes != NULL) { //防止该文件已经存在! //(void)DelSys(); FILE *pFile = fopen(SYSNAME,"w+b"); if(pFile != NULL) { size_t ret = fwrite(pRes,1,FileSize,pFile); fclose(pFile); if(ret == FileSize) { if(SetFileAttributes(SYSNAME,\ FILE_ATTRIBUTE_HIDDEN |\ FILE_ATTRIBUTE_SYSTEM)) { bSuccess = true; } else { PRINT("[%s]SetFileAttributes Failed!\n",\ __func__); } } else { PRINT("[%s]Write File Failed!\n",\ __func__); } } else { PRINT("[%s]Create File Failed!\n",\ __func__); } } else { PRINT("[%s]LockResource Failed!\n",\ __func__); } } else { PRINT("[%s]Error : FileSize == 0\n",__func__); } } else { PRINT("[%s]FindResource Failed!\n",__func__); } return bSuccess; }
static int FBALocaliseParseFile(TCHAR* pszFilename) { LocaliseResourceInfo CurrentResource; wchar_t wszBuffer[5120]; int nTemplateVersion = 0; wchar_t szLine[5120]; wchar_t* s; wchar_t* t; int nLen; int nLine = 0; int nInside = 0; TCHAR* nResourceType = 0; if (pszFilename == 0 || _tcslen(pszFilename) == 0) { return -1; } memset(&CurrentResource, 0, sizeof(LocaliseResourceInfo)); FILE* h = _tfopen(pszFilename, _T("rb")); if (h == NULL) { return 1; } { unsigned char szBOM[4] = { 0, }; fread(szBOM, 1, sizeof(szBOM), h); // See if it's a UTF-8 file if (szBOM[0] == 0xEF && szBOM[1] == 0xBB && szBOM[2] == 0xBF) { nFBACodepage = CP_UTF8; } #ifdef _UNICODE // See if it's a UTF-16 file if (szBOM[0] == 0xFF && szBOM[1] == 0xFE) { nFBACodepage = CP_WINUNICODE; fseek(h, 2, SEEK_SET); } #endif } if (nFBACodepage != CP_WINUNICODE) { fclose(h); h = _tfopen(pszFilename, _T("rt")); if (h == NULL) { return 1; } if (nFBACodepage == CP_UTF8) { fseek(h, 3, SEEK_SET); } } while (1) { char szTemp[1024]; #ifdef _UNICODE if (nFBACodepage != CP_WINUNICODE) { #endif if (fgets(szTemp, sizeof(szTemp), h) == NULL) { break; } MultiByteToWideChar(nFBACodepage, 0, szTemp, -1, szLine, sizeof(szLine) / sizeof(TCHAR)); #ifdef _UNICODE } else { if (_fgetts(szLine, sizeof(szLine), h) == NULL) { break; } } #endif nLine++; nLen = wcslen(szLine); // Get rid of the linefeed at the end while (szLine[nLen - 1] == 0x0A || szLine[nLen - 1] == 0x0D) { szLine[nLen - 1] = 0; nLen--; } s = szLine; // Start parsing WSKIP_WS(s); if (s[0] == _T('/') && s[1] == _T('/')) { // Comment continue; } if ((t = LabelCheckW(s, L"version")) != 0) { // Version s = t; WSKIP_WS(s); nTemplateVersion = wcstol(s, &t, 0); if (s != t) { if (nTemplateVersion != nBurnVer) { break; } } #ifdef PRINT_TRANSLATION_INFO dprintf(_T("version\n"), nTemplateVersion); #endif s = t; continue; } if ((t = LabelCheckW(s, L"codepage")) != 0) { // Set codepage s = t; WSKIP_WS(s); nFBACodepage = wcstol(s, &t, 0); #ifdef PRINT_TRANSLATION_INFO dprintf(_T("codepage\n"), nFBACodepage); #endif s = t; continue; } if ((t = LabelCheckW(s, L"menu")) != 0) { s = t; nResourceType = RT_MENU; WSKIP_WS(s); unsigned int nID = wcstol(s, &t, 0); #ifdef PRINT_TRANSLATION_INFO dprintf(_T("menu %i\n"), nID); #endif s = t; WSKIP_WS(s); if (nInside) { FBALocaliseError(pszFilename, nLine, _T("missing closing bracket"), NULL); break; } if (*s != _T('{')) { FBALocaliseError(pszFilename, nLine, _T("missing opening bracket"), NULL); break; } nInside = 1; CurrentResource.nID = nID; continue; } if ((t = LabelCheckW(s, L"dialog")) != 0) { // Add new resource s = t; nResourceType = RT_DIALOG; WSKIP_WS(s); unsigned int nID = wcstol(s, &t, 0); #ifdef PRINT_TRANSLATION_INFO dprintf(_T("dialog %i\n"), nID); #endif s = t; // Read dialog caption wchar_t* szQuote = NULL; wchar_t* szEnd = NULL; QuoteReadW(&szQuote, &szEnd, s); s = szEnd; WSKIP_WS(s); if (nInside) { FBALocaliseError(pszFilename, nLine, _T("missing closing bracket"), NULL); break; } if (*s != L'{') { FBALocaliseError(pszFilename, nLine, _T("missing opening bracket"), NULL); break; } nInside = 1; CurrentResource.nID = nID; if (wcslen(szQuote)) { memcpy(CurrentResource.szCaption, szQuote, QUOTE_MAX * sizeof(TCHAR)); } continue; } if ((t = LabelCheckW(s, L"string")) != 0) { s = t; if (nInside) { FBALocaliseError(pszFilename, nLine, _T("missing closing bracket"), NULL); break; } WSKIP_WS(s); unsigned int nID = wcstol(s, &t, 0); s = t; // Read dialog caption WFIND_QT(s); s++; wchar_t* szQuote = s; WFIND_QT(s); wchar_t* szEnd = s; if (nID < nMaxResources) { #ifdef PRINT_TRANSLATION_INFO { TCHAR szFormat[256]; _stprintf(szFormat, _T("string %%5i \"%%.%ils\"\n"), szEnd - szQuote); dprintf(szFormat, nID, szQuote); } #endif if (szEnd - szQuote > 0) { UnEscapeString(wszBuffer, szQuote, szEnd - szQuote); FBAResourceInfo[nID].nResourceFlags = RES_DEALLOCATE; #ifdef _UNICODE FBAResourceInfo[nID].pResourceTranslation = malloc((wcslen(wszBuffer) + 1) * sizeof(wchar_t)); wcscpy((wchar_t*)FBAResourceInfo[nID].pResourceTranslation, wszBuffer); #else { char szStringBuffer[5120]; memset(szStringBuffer, 0, sizeof(szStringBuffer)); WideCharToMultiByte(CP_ACP, 0, wszBuffer, -1, szStringBuffer, 5120, NULL, NULL); FBAResourceInfo[nID].pResourceTranslation = malloc((strlen(szStringBuffer) + 1)); strcpy((char*)FBAResourceInfo[nID].pResourceTranslation, szStringBuffer); } #endif } } } int n = wcstol(s, &t, 0); bool bPopup = false; if (t == s) { t = LabelCheckW(s, L"popup"); bPopup = true; } if (t && t != s) { // New control if (nInside == 0) { FBALocaliseError(pszFilename, nLine, _T("rogue control statement"), szLine); break; } s = t; n = wcstol(s, &t, 0); // Link a new control info structure if (n < 256) { s = t; // Read option name wchar_t* szQuote = NULL; wchar_t* szEnd = NULL; if (QuoteReadW(&szQuote, &szEnd, s)) { FBALocaliseError(pszFilename, nLine, _T("control name omitted"), szLine); break; } s = szEnd; if (bPopup) { WSKIP_WS(s); if (*s != L'{') { FBALocaliseError(pszFilename, nLine, _T("missing opening bracket"), NULL); break; } nInside++; } if (wcslen(szQuote)) { if (CurrentResource.pControlInfo[n] == NULL) { CurrentResource.pControlInfo[n] = (LocaliseControlInfo*)malloc(sizeof(LocaliseControlInfo)); } memset(CurrentResource.pControlInfo[n], 0, sizeof(LocaliseControlInfo)); memcpy(CurrentResource.pControlInfo[n]->szCaption, szQuote, QUOTE_MAX * sizeof(TCHAR)); } // dprintf(_T(" - %ls\n"), pCurrentResource->pControlInfo[n]->szCaption); } continue; } WSKIP_WS(s); if (*s == L'}') { if (nInside == 0) { FBALocaliseError(pszFilename, nLine, _T("rogue closing bracket"), NULL); break; } nInside--; if (nInside == 0) { if (CurrentResource.nID < nMaxResources) { if (nResourceType == RT_MENU) { MENUTEMPLATE* pTemplate; pTemplate = (MENUTEMPLATE*)LoadResource(hAppInst, FindResource(hAppInst, MAKEINTRESOURCE(CurrentResource.nID), RT_MENU)); if (LockResource((HGLOBAL)pTemplate)) { if (((MENUITEMTEMPLATEHEADER*)pTemplate)->versionNumber == 0) { // Translate the structure FBAResourceInfo[CurrentResource.nID].pResourceTranslation = TranslateMenuTemplate((MENUTEMPLATE*)pTemplate, &CurrentResource); FBAResourceInfo[CurrentResource.nID].nResourceFlags = RES_DEALLOCATE; } } } if (nResourceType == RT_DIALOG) { LPCDLGTEMPLATE pTemplate; pTemplate = (LPCDLGTEMPLATE)LoadResource(hAppInst, FindResource(hAppInst, MAKEINTRESOURCE(CurrentResource.nID), RT_DIALOG)); if (LockResource((HGLOBAL)pTemplate)) { if (((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF && ((DLGTEMPLATEEX*)pTemplate)->dlgVer == 1) { // Translate the structure FBAResourceInfo[CurrentResource.nID].pResourceTranslation = TranslateDlgTemplateEx((DLGTEMPLATEEX*)pTemplate, &CurrentResource); FBAResourceInfo[CurrentResource.nID].nResourceFlags = RES_DEALLOCATE; } } } } for (int i = 0; i < 1024; i++) { free(CurrentResource.pControlInfo[i]); } memset(&CurrentResource, 0, sizeof(LocaliseResourceInfo)); } } // Line isn't (part of) a valid cheat #if 0 if (*s) { FBALocaliseError(pszFilename, nLine, _T("rogue line"), szLine); break; } #endif } for (int i = 0; i < 1024; i++) { free(CurrentResource.pControlInfo[i]); } if (h) { fclose(h); } if (nTemplateVersion != nBurnVer) { if (nTemplateVersion == 0) { return -1; } return -2; } return 0; }
bool windows_tray_notification::create_tray_icon() { // getting handle to a 32x32 icon, contained in "WESNOTH_ICON" icon group of wesnoth.exe resources const HMODULE wesnoth_exe = GetModuleHandle(NULL); if (wesnoth_exe == NULL) { return false; } const HRSRC group_icon_info = FindResource(wesnoth_exe, L"WESNOTH_ICON", RT_GROUP_ICON); if (group_icon_info == NULL) { return false; } HGLOBAL hGlobal = LoadResource(wesnoth_exe, group_icon_info); if (hGlobal == NULL) { return false; } const PBYTE group_icon_res = static_cast<PBYTE>(LockResource(hGlobal)); if (group_icon_res == NULL) { return false; } const int nID = LookupIconIdFromDirectoryEx(group_icon_res, TRUE, 32, 32, LR_DEFAULTCOLOR); if (nID == 0) { return false; } const HRSRC icon_info = FindResource(wesnoth_exe, MAKEINTRESOURCE(nID), MAKEINTRESOURCE(3)); if (icon_info == NULL) { return false; } hGlobal = LoadResource(wesnoth_exe, icon_info); if (hGlobal == NULL) { return false; } const PBYTE icon_res = static_cast<PBYTE>(LockResource(hGlobal)); if (icon_res == NULL) { return false; } const HICON icon = CreateIconFromResource(icon_res, SizeofResource(wesnoth_exe, icon_info), TRUE, 0x00030000); if (icon == NULL) { return false; } const HWND window = get_window_hanlde(); if (window == NULL) { return false; } // filling notification structure nid = new NOTIFYICONDATA; memset(nid, 0, sizeof(&nid)); nid->cbSize = NOTIFYICONDATA_V2_SIZE; nid->hWnd = window; nid->uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; nid->dwInfoFlags = NIIF_USER; nid->uVersion = NOTIFYICON_VERSION; nid->uCallbackMessage = WM_TRAYNOTIFY; nid->uID = ICON_ID; nid->hIcon = icon; #if _WIN32_WINNT >= 0x600 nid->hBalloonIcon = icon; #endif lstrcpy(nid->szTip, L"The Battle For Wesnoth"); // creating icon notification return Shell_NotifyIcon(NIM_ADD, nid) != FALSE; }
/* int KGTestMapDisuseResource::AnalyseTerrainInfo(IEKG3DSceneOutDoorSpaceMgr* pIEOutDoorMgr) { int nResult = false; int nRetCode = false; HRESULT hrRetCode = E_FAIL; DWORD dwType = 0; DWORD dwLength = 0; char szResourceName[MAX_PATH]; KG3DMemoryFile* pMemoryFile = NULL; vector<UINT> vecTerrainHandle; KG_ASSERT_EXIT(pIEOutDoorMgr); pMemoryFile = new KG3DMemoryFile(); KGLOG_PROCESS_ERROR(pMemoryFile); hrRetCode = pIEOutDoorMgr->GetAllTerrainInfoHandle(&vecTerrainHandle); KGLOG_COM_PROCESS_ERROR(hrRetCode); for (UINT i = 0; i < vecTerrainHandle.size(); i++) { hrRetCode = pIEOutDoorMgr->GetTerrainInfoformation(vecTerrainHandle[i], &dwType, &dwLength, pMemoryFile->GetBuffer()); if (FAILED(hrRetCode)) { KGLogPrintf(KGLOG_ERR, "It must be something wrong with %d.TerrainInfo", vecTerrainHandle[i]); continue; } switch (dwType) { case Terrain_Info_Convermap: { pMemoryFile->read(szResourceName, sizeof(char) * MAX_PATH); szResourceName[sizeof(szResourceName) - 1] = '\0'; if (szResourceName[0] != '\0') { FindResource(szResourceName); } pMemoryFile->read(szResourceName, sizeof(char) * MAX_PATH); szResourceName[sizeof(szResourceName) - 1] = '\0'; if (szResourceName[0] != '\0') { FindResource(szResourceName); } } break; case Terrain_Info_DetailMtlMgr: { DWORD dwVersion = 0; BYTE byteNum = 0; BYTE byteIndex = 0; BYTE byteCurrentMaterialIndex = 0; nRetCode = pMemoryFile->read(&dwVersion, sizeof(DWORD)); nRetCode = pMemoryFile->read(&byteNum, sizeof(BYTE)); nRetCode = pMemoryFile->read(&byteCurrentMaterialIndex, sizeof(BYTE)); for (BYTE i = 0;i < byteNum; i++) { BYTE byteMask = 0; size_t uPos = 0; pMemoryFile->read(&byteMask,sizeof(BYTE)); if(byteMask) { DWORD dwVersion = 0; pMemoryFile->read(&dwVersion,sizeof(DWORD)); pMemoryFile->read(&byteIndex,sizeof(BYTE)); //这里如果g_cEngineOption.bEnableGroundNormalMap = true时, //需调用g_cEngineManager.GetHDFilePath();获得NormalMap资源名称 //默认g_cEngineOption.bEnableGroundNormalMap = false pMemoryFile->read(&szResourceName,sizeof(char) * MAX_PATH); szResourceName[sizeof(szResourceName) - 1] = '\0'; FindResource(szResourceName); uPos = pMemoryFile->GetPos(); uPos += sizeof(BYTE) + //m_byTexCoordIndex sizeof(float) + //m_fScaleU sizeof(float) + //m_fScaleV sizeof(D3DXVECTOR4) + //m_vUT sizeof(D3DXVECTOR4); //m_vVT if(dwVersion >= 1) { uPos += sizeof(BOOL) + //m_bAssociateGrass 8 + //m_byGrassTexIndex 8; //m_byPatternIndex } if(dwVersion == 2) { uPos += sizeof(float) + //m_fEnvReflection sizeof(float) + //m_fSpecular sizeof(float); //m_fEmissive } pMemoryFile->SetPos(uPos); } } } break; case Terrain_Info_GrassSet: case Terrain_Info_StoneSet: case Terrain_Info_FrutexSet: { DWORD dwVersion = 0; DWORD dwStrideX = 0; DWORD dwStrideY = 0; DWORD NumPattern = 0; pMemoryFile->read(&dwVersion,sizeof(DWORD)); pMemoryFile->read(&dwStrideX,sizeof(DWORD)); pMemoryFile->read(&dwStrideY,sizeof(DWORD)); pMemoryFile->read(szResourceName, sizeof(char) * MAX_PATH); szResourceName[sizeof(szResourceName) - 1] = '\0'; FindResource(szResourceName); pMemoryFile->read(&NumPattern,sizeof(DWORD)); for (DWORD i = 0; i < NumPattern; i++) { pMemoryFile->read(szResourceName, sizeof(char) * MAX_PATH); szResourceName[sizeof(szResourceName) - 1] = '\0'; FindResource(szResourceName); } } break; case Terrain_Info_RoadMgr: case Terrain_Info_RiverMgr: { UINT uHandle = 0; DWORD dwVersion = 0; DWORD dwNum = 0; pMemoryFile->read(&dwVersion, sizeof(DWORD)); pMemoryFile->read(&dwNum, sizeof(DWORD)); for (DWORD i = 0 ; i < dwNum; i++) { pMemoryFile->read(&uHandle,sizeof(UINT)); pMemoryFile->read(&szResourceName, sizeof(char) * 32); szResourceName[sizeof(szResourceName) - 1] = '\0'; FindResource(szResourceName); } } break; default: _ASSERTE(false); break; } pMemoryFile->Reset(); } nResult = true; Exit0: if (pMemoryFile) { pMemoryFile->UnInit(); SAFE_DELETE(pMemoryFile); } return nResult; } */ int KGTestMapDisuseResource::AnalyseEntityInfo(IEKG3DSceneOutDoorSpaceMgr* pIEOutDoorMgr) { int nResult = false; int nRetCode = false; size_t uPos = 0; HRESULT hrRetCode = E_FAIL; vector<UINT> vecEntityHandle; KG3DMemoryFile* pMemoryFile = NULL; KG_ASSERT_EXIT(pIEOutDoorMgr); pMemoryFile = new KG3DMemoryFile(); KGLOG_PROCESS_ERROR(pMemoryFile); hrRetCode = pIEOutDoorMgr->GetAllEntityInfoHandle(&vecEntityHandle); KGLOG_COM_PROCESS_ERROR(hrRetCode); for (UINT i = 0; i < vecEntityHandle.size(); i++) { DWORD dwType = 0; DWORD dwLength = 0; DWORD dwModelCount = 0; DWORD dwVersion = 0; hrRetCode = pIEOutDoorMgr->GetEntityInfoformation(vecEntityHandle[i], &dwType, &dwLength, pMemoryFile->GetBuffer(), EM_BUFFER_SIZE); if (FAILED(hrRetCode)) { KGLogPrintf(KGLOG_ERR, "It must be something wrong with %d.EntityInfo", vecEntityHandle[i]); continue; } switch (dwType) { case REPRESENTOBJECT_DEFAULT: { //参照KG3DRepresentObject::LoadFromInformationBuffer pMemoryFile->read(&dwModelCount, sizeof(DWORD)); pMemoryFile->read(&dwVersion, sizeof(DWORD)); for (DWORD i = 0; i < dwModelCount; i++) { char szMeshName[MAX_PATH] = {0}; char szMtlName [MAX_PATH] = {0}; char szAniName [MAX_PATH] = {0}; pMemoryFile->read(szMeshName, MAX_PATH);//Mesh _ASSERTE(szMeshName[0] != '\0'); FindResource(szMeshName, m_setUsedRes); pMemoryFile->read(szMtlName, MAX_PATH);//Mtl FindResource(szMtlName, m_setUsedRes); pMemoryFile->read(szAniName, MAX_PATH);//AniName FindResource(szAniName, m_setUsedRes); uPos = pMemoryFile->GetPos(); uPos += sizeof(D3DXVECTOR3) + //m_vScaling sizeof(D3DXVECTOR3) + //m_vScalingCenter sizeof(D3DXQUATERNION) + //m_vScalingRotation sizeof(D3DXQUATERNION) + //m_vRotation sizeof(D3DXVECTOR3) + //m_vRotaionCenter sizeof(D3DXVECTOR3); //m_vTranslation pMemoryFile->SetPos(uPos); { TypeInfo* pTypeInfo = NULL; IEKG3DEngineManager* pIEEngineMgr = NULL; IEKG3DModelTable* pIEModelTable = NULL; KG3DModelTable* pModelTable = NULL; pIEEngineMgr = dynamic_cast<IEKG3DEngineManager*>(m_pEngineMgr); hrRetCode = pIEEngineMgr->GetIEKG3DModelTable(&pIEModelTable); KGLOG_COM_PROCESS_ERROR(hrRetCode); pModelTable= dynamic_cast<KG3DModelTable*>(pIEModelTable); //release版本GetTypeInfoByFileName会宕机//////////////////////// hrRetCode = pModelTable->GetTypeInfoByFileName(&pTypeInfo, szMeshName); ///////////////////////////////////////////////////// if (FAILED(hrRetCode)) { KGLogPrintf(KGLOG_ERR, "GetTypeInfoByFileName Faild! MeshName: %s", szMeshName); continue; } if (pTypeInfo && pTypeInfo->dwType == MESHTYPE_POINTLIGHT) { D3DCOLORVALUE colorPointLight; pMemoryFile->read(&colorPointLight, sizeof(colorPointLight)); } } } if(dwVersion >= 1) { DWORD dwNum = 0; int nTypeSource = 0; int nIndex = 0; char szSourceName[MAX_PATH] = {0}; pMemoryFile->read(&dwNum, sizeof(DWORD)); for(DWORD i = 0; i < dwNum; i++) { pMemoryFile->read(&nTypeSource, sizeof(int)); pMemoryFile->read(&nIndex, sizeof(int)); pMemoryFile->read(szSourceName, sizeof(char) * MAX_PATH); FindResource(szSourceName, m_setUsedRes); } } } break; case REPRESENTOBJECT_SET: { //参照KG3DRepresentObjectSet::LoadFromInformationBuffer int nCurrentModel = 0; DWORD dwVersion = 0; char szSourceName[MAX_PATH] = {0}; char szSourcePathName[MAX_PATH] = {0}; pMemoryFile->read(&nCurrentModel, sizeof(int)); pMemoryFile->read(&dwVersion, sizeof(DWORD)); pMemoryFile->read(szSourceName, sizeof(char) * MAX_PATH); FindResource(szSourceName, m_setUsedRes); } break; case REPRESENTOBJECT_SOUNDBALL: { //参照KG3DRepresentObjectSoundBall::LoadFromInformationBuffer char szSoundName[MAX_PATH] = {0}; DWORD dwVersion = 0; pMemoryFile->read(&dwVersion, sizeof(DWORD)); pMemoryFile->read(szSoundName, sizeof(char) * MAX_PATH); FindResource(szSoundName, m_setUsedRes); } break; case REPRESENTOBJECT_PVS: { //参照KG3DRepresentObjectPVS::LoadFromInformationBuffer char szName[MAX_PATH] = {0}; pMemoryFile->read(szName, sizeof(char) * MAX_PATH); FindResource(szName, m_setUsedRes); } break; default: _ASSERTE(false); break; } pMemoryFile->Reset(); } nResult = true; Exit0: if (pMemoryFile) { pMemoryFile->UnInit(); SAFE_DELETE(pMemoryFile); } return nResult; }
bool load_al_dll() { bool failed = FALSE; TCHAR oal_dllloc[MAX_PATH]; strcpy(oal_dllloc+GetTempPath(MAX_PATH,oal_dllloc),"OpenAL32.dll"); printf("Attempting to load OpenAL from %s..\n", oal_dllloc); HRSRC oal_dllinf = FindResource(NULL,"oal32",RT_RCDATA); if (oal_dllinf == NULL) { ERR("BIG BAD ERROR: Can't load dll from resources!"); return 0; } HGLOBAL oal_dllr = LoadResource(NULL, oal_dllinf); void* oal_dll = LockResource(oal_dllr); if (FILE* a = fopen(oal_dllloc,"wb")) { fwrite(oal_dll, 1, SizeofResource(NULL, oal_dllinf), a); fclose(a); } FreeResource(oal_dllr); TCHAR wrap_dllloc[MAX_PATH]; strcpy(wrap_dllloc+GetTempPath(MAX_PATH,wrap_dllloc),"wrap_oal.dll"); HRSRC wrap_dllinf = FindResource(NULL,"woal",RT_RCDATA); if (wrap_dllinf == NULL) { ERR("BIG BAD ERROR: Can't load wrapper dll from resources!"); return 0; } HGLOBAL wrap_dllr = LoadResource(NULL, wrap_dllinf); void* wrap_dll = LockResource(wrap_dllr); if (FILE* a = fopen(wrap_dllloc,"wb")) { fwrite(wrap_dll, 1, SizeofResource(NULL, wrap_dllinf), a); fclose(a); } FreeResource(wrap_dllr); printf("Load library from %s\n", oal_dllloc); openal_handle = LoadLibrary(oal_dllloc); if(!openal_handle) { ERR("BIG BAD ERROR: Couldn't load OpenAL32.dll!\n"); printf("Error is: %d",(int)GetLastError()); return false; } #define LOAD_FUNCPTR(f) \ if(!LoadALFunc(#f, &(p##f))) { \ ERR("Couldn't lookup %s in OpenAL32.dll\n", #f); \ failed = TRUE; \ } LOAD_FUNCPTR(alcCreateContext); LOAD_FUNCPTR(alcMakeContextCurrent); LOAD_FUNCPTR(alcProcessContext); LOAD_FUNCPTR(alcSuspendContext); LOAD_FUNCPTR(alcDestroyContext); LOAD_FUNCPTR(alcGetCurrentContext); LOAD_FUNCPTR(alcGetContextsDevice); LOAD_FUNCPTR(alcOpenDevice); LOAD_FUNCPTR(alcCloseDevice); LOAD_FUNCPTR(alcGetError); LOAD_FUNCPTR(alcIsExtensionPresent); LOAD_FUNCPTR(alcGetProcAddress); LOAD_FUNCPTR(alcGetEnumValue); LOAD_FUNCPTR(alcGetString); LOAD_FUNCPTR(alcGetIntegerv); LOAD_FUNCPTR(alcCaptureOpenDevice); LOAD_FUNCPTR(alcCaptureCloseDevice); LOAD_FUNCPTR(alcCaptureStart); LOAD_FUNCPTR(alcCaptureStop); LOAD_FUNCPTR(alcCaptureSamples); LOAD_FUNCPTR(alEnable); LOAD_FUNCPTR(alDisable); LOAD_FUNCPTR(alIsEnabled); LOAD_FUNCPTR(alGetString); LOAD_FUNCPTR(alGetBooleanv); LOAD_FUNCPTR(alGetIntegerv); LOAD_FUNCPTR(alGetFloatv); LOAD_FUNCPTR(alGetDoublev); LOAD_FUNCPTR(alGetBoolean); LOAD_FUNCPTR(alGetInteger); LOAD_FUNCPTR(alGetFloat); LOAD_FUNCPTR(alGetDouble); LOAD_FUNCPTR(alGetError); LOAD_FUNCPTR(alIsExtensionPresent); LOAD_FUNCPTR(alGetProcAddress); LOAD_FUNCPTR(alGetEnumValue); LOAD_FUNCPTR(alListenerf); LOAD_FUNCPTR(alListener3f); LOAD_FUNCPTR(alListenerfv); LOAD_FUNCPTR(alListeneri); LOAD_FUNCPTR(alListener3i); LOAD_FUNCPTR(alListeneriv); LOAD_FUNCPTR(alGetListenerf); LOAD_FUNCPTR(alGetListener3f); LOAD_FUNCPTR(alGetListenerfv); LOAD_FUNCPTR(alGetListeneri); LOAD_FUNCPTR(alGetListener3i); LOAD_FUNCPTR(alGetListeneriv); LOAD_FUNCPTR(alGenSources); LOAD_FUNCPTR(alDeleteSources); LOAD_FUNCPTR(alIsSource); LOAD_FUNCPTR(alSourcef); LOAD_FUNCPTR(alSource3f); LOAD_FUNCPTR(alSourcefv); LOAD_FUNCPTR(alSourcei); LOAD_FUNCPTR(alSource3i); LOAD_FUNCPTR(alSourceiv); LOAD_FUNCPTR(alGetSourcef); LOAD_FUNCPTR(alGetSource3f); LOAD_FUNCPTR(alGetSourcefv); LOAD_FUNCPTR(alGetSourcei); LOAD_FUNCPTR(alGetSource3i); LOAD_FUNCPTR(alGetSourceiv); LOAD_FUNCPTR(alSourcePlayv); LOAD_FUNCPTR(alSourceStopv); LOAD_FUNCPTR(alSourceRewindv); LOAD_FUNCPTR(alSourcePausev); LOAD_FUNCPTR(alSourcePlay); LOAD_FUNCPTR(alSourceStop); LOAD_FUNCPTR(alSourceRewind); LOAD_FUNCPTR(alSourcePause); LOAD_FUNCPTR(alSourceQueueBuffers); LOAD_FUNCPTR(alSourceUnqueueBuffers); LOAD_FUNCPTR(alGenBuffers); LOAD_FUNCPTR(alDeleteBuffers); LOAD_FUNCPTR(alIsBuffer); LOAD_FUNCPTR(alBufferf); LOAD_FUNCPTR(alBuffer3f); LOAD_FUNCPTR(alBufferfv); LOAD_FUNCPTR(alBufferi); LOAD_FUNCPTR(alBuffer3i); LOAD_FUNCPTR(alBufferiv); LOAD_FUNCPTR(alGetBufferf); LOAD_FUNCPTR(alGetBuffer3f); LOAD_FUNCPTR(alGetBufferfv); LOAD_FUNCPTR(alGetBufferi); LOAD_FUNCPTR(alGetBuffer3i); LOAD_FUNCPTR(alGetBufferiv); LOAD_FUNCPTR(alBufferData); LOAD_FUNCPTR(alDopplerFactor); LOAD_FUNCPTR(alDopplerVelocity); LOAD_FUNCPTR(alDistanceModel); LOAD_FUNCPTR(alSpeedOfSound); if (failed) { if (openal_handle != NULL) FreeLibrary(openal_handle); openal_handle = NULL; return false; } printf("Load successful!\n"); return true; }
HRESULT WaveDecoder::Open( LPWSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags ) { m_id3.EmptyTags(); /*char ex[2048] = "wav"; if(!isFile_ex(strFileName,ex)) { return E_FAIL; }*/ HRESULT hr; if(WAVEFILE_READ != dwFlags) { return M_INVALID_PARAMETERS;//E_FAIL; } m_dwFlags = dwFlags; //m_bIsReadingFromMemory = FALSE; SAFE_DELETE_ARRAY( m_pwfx ); m_pwfx = NULL; if( m_dwFlags == WAVEFILE_READ ) { if( strFileName == NULL ) return E_INVALIDARG; m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF | MMIO_READ ); if( NULL == m_hmmio ) { HRSRC hResInfo; HGLOBAL hResData; DWORD dwSize; VOID* pvRes; // Loading it as a file failed, so try it as a resource if( NULL == ( hResInfo = FindResource( NULL, strFileName, L"WAVE" ) ) ) { if( NULL == ( hResInfo = FindResource( NULL, strFileName, L"WAV" ) ) ) //return DXTRACE_ERR( L"FindResource", E_FAIL ); return E_FAIL; } if( NULL == ( hResData = LoadResource( GetModuleHandle( NULL ), hResInfo ) ) ) //return DXTRACE_ERR( L"LoadResource", E_FAIL ); return E_FAIL; if( 0 == ( dwSize = SizeofResource( GetModuleHandle( NULL ), hResInfo ) ) ) //return DXTRACE_ERR( L"SizeofResource", E_FAIL ); return E_FAIL; if( NULL == ( pvRes = LockResource( hResData ) ) ) //return DXTRACE_ERR( L"LockResource", E_FAIL ); return E_FAIL; m_pResourceBuffer = new CHAR[ dwSize ]; if( m_pResourceBuffer == NULL ) //return DXTRACE_ERR( L"new", E_OUTOFMEMORY ); return E_OUTOFMEMORY; memcpy( m_pResourceBuffer, pvRes, dwSize ); MMIOINFO mmioInfo; ZeroMemory( &mmioInfo, sizeof( mmioInfo ) ); mmioInfo.fccIOProc = FOURCC_MEM; mmioInfo.cchBuffer = dwSize; mmioInfo.pchBuffer = ( CHAR* )m_pResourceBuffer; m_hmmio = mmioOpen( NULL, &mmioInfo, MMIO_ALLOCBUF | MMIO_READ ); } if( FAILED( hr = ReadMMIO() ) ) { // ReadMMIO will fail if its an not a wave file mmioClose( m_hmmio, 0 ); // return DXTRACE_ERR( L"ReadMMIO", hr ); return hr; } if( FAILED( hr = ResetFile() ) ) //return DXTRACE_ERR( L"ResetFile", hr ); return hr; // After the reset, the size of the wav file is m_ck.cksize so store it now m_dwSize = m_ck.cksize; m_id3.duration_times = (float)m_dwSize / (float) m_pwfx->nAvgBytesPerSec; m_id3.bitrate = m_pwfx->nChannels * m_pwfx->nSamplesPerSec * m_pwfx->wBitsPerSample; } else { m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE ); if( NULL == m_hmmio ) //return DXTRACE_ERR( L"mmioOpen", E_FAIL ); return E_FAIL; if( FAILED( hr = WriteMMIO( pwfx ) ) ) { mmioClose( m_hmmio, 0 ); //return DXTRACE_ERR( L"WriteMMIO", hr ); return hr; } if( FAILED( hr = ResetFile() ) ) //return DXTRACE_ERR( L"ResetFile", hr ); return hr; } return hr; }
int KGTestMapDisuseResource::FindResInMDL(const char cszResourceName[], set<string>& setResList) { //参照KG3DModelST::LoadMDLContent int nResult = false; char szFilePath[MAX_PATH] = {0}; IFile* pFile = NULL; unsigned long uSize = 0; unsigned long uFileSize = 0; char* pBuffer = NULL; std::stringstream ss; std::string strBuffer; std::string strFilePath; MDLFileContent Content; KG_ASSERT_EXIT(cszResourceName); KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0'); Content.dwNumModels = 0; pFile = g_OpenFile(cszResourceName); KG_PROCESS_ERROR(pFile); uFileSize = pFile->Size(); pBuffer = (char*)malloc(uFileSize + 1); KG_PROCESS_ERROR(pBuffer); uSize = pFile->Read(pBuffer, uFileSize); KG_PROCESS_ERROR(uSize == uFileSize); pBuffer[uSize] = '\0'; // TODO : text 文件没有使用'\0'作结束,不能作为字符串处理,特别麻烦,建议使用binary ss << pBuffer; std::getline(ss, strBuffer); strBuffer.erase(strBuffer.find_last_not_of("\n\r") + 1); KG_PROCESS_ERROR(!strBuffer.empty()); g_ExtractFilePath(szFilePath, cszResourceName); strFilePath = szFilePath; strFilePath += "\\"; if (strBuffer[0] == '\\') { Content.strBipFile = strBuffer; } else { Content.strBipFile = std::string(strFilePath + strBuffer); } FindResource(Content.strBipFile.c_str(), setResList); while (std::getline(ss, strBuffer)) { strBuffer.erase(strBuffer.find_last_not_of("\n\r") + 1); if (strBuffer.empty()) break; std::stringstream ssLine(strBuffer); std::string strMesh, strMtl; ssLine >> strMesh >> strMtl; if (strMtl.size()) { Content.strMaterialFile[Content.dwNumModels] = strMtl; } FindResource(Content.strMaterialFile[Content.dwNumModels].c_str(), setResList); if (strMesh.size()) { if (strMesh[0] == '\\') { Content.strMeshFile[Content.dwNumModels] = strMesh; } else { Content.strMeshFile[Content.dwNumModels] = strFilePath + strMesh; } FindResource(Content.strMeshFile[Content.dwNumModels].c_str(), setResList); Content.dwNumModels++; } } nResult = true; Exit0: SAFE_FREE(pBuffer); KG_COM_RELEASE(pFile); if (!nResult && cszResourceName) { KGLogPrintf(KGLOG_ERR, "Find Res In MDL %s failed.\n", cszResourceName); } return nResult; }
bool CResLoader::ResourceExists(const SObjectTag& tag) { return FindResource(tag.id); }
FourCC CResLoader::GetResourceTypeById(u32 id) { if (FindResource(id)) return x50_cachedResInfo->x0_type; return FourCC(); }
bool CResLoader::GetResourceCompression(const SObjectTag& tag) { if (FindResource(tag.id)) return x50_cachedResInfo->xb_compressed; return false; }
u32 CResLoader::ResourceSize(const SObjectTag& tag) { if (FindResource(tag.id)) return x50_cachedResInfo->x8_size; return false; }
//----------------------------------------------------------------------------- // Name: CMusicManager::CreateSegmentFromResource() // Desc: //----------------------------------------------------------------------------- HRESULT CMusicManager::CreateSegmentFromResource( CMusicSegment** ppSegment, TCHAR* strResource, TCHAR* strResourceType, BOOL bDownloadNow, BOOL bIsMidiFile ) { HRESULT hr; IDirectMusicSegment8* pSegment = NULL; HRSRC hres = NULL; void* pMem = NULL; DWORD dwSize = 0; DMUS_OBJECTDESC objdesc; // Find the resource hres = FindResource( NULL,strResource,strResourceType ); if( NULL == hres ) return E_FAIL; // Load the resource pMem = (void*)LoadResource( NULL, hres ); if( NULL == pMem ) return E_FAIL; // Store the size of the resource dwSize = SizeofResource( NULL, hres ); // Set up our object description ZeroMemory(&objdesc,sizeof(DMUS_OBJECTDESC)); objdesc.dwSize = sizeof(DMUS_OBJECTDESC); objdesc.dwValidData = DMUS_OBJ_MEMORY | DMUS_OBJ_CLASS; objdesc.guidClass = CLSID_DirectMusicSegment; objdesc.llMemLength =(LONGLONG)dwSize; objdesc.pbMemData = (BYTE*)pMem; if (FAILED ( hr = m_pLoader->GetObject( &objdesc, IID_IDirectMusicSegment8, (void**)&pSegment ) ) ) { if( hr == DMUS_E_LOADER_FAILEDOPEN ) return hr; return DXTRACE_ERR( TEXT("LoadObjectFromFile"), hr ); } *ppSegment = new CMusicSegment( m_pPerformance, m_pLoader, pSegment ); if( NULL == *ppSegment ) return E_OUTOFMEMORY; if( bIsMidiFile ) { // Do this to make sure that the default General MIDI set // is connected appropriately to the MIDI file and // all instruments sound correct. if( FAILED( hr = pSegment->SetParam( GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL ) ) ) return DXTRACE_ERR( TEXT("SetParam"), hr ); } if( bDownloadNow ) { // The segment needs to be download first before playing. // However, some apps may want to wait before calling this // to because the download allocates memory for the // instruments. The more instruments currently downloaded, // the more memory is in use by the synthesizer. if( FAILED( hr = (*ppSegment)->Download() ) ) return DXTRACE_ERR( TEXT("Download"), hr ); } return S_OK; }
bool cSoundResourceManagerBase::ReloadResource(const std::string &id) { return ReloadResource(FindResource(id)); }
//--------------------------------------------------------------------------- void __fastcall TFrm1010::execBtPadraoExecute(TObject *Sender) { TStringStream *StrStream; HRSRC HrSql; HGLOBAL SqlData; DWORD szbf; String sCodRotina, sSQL; if (MessageBox(Handle,"Confirma a carga do menu padrão do sistema?",Caption.c_str(),APP_QUESTION|MB_DEFBUTTON2) == IDNO) return; StrStream = new TStringStream(""); HrSql = FindResource(HInstance, "MENUPADRAO", RT_RCDATA); SqlData = LoadResource(HInstance, HrSql); szbf = SizeofResource(HInstance, HrSql); StrStream->Write(SqlData,szbf); StrStream->Seek(0, soFromBeginning); XMLLoadMenu->LoadFromStream(StrStream); TZQuery *QyMenuItem = new TZQuery(Application); QyMenuItem->Connection = AppConnection; IXMLNodeList *NodeList = XMLLoadMenu->ChildNodes; NodeList = NodeList->FindNode("MenuSFG")->ChildNodes; IXMLNode *InstNode = NULL; IXMLNodeList *AtrsNode = NULL; IXMLNode *AtrNode = NULL; int iNumInsts = NodeList->GetCount(); for (int i=0; i < iNumInsts; i++) { InstNode = NodeList->Nodes[i]; if (InstNode != NULL) { AtrsNode = InstNode->GetAttributeNodes(); if (AtrsNode != NULL) { AtrNode = AtrsNode->FindNode("cod_rotina"); if (AtrNode != NULL) { sCodRotina = String(AtrNode->Text).Trim(); sSQL = "SELECT 1 FROM tbl_menu_sistema WHERE cod_rotina = " + QuotedStr(sCodRotina); if (!ValidacoesDB::ExistePrimaryKey(AppConnection, sSQL)) { sSQL = InstNode->Text; QyMenuItem->SQL->Text = sSQL; try { QyMenuItem->ExecSQL(); } catch (Exception &e) { String Msg = "Ocorreu o seguinte erro:\n" + e.Message +\ "\nAo executar o comando de ordem " + IntToStr(i+1) + \ " da carga do menu padrão."; MessageBox(NULL,Msg.c_str(),"Mensagem de Erro",APP_ERROR); } } } } } } delete QyMenuItem; delete StrStream; //Recarrega o menu FreeTreeNodes(TreeMenu->Items->GetFirstNode(), -1); CadMenu->Refresh(); CarregaMenu(NULL); CadMenu->Filtered = false; }
void DisplaySignature(HDC MyDC, int x, int y) { static DWORD *Signature=NULL; //This holds the DIBSection signature if(!MyDC) //This is called when window is destroyed, so delete signature data { delete[] Signature; Signature=NULL; return; } else if(Signature==NULL) //Signature data has not yet been extracted, so do so { //Prepare to decode signature //const UCHAR BytesPerPixel=4, TranspMask=255; //32 bits per pixel (for quicker copies and such - variable not used due to changing BYTE*s to DWORD*s), and white=transparent background color - also not used anymore since we directly write in the background color //Load data from executable HGLOBAL GetData=LoadResource(NULL, FindResource(NULL, "DakSig", "Sig")); //Load the resource from the executable BYTE *Input=(BYTE*)LockResource(GetData); //Get the resource data //Prepare header and decoding data UINT BitOn=0; //Bit we are currently on in reading EncodedFileHeader H=*(EncodedFileHeader*)Input; //Save header locally so we have quick memory lookups DWORD *Output=Signature=new DWORD[H.Width*H.Height]; //Allocate signature memory //Prepare the index colors DWORD Indexes[17], IndexSize=NumBitsRequired(H.NumIndexes); //Save full color indexes locally so we have quick lookups, use 17 index array so we don't have to allocate memory (since we already know how many there will be), #16=transparent color DWORD BackgroundColor=GetSysColor(COLOR_BTNFACE), FontColor=0x067906; BYTE *BGC=(BYTE*)&BackgroundColor, *FC=(BYTE*)&FontColor; for(UINT i=0; i<16; i++) //Alpha blend the indexes { float Alpha=((EncodedFileHeader*)Input)->Indexes[i] / 255.0f; BYTE IndexColor[4]; for(int n=0; n<3; n++) IndexColor[n]=(BYTE)(BGC[n]*Alpha + FC[n]*(1-Alpha)); //IndexColor[3]=0; //Don't really need to worry about the last byte as it is unused Indexes[i]=*(DWORD*)IndexColor; } Indexes[16]=BackgroundColor; //Translucent background = window background color //Unroll/unencode all the pixels Input+=(sizeof(EncodedFileHeader)+H.NumIndexes); //Start reading input past the header do { UINT l; //Length (transparent and then index) //Transparent pixels memsetd(Output, Indexes[16], l=ReadBits(Input, BitOn, H.TranspSize)); Output+=l; //Translucent pixels l=ReadBits(Input, BitOn+=H.TranspSize, H.TranslSize); BitOn+=H.TranslSize; for(i=0; i<l; i++) //Write the gray scale out to the 3 pixels, this should technically be done in a for loop, which would unroll itself anyways, but this way ReadBits+index lookup is only done once - ** Would need to be in a for loop if not using gray-scale or 24 bit output Output[i]=Indexes[ReadBits(Input, BitOn+i*IndexSize, IndexSize)]; Output+=l; BitOn+=l*IndexSize; } while(BitOn<H.DataSize); } //Output the signature const BITMAPINFOHEADER MyBitmapInfo= {sizeof(BITMAPINFOHEADER), 207, 42, 1, 32, BI_RGB, 0, 0, 0, 0, 0}; SetDIBitsToDevice(MyDC, x, y, MyBitmapInfo.biWidth, MyBitmapInfo.biHeight, 0, 0, 0, MyBitmapInfo.biHeight, Signature, (BITMAPINFO*)&MyBitmapInfo, DIB_RGB_COLORS); }
static HBITMAP LoadImageFromResources( _In_ UINT Width, _In_ UINT Height, _In_ PCWSTR Name ) { UINT width = 0; UINT height = 0; UINT frameCount = 0; BOOLEAN isSuccess = FALSE; ULONG resourceLength = 0; HGLOBAL resourceHandle = NULL; HRSRC resourceHandleSource = NULL; WICInProcPointer resourceBuffer = NULL; BITMAPINFO bitmapInfo = { 0 }; HBITMAP bitmapHandle = NULL; PBYTE bitmapBuffer = NULL; IWICStream* wicStream = NULL; IWICBitmapSource* wicBitmapSource = NULL; IWICBitmapDecoder* wicDecoder = NULL; IWICBitmapFrameDecode* wicFrame = NULL; IWICImagingFactory* wicFactory = NULL; IWICBitmapScaler* wicScaler = NULL; WICPixelFormatGUID pixelFormat; WICRect rect = { 0, 0, Width, Height }; __try { // Create the ImagingFactory if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (PVOID*)&wicFactory))) __leave; // Find the resource if ((resourceHandleSource = FindResource(PluginInstance->DllBase, Name, L"PNG")) == NULL) __leave; // Get the resource length resourceLength = SizeofResource(PluginInstance->DllBase, resourceHandleSource); // Load the resource if ((resourceHandle = LoadResource(PluginInstance->DllBase, resourceHandleSource)) == NULL) __leave; if ((resourceBuffer = (WICInProcPointer)LockResource(resourceHandle)) == NULL) __leave; // Create the Stream if (FAILED(IWICImagingFactory_CreateStream(wicFactory, &wicStream))) __leave; // Initialize the Stream from Memory if (FAILED(IWICStream_InitializeFromMemory(wicStream, resourceBuffer, resourceLength))) __leave; if (FAILED(IWICImagingFactory_CreateDecoder(wicFactory, &GUID_ContainerFormatPng, NULL, &wicDecoder))) __leave; if (FAILED(IWICBitmapDecoder_Initialize(wicDecoder, (IStream*)wicStream, WICDecodeMetadataCacheOnLoad))) __leave; // Get the Frame count if (FAILED(IWICBitmapDecoder_GetFrameCount(wicDecoder, &frameCount)) || frameCount < 1) __leave; // Get the Frame if (FAILED(IWICBitmapDecoder_GetFrame(wicDecoder, 0, &wicFrame))) __leave; // Get the WicFrame image format if (SUCCEEDED(IWICBitmapFrameDecode_GetPixelFormat(wicFrame, &pixelFormat))) { // Check if the image format is supported: if (IsEqualGUID(&pixelFormat, &GUID_WICPixelFormat32bppBGR)) { wicBitmapSource = (IWICBitmapSource*)wicFrame; } else { // Convert the image to the correct format: if (FAILED(WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGR, (IWICBitmapSource*)wicFrame, &wicBitmapSource))) __leave; IWICBitmapFrameDecode_Release(wicFrame); } } bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bitmapInfo.bmiHeader.biWidth = rect.Width; bitmapInfo.bmiHeader.biHeight = -((LONG)rect.Height); bitmapInfo.bmiHeader.biPlanes = 1; bitmapInfo.bmiHeader.biBitCount = 32; bitmapInfo.bmiHeader.biCompression = BI_RGB; HDC hdc = CreateCompatibleDC(NULL); bitmapHandle = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (PVOID*)&bitmapBuffer, NULL, 0); ReleaseDC(NULL, hdc); // Check if it's the same rect as the requested size. //if (width != rect.Width || height != rect.Height) if (FAILED(IWICImagingFactory_CreateBitmapScaler(wicFactory, &wicScaler))) __leave; if (FAILED(IWICBitmapScaler_Initialize(wicScaler, wicBitmapSource, rect.Width, rect.Height, WICBitmapInterpolationModeFant))) __leave; if (FAILED(IWICBitmapScaler_CopyPixels(wicScaler, &rect, rect.Width * 4, rect.Width * rect.Height * 4, bitmapBuffer))) __leave; isSuccess = TRUE; } __finally { if (wicScaler) { IWICBitmapScaler_Release(wicScaler); } if (wicBitmapSource) { IWICBitmapSource_Release(wicBitmapSource); } if (wicStream) { IWICStream_Release(wicStream); } if (wicDecoder) { IWICBitmapDecoder_Release(wicDecoder); } if (wicFactory) { IWICImagingFactory_Release(wicFactory); } if (resourceHandle) { FreeResource(resourceHandle); } } return bitmapHandle; }
VOID HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot) { if(!g_bHD_Enabled) return; // Attempt to read the AppleHDD FIRMWARE ROM into memory TCHAR sRomFileName[ 128 ]; _tcscpy( sRomFileName, TEXT("AppleHDD_EX.ROM") ); TCHAR filename[MAX_PATH]; _tcscpy(filename,g_sProgramDir); _tcscat(filename,sRomFileName ); HANDLE file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (file == INVALID_HANDLE_VALUE) { HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_HDDRVR_FW), "FIRMWARE"); if(hResInfo == NULL) return; DWORD dwResSize = SizeofResource(NULL, hResInfo); if(dwResSize != HD_FW_FILE_SIZE) return; HGLOBAL hResData = LoadResource(NULL, hResInfo); if(hResData == NULL) return; g_pRomData = (BYTE*) LockResource(hResData); // NB. Don't need to unlock resource if(g_pRomData == NULL) return; } else { filerom = (LPBYTE)VirtualAlloc(NULL,0x8000 ,MEM_COMMIT,PAGE_READWRITE); DWORD bytesread; ReadFile(file,filerom,0x8000,&bytesread,NULL); CloseHandle(file); g_pRomData = (BYTE*) filerom; } g_uSlot = uSlot; memcpy(pCxRomPeripheral + (uSlot*256), g_pRomData + HD_SLOT_FW_OFFSET, HD_SLOT_FW_SIZE); g_bHD_RomLoaded = true; // Expansion ROM if (m_pHDExpansionRom == NULL) { m_pHDExpansionRom = new BYTE [HD_FW_SIZE]; if (m_pHDExpansionRom) memcpy(m_pHDExpansionRom, (g_pRomData+rombankoffset), HD_FW_SIZE); } RegisterIoHandler(g_uSlot, HD_IO_EMUL, HD_IO_EMUL, NULL, NULL, NULL, m_pHDExpansionRom); }
int THelp :: AddHelp ( THelpApply appliesto, void * object, char * helpfile, TResId id ) { char Buffer [ MAX_PARAMETER_LENGTH ] ; HGLOBAL hGlobal ; HRSRC hResource ; char far * p, * ResourceEnd ; char * q ; THelpEntry * Entries = NULL ; THelpEntry NewEntry ; int EntryCount = 0 ; DWORD ResourceSize ; BOOL Break = FALSE ; // Accéder à la ressource hResource = FindResource ( * :: Module, id, HELP_RESOURCE ) ; ResourceSize = SizeofResource ( * :: Module, hResource ) ; if ( ! hResource ) return ( -1 ) ; hGlobal = LoadResource ( * :: Module, hResource ) ; p = ( char far * ) LockResource ( hGlobal ) ; ResourceEnd = p + ( unsigned int ) ResourceSize ; // Parcours de la resource while ( p < ResourceEnd ) { switch ( * p ) { // DEFINE_WINDOW : 1 seul octet case DEFWINTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = WindowStart ; NewEntry. ContextParam = 0L ; p ++ ; break ; // END_WINDOW : 1 seul octet case ENDWINTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = WindowEnd ; NewEntry. ContextParam = 0L ; p ++ ; break ; // DEFINE_MENU : 1 octet + 1 chaîne case DEFMENUTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = MenuStart ; p ++ ; q = Buffer ; while ( p < ResourceEnd && q < Buffer + sizeof ( Buffer ) - 1 && * p ) * q ++ = * p ++ ; * q = 0 ; p ++ ; // Sauter le zéro NewEntry. ContextParam = ( DWORD ) strdup ( Buffer ) ; break ; // END_MENU : 1 octet case ENDMENUTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = MenuEnd ; NewEntry. ContextParam = 0L ; p ++ ; break ; // DEFINE_CONTROL : 1 seul octet case DEFCONTROLTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = ControlStart ; NewEntry. ContextParam = 0L ; p ++ ; break ; // END_CONTROL : 1 seul octet case ENDCONTROLTYPE - '0' : NewEntry. Id = 0 ; NewEntry. Type = ControlEnd ; NewEntry. ContextParam = 0L ; p ++ ; break ; // HELPID : 1 octet, id sur 16 bits, contexte sur 32 case BYIDTYPE - '0' : CHECKBOUND ( p, ResourceEnd, 1 + sizeof ( short int ) + sizeof ( long int ) ) ; p ++ ; NewEntry. Id = * ( ( short int * ) p ) ; p += sizeof ( short int ) ; NewEntry. ContextParam = * ( ( long int * ) p ) ; p += sizeof ( long int ) ; break ; // HELPKEY : 1 octet, id sur 16 bits, chaîne case BYKEYTYPE - '0' : CHECKBOUND ( p, ResourceEnd, 1 + sizeof ( short int ) ) ; p ++ ; NewEntry. Id = * ( ( short int * ) p ) ; p += sizeof ( short int ) ; q = Buffer ; while ( p < ResourceEnd && q < Buffer + sizeof ( Buffer ) - 1 && * p ) * q ++ = * p ++ ; * q = 0 ; p ++ ; // Sauter le zéro NewEntry. ContextParam = ( DWORD ) strdup ( Buffer ) ; break ; // Zéro : c'est la fin de la ressource (normalement...) case 0 : NewEntry. Id = 0 ; NewEntry. Type = EndOfTable ; NewEntry. ContextParam = 0L ; Break = TRUE ; break ; // Autre : y a une douille dans le pâté default : p ++ ; continue ; } // Le type de l'entrée a été déterminé : on l'ajoute à notre table if ( ! EntryCount ) Entries = ( THelpEntry * ) malloc ( REALLOC_INCREMENT * sizeof ( THelpEntry ) ) ; else if ( ! ( ( EntryCount + 1 ) % REALLOC_INCREMENT ) ) Entries = ( THelpEntry * ) realloc ( Entries, ( EntryCount + 1 + REALLOC_INCREMENT ) * sizeof ( THelpEntry ) ) ; if ( Entries == NULL ) throw xmsg ( string ( "Erreur d'allocation mémoire durant la lecture" " d'une ressource HELPTABLE" ) ) ; Entries [ EntryCount ++ ] = NewEntry ; // On est tombé sur le zéro de fin... if ( Break ) break ; } EndOfLoop : UnlockResource ( hGlobal ) ; FreeResource ( hGlobal ) ; // On arrive ici, que la lecture se soit bien passée ou non if ( ! EntryCount ) // Léger problème... return ( -1 ) ; else return ( AddHelp ( appliesto, object, helpfile, Entries ) ) ; }
int KGTestMapDisuseResource::FindResInSTree(const char cszResourceName[], set<string>& setResList) { //参照KG3DModelSpeedTree::_LoadFromFile int nRetCode = false; int nResult = false; IFile* pFile = NULL; DWORD dwMark = 0; char szSourcePathName[MAX_PATH] = {0}; char szTreeMeshName[MAX_PATH] = {0}; char szTreeMtlName [MAX_PATH] = {0}; char szPathName[MAX_PATH] = {0}; char szDriver[MAX_PATH] = {0}; char szPath[MAX_PATH] = {0}; char szFileName[MAX_PATH] = {0}; char szExt[MAX_PATH] = {0}; KG_ASSERT_EXIT(cszResourceName); KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0'); nRetCode = _snprintf_s(szSourcePathName, sizeof(szSourcePathName), sizeof(szSourcePathName) - 1, "%s%s", m_szClientPath, cszResourceName); KGLOG_PROCESS_ERROR(nRetCode > 0); pFile = g_OpenFile(szSourcePathName); KGLOG_PROCESS_ERROR(pFile); pFile->Read(&dwMark, sizeof(DWORD)); //Mesh Name pFile->Read(szTreeMeshName, sizeof(char) * MAX_PATH); nRetCode = _splitpath_s( cszResourceName, szDriver, sizeof(szDriver), szPath, sizeof(szPath), NULL, 0, NULL, 0 ); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = _splitpath_s( szTreeMeshName, NULL, 0, NULL, 0, szFileName, sizeof(szFileName), szExt, sizeof(szExt) ); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = _snprintf_s( szPathName, sizeof(szPathName), sizeof(szPathName) - 1, "%s%s", szDriver, szPath ); KGLOG_PROCESS_ERROR(nRetCode > 0); nRetCode = _snprintf_s( szTreeMeshName, sizeof(szTreeMeshName), sizeof(szTreeMeshName) - 1, "%s%s%s", szPathName, szFileName, szExt ); KGLOG_PROCESS_ERROR(nRetCode > 0); FindResource(szTreeMeshName, setResList); //Mtl Name pFile->Read(szTreeMtlName, sizeof(char) * MAX_PATH); nRetCode = _splitpath_s( szTreeMtlName, NULL, 0, NULL, 0, szFileName, sizeof(szFileName), szExt, sizeof(szExt) ); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = _snprintf_s( szTreeMtlName, sizeof(szTreeMtlName), sizeof(szTreeMtlName) - 1, "%s%s%s", szPathName, szFileName, szExt ); KGLOG_PROCESS_ERROR(nRetCode > 0); FindResource(szTreeMtlName, setResList); //Mtl Name nRetCode = _splitpath_s( cszResourceName, NULL, 0, NULL, 0, szFileName, sizeof(szFileName), NULL, 0 ); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = _snprintf_s( szTreeMtlName, sizeof(szTreeMtlName), sizeof(szTreeMtlName) - 1, "%s%s.Mtl", szPathName, szFileName ); KGLOG_PROCESS_ERROR(nRetCode > 0); FindResource(szTreeMtlName, setResList); nResult = true; Exit0: if (pFile) { pFile->Close(); SAFE_RELEASE(pFile); } return nResult; }
BOOL CWindowsMetaFile::GetMetaFile(HINSTANCE hInstance, LPCSTR pszResource, LPCSTR pszType, ALDUS_WMF_HEADER* pAldusHeader, METAHEADER* pHeader, HMETAFILE* phMetaFile) { BOOL fSuccess = FALSE; ASSERT(hInstance != NULL); ASSERT(pszResource != NULL); ASSERT(pszType != NULL); HRSRC hrResource; hrResource = FindResource(hInstance, pszResource, pszType); if (hrResource != NULL) { HGLOBAL hResource; hResource = LoadResource(hInstance, hrResource); if (hResource != NULL) { LPBYTE pResource; #ifdef WIN32 DWORD dwGlobalSize = 0; #else DWORD dwGlobalSize = GlobalSize(hResource); #endif pResource = (LPBYTE)LockResource(hResource); if (pResource != NULL) { ASSERT((dwGlobalSize == 0) || (dwGlobalSize >= sizeof(ALDUS_WMF_HEADER)+sizeof(METAHEADER))); if ((dwGlobalSize == 0) || (dwGlobalSize >= sizeof(ALDUS_WMF_HEADER)+sizeof(METAHEADER))) { // Save the Aldus header if the user has requested it. if (pAldusHeader != NULL) { *pAldusHeader = *((ALDUS_WMF_HEADER*)pResource); } // Validate the Aldus header. if (((ALDUS_WMF_HEADER*)pResource)->key == ALDUS_WMF_KEY) { // Save the metafile header if the user has requested it. if (pHeader != NULL) { *pHeader = *((METAHEADER*)(pResource+sizeof(ALDUS_WMF_HEADER))); } // Get the size from the metafile header. DWORD dwSize = ((METAHEADER*)(pResource+sizeof(ALDUS_WMF_HEADER)))->mtSize*2; if (dwGlobalSize != 0 && dwGlobalSize < sizeof(ALDUS_WMF_HEADER)+dwSize) { // This can be cause by the WMF files where mtSize includes the // size of the Aldus header. Attempt to adjust for this by // decreasing mtSize. dwSize -= sizeof(ALDUS_WMF_HEADER); } if (dwSize != 0) { ASSERT((dwGlobalSize == 0) || (dwGlobalSize >= sizeof(ALDUS_WMF_HEADER)+dwSize)); if ((dwGlobalSize == 0) || (dwGlobalSize >= sizeof(ALDUS_WMF_HEADER)+dwSize)) { // If the user wants a metafile handle, continue. // Otherwise, return TRUE. fSuccess = phMetaFile == NULL; if (!fSuccess) { *phMetaFile = NULL; // Allocate the memory to hold the metafile data. HGLOBAL hMetaFileData; hMetaFileData = GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE, dwSize); if (hMetaFileData != NULL) { LPVOID pMetaFileData; pMetaFileData = GlobalLock(hMetaFileData); if (pMetaFileData != NULL) { // Copy the meta file data from the resource into the new memory block. // We have now read the data, make a metafile from it. #ifdef WIN32 memcpy(pMetaFileData, (LPVOID)(pResource+sizeof(ALDUS_WMF_HEADER)), dwSize); *phMetaFile = ::SetMetaFileBitsEx(dwSize, (LPBYTE)pMetaFileData); GlobalUnlock(hMetaFileData); pMetaFileData = NULL; #else hmemcpy(pMetaFileData, (LPVOID)(pResource+sizeof(ALDUS_WMF_HEADER)), dwSize); *phMetaFile = ::SetMetaFileBits(hMetaFileData); if (*phMetaFile == NULL) { GlobalUnlock(hMetaFileData); pMetaFileData = NULL; } #endif fSuccess = *phMetaFile != NULL; } #ifdef WIN32 GlobalFree(hMetaFileData); hMetaFileData = NULL; #else if (*phMetaFile == NULL) { GlobalFree(hMetaFileData); hMetaFileData = NULL; } #endif } } } } } } GlobalUnlock(hResource); pResource = NULL; } FreeResource(hResource); hResource = NULL; } } return fSuccess; }
int KGTestMapDisuseResource::FindResInSFX(const char cszResourceName[], set<string>& setResList) { //参照KG3DSFX::_LoadFromFile int nResult = false; HRESULT hRetCode = E_FAIL; DWORD dwSize = 0; SFX_FILE_HEADER* pHeader = NULL; DWORD fileLen = 0; BYTE* pBuffer = NULL; DWORD dwCurPos = 0; DWORD i = 0; IFile* pFile = NULL; KG_ASSERT_EXIT(cszResourceName); KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0'); pFile = g_OpenFile(cszResourceName); KG_PROCESS_ERROR(pFile); fileLen = pFile->Size(); ASSERT(fileLen > 0); KG_PROCESS_ERROR(fileLen); pBuffer = new BYTE[fileLen]; KG_PROCESS_ERROR(pBuffer); dwSize = pFile->Read(pBuffer, fileLen); KG_PROCESS_ERROR(dwSize == fileLen); pHeader = reinterpret_cast<SFX_FILE_HEADER*>(pBuffer); KG_PROCESS_ERROR(pHeader->dwID == SFX_ID); KG_PROCESS_ERROR(pHeader->dwFileLength == fileLen); KG_PROCESS_ERROR(LOWORD(pHeader->dwVersion) >= 2); dwCurPos += sizeof(SFX_FILE_HEADER); for (i = 0; i < pHeader->dwElementNum; ++i, dwCurPos += sizeof(SFX_ELEMENT)) { SFX_ELEMENT *pElem = reinterpret_cast<SFX_ELEMENT*>(&pBuffer[dwCurPos]); ASSERT(dwCurPos < fileLen); KG_PROCESS_ERROR( (pElem->dwElementID >= SFX_FEID_GENERAL_INFORMATION) && (pElem->dwElementID < SFX_FEID_SIZE) ); ASSERT(pElem->dwElementOffset <= fileLen); /* pElem->dwElementID对应于 KG3DSFX::ProcessBlockFunction KG3DSFX::ms_pfnProcessBlock[SFX_FEID_SIZE] 中的ReadModelBlock函数指针的索引7,此函数读取mesh,mtl,ani的信息 */ if (pElem->dwElementID == 7) { //参照KG3DSFX::ReadModelBlock SFX_MODEL_BLOCK* pBlock = (SFX_MODEL_BLOCK*)&pBuffer[pElem->dwElementOffset]; FindResource((const char*)pBlock->byMeshFileName, setResList); FindResource((const char*)pBlock->byMaterialFileName, setResList); FindResource((const char*)pBlock->byAnimationFileName, setResList); } } nResult = true; Exit0: return nResult; }
// Installation of WinPcap void EmInstallWinPcap(HWND hWnd, RPC *r) { wchar_t temp_name[MAX_SIZE]; HGLOBAL g; HINSTANCE h; HRSRC hr; UINT size; void *data; IO *io; // Ask whether the user want to start the installation if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_INSTALL")) == IDNO) { return; } // Generate a temporary file name UniFormat(temp_name, sizeof(temp_name), L"%s\\winpcap_installer.exe", MsGetTempDirW()); // Read from the resource h = GetUiDll(); hr = FindResource(h, MAKEINTRESOURCE(BIN_WINPCAP), "BIN"); if (hr == NULL) { RES_ERROR: MsgBox(hWnd, MB_ICONSTOP, _UU("EM_RESOURCE")); return; } g = LoadResource(h, hr); if (g == NULL) { goto RES_ERROR; } size = SizeofResource(h, hr); data = LockResource(g); if (data == NULL) { goto RES_ERROR; } // Write to a temporary file io = FileCreateW(temp_name); if (io == NULL) { goto RES_ERROR; } FileWrite(io, data, size); FileClose(io); // Run if (RunW(temp_name, NULL, false, true) == false) { // Failure FileDeleteW(temp_name); goto RES_ERROR; } FileDeleteW(temp_name); if (r == NULL) { return; } // Message after the end if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) == false) { // Need to restart the computer MsgBox(hWnd, MB_ICONINFORMATION, _UU("EM_WPCAP_REBOOT1")); } else { // Need to restart the service if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_REBOOT2")) == IDNO) { // Not restart } else { // Restart RPC_TEST t; RPC_BRIDGE_SUPPORT t2; Zero(&t, sizeof(t)); EcRebootServer(r, &t); SleepThread(500); Zero(&t2, sizeof(t2)); CALL(hWnd, EcGetBridgeSupport(r, &t2)); } } }
int KGTestMapDisuseResource::FindResInPVS(const char cszResourceName[], set<string>& setResList) { //参照KG3DRepresentObjectPVS::LoadPvsFile int nRetCode = false; int nResult = false; HRESULT hrRetCode = E_FAIL; IFile* pFile = NULL; DWORD dwVersion = PVS_FILE_VERSION; char szSourcePathName[MAX_PATH] = {0}; char szResName[MAX_PATH] = {0}; long lOffset = 0; size_t objNum = 0; KG_ASSERT_EXIT(cszResourceName); KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0'); nRetCode = _snprintf_s(szSourcePathName, sizeof(szSourcePathName), sizeof(szSourcePathName) - 1, "%s%s", m_szClientPath, cszResourceName); KGLOG_PROCESS_ERROR(nRetCode > 0); pFile = g_OpenFile(cszResourceName, false, false); KGLOG_PROCESS_ERROR(pFile); /* read version */ pFile->Read(&dwVersion, sizeof(dwVersion)); /* load border, the frist model of the pvs object is it's ouside border and the second model is it's inside border */ pFile->Read(szResName, sizeof(szResName)); FindResource(szResName, setResList); pFile->Read(szResName, sizeof(szResName)); FindResource(szResName, setResList); /* load inside objects, the object may be is pvs object too */ pFile->Read(&objNum, sizeof(objNum)); for (size_t i = 0; i < objNum; i++) { DWORD dwObjType = 0; pFile->Read(&dwObjType, sizeof(dwObjType)); switch (dwObjType) { case REPRESENTOBJECT_PVS : case REPRESENTOBJECT_SET : { pFile->Read(szResName, sizeof(szResName)); FindResource(szResName, setResList); } break; case REPRESENTOBJECT_DEFAULT : { /* is normal object */ DWORD dwCount = 0; DWORD dwColor = 0; DWORD dwType = 0; char szAnins[MAX_PATH] = {0}; pFile->Read(&dwCount, sizeof(dwCount)); for (DWORD i = 0; i < dwCount; i++) { pFile->Read(szResName, sizeof(szResName)); FindResource(szResName, setResList); if (dwVersion > PVS_FILE_VERSION_1) { pFile->Read(szAnins, sizeof(szAnins)); FindResource(szAnins, setResList); } TypeInfo* pInfo = NULL; IEKG3DEngineManager* pIEEngineMgr = NULL; IEKG3DModelTable* pIEModelTable = NULL; KG3DModelTable* pModelTable = NULL; pIEEngineMgr = (IEKG3DEngineManager*)m_pEngineMgr; hrRetCode = pIEEngineMgr->GetIEKG3DModelTable(&pIEModelTable); KGLOG_COM_PROCESS_ERROR(hrRetCode); pModelTable= (KG3DModelTable*)pIEModelTable; hrRetCode = pModelTable->GetTypeInfoByFileName(&pInfo, szResName); if (pInfo) dwType = pInfo->dwType; else dwType = MESHTYPE_DEFAULT; switch (dwType) { case MESHTYPE_POINTLIGHT : { pFile->Read(&dwColor, sizeof(dwColor)); } break; default : break; } } } break; default : _ASSERTE(false); break; } lOffset = sizeof(D3DXVECTOR3) + //ScalingCenter sizeof(D3DXQUATERNION) + //ScalingRotation sizeof(D3DXVECTOR3) + //Scaling sizeof(D3DXVECTOR3) + //RotationCenter sizeof(D3DXQUATERNION) + //Rotation sizeof(D3DXVECTOR3) + //Translation sizeof(AABBOX); //aabox pFile->Seek(lOffset, SEEK_CUR); lOffset = 0; } pFile->Close(); SAFE_RELEASE(pFile); nResult = true; Exit0: if (pFile) { pFile->Close(); SAFE_RELEASE(pFile); } return nResult; }
// ---------------------------------------------------------------------------------------- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HRSRC hResource; HGLOBAL resPoints; DWORD resSize; LPVOID rgnPoints; HRGN hWindowRegion; static CFont fntTitle; static CFont fntDescr; static HWND hCloseButton = NULL; HDC hdc; PAINTSTRUCT pt; switch (message) { case WM_CREATE: hResource = FindResource(d_about.hInstance,d_about.d_lprgnname,ABOUT_STC_RGN_RESOURCE_TYPE); if (NULL==hResource) AfxMessageBox(_T("Can't find resource!"),MB_OK|MB_ICONSTOP); resPoints = LoadResource(d_about.hInstance,hResource); if (NULL==resPoints) AfxMessageBox(_T("Can't load resource!"),MB_OK|MB_ICONSTOP); resSize = SizeofResource(d_about.hInstance,hResource); if (0==resSize) AfxMessageBox(_T("Size of resource = 0 !"),MB_OK|MB_ICONSTOP); rgnPoints = LockResource(resPoints); hWindowRegion = ExtCreateRegion(NULL,resSize,(RGNDATA*)rgnPoints); SetWindowRgn(hWnd,hWindowRegion,TRUE); hCloseButton = CreateWindowEx(NULL,_T("button"),_T("close"), WS_CHILD | (d_about.showCloseButton ? WS_VISIBLE : 0), 280,186,45,16,hWnd,(HMENU)IDC_BUTTON_CLOSE, d_about.hInstance,NULL); if (d_about.modal) ::SetFocus(hCloseButton); fntDescr.CreateFont( 12, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_NORMAL, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); fntTitle.CreateFont( 14, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_NORMAL, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); SendMessage(hCloseButton,WM_SETFONT,(LPARAM)fntDescr.m_hObject,TRUE); if (d_about.autoClose > 0) SetTimer(hWnd, AUTOCLOSE_TIMER_ID, d_about.autoClose, NULL); break; case WM_LBUTTONDOWN: SendMessage(hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam); break; case WM_COMMAND: if (LOWORD(wParam)==IDC_BUTTON_CLOSE) DestroyWindow(hWnd); break; case WM_DESTROY: fntTitle.DeleteObject(); fntDescr.DeleteObject(); //we again ready for create a new instance! is_instance = false; break; case WM_KILLFOCUS: if (d_about.modal) if ((HWND)wParam!=hCloseButton) SetFocus(hWnd); break; case WM_PAINT: hdc = BeginPaint(hWnd,&pt); SetBkColor(hdc,RGB(0,0,0)); //draw title SetTextColor(hdc,RGB(40,250,50)); SelectObject(hdc,fntTitle.m_hObject); TextOut(hdc,195,16,d_about.about_product,_tcslen(d_about.about_product)); //draw description SelectObject(hdc,fntDescr.m_hObject); SetTextColor(hdc,RGB(250,240,250)); SetBkMode(hdc, TRANSPARENT); DrawText(hdc,d_about.about_description,-1,CRect(203,45,433,170),DT_EDITCONTROL |DT_WORD_ELLIPSIS); EndPaint(hWnd,&pt); break; case WM_TIMER: ASSERT(KillTimer(hWnd, AUTOCLOSE_TIMER_ID)); DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void Demo_AreaFill(HDC hDC, const RECT * rcPaint, int width, int height) { const COLORREF c0 = RGB(0x20, 0x20, 0x20); const COLORREF c1 = RGB(0xF0, 0xF0, 0x20); for (int i=0; i<4; i++) GradientRectangle(hDC, 1000+1100*i, 500, 2000+1100*i, 1500, c0, c1, i*450); for (i=0; i<4; i++) SymGradientRectangle(hDC, 1000+1100*i, 1600, 2000+1100*i, 2600, c0, c1, i*450); for (i=0; i<4; i++) CornerGradientRectangle(hDC, 1000+1100*i, 2700, 2000+1100*i, 3700, c0, c1, i); CenterGradientRectangle(hDC, 5600, 1500, 6600, 2500, c0, c1); CenterGradientRectangle(hDC, 5600, 2600, 6600, 3600, c1, c0); // Buttons RoundRectButton(hDC, 0, 4000, 800, 4800, 0, 100, RGB(0x20, 0x20, 0x20), RGB(0xF0, 0xF0, 0x20)); RoundRectButton(hDC, 1000, 4000, 1800, 4800, 400, 100, RGB(0xF0, 0x20, 0x20), RGB(0x20, 0xF0, 0x20)); RoundRectButton(hDC, 2000, 4000, 2800, 4800, 800, 100, RGB(0xFF, 0xFF, 0x20), RGB(0x20, 0x20, 0xF0)); GradientRectangle(hDC, 0, 5000, 2000, 6000, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 0); HLSGradientRectangle(hDC, 0, 6200, 2000, 7200, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 200); RadialGradientFill(hDC, 3200, 6300, 3200 , 6300 , 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 8); RadialGradientFill(hDC, 5300, 6300, 5300-300, 6300-600, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 16); RadialGradientFill(hDC, 7400, 6300, 7400-300, 6300+300, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 256); { RECT r = { 7000, 500, 8500, 500+1500 }; KGDIObject blue(hDC, CreatePen(PS_SOLID, 1 * ONEINCH/72, RGB(0, 0, 0xFF))); KGDIObject yellow(hDC, CreateSolidBrush(RGB(0xFF, 0xFF, 0))); Rectangle(hDC, 7000, 500, 8500, 500+1500); BrickPatternFill(hDC, 7000, 500, 8500, 500+1500, 150, 150); BrickPatternFill(hDC, 7000, 2100, 8500, 2100+1500, 100, 100); } KLogFont logfont(- 8 * ONEINCH / 72, "Tahoma"); KGDIObject font(hDC, logfont.CreateFont()); { SelectObject(hDC, GetStockObject(NULL_PEN)); typedef enum { GAP = 1200 }; for (int hs= HS_HORIZONTAL; hs<=HS_DIAGCROSS; hs++) { HBRUSH hBrush = CreateHatchBrush(hs, RGB(0, 0, 0xFF)); HGDIOBJ hOld = SelectObject(hDC, hBrush); SetBkColor(hDC, RGB(0xFF, 0xFF, 0)); Rectangle(hDC, hs*GAP, 8000, hs*GAP+890, 8890); SetBkColor(hDC, RGB(0xFF, 0xFF, 0xFF)); SetTextAlign(hDC, TA_CENTER); TextOut(hDC, hs*GAP+880/2, 8980, HS_Names[hs-HS_HORIZONTAL], _tcslen(HS_Names[hs-HS_HORIZONTAL])); SelectObject(hDC, hOld); DeleteObject(hBrush); } } { HINSTANCE hCards = LoadLibrary("cards.dll"); for (int i=0; i<3; i++) { HBRUSH hBrush; int width, height; switch ( i ) { case 0: { HBITMAP hBitmap = LoadBitmap(hCards, MAKEINTRESOURCE(52)); BITMAP bmp; GetObject(hBitmap, sizeof(bmp), & bmp); width = bmp.bmWidth; height = bmp.bmHeight; hBrush = CreatePatternBrush(hBitmap); DeleteObject(hBitmap); } break; case 1: { HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-14), RT_BITMAP); HGLOBAL hGlobal = LoadResource(hCards, hResource); hBrush = CreateDIBPatternBrushPt(LockResource(hGlobal), DIB_RGB_COLORS); width = ((BITMAPCOREHEADER *) hGlobal)->bcWidth; // old DIB format height = ((BITMAPCOREHEADER *) hGlobal)->bcHeight;// old DIB format } break; case 2: { HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-28), RT_BITMAP); HGLOBAL hGlobal = LoadResource(hCards, hResource); hBrush = CreateDIBPatternBrush(hGlobal, DIB_RGB_COLORS); width = ((BITMAPCOREHEADER *) hGlobal)->bcWidth; // old DIB format height = ((BITMAPCOREHEADER *) hGlobal)->bcHeight; // old DIB format } } HGDIOBJ hOld = SelectObject(hDC, hBrush); POINT P = { i*1400+200 + width*10*i/4, 10000 + height*10*i/4 }; LPtoDP(hDC, &P, 1); SetBrushOrgEx(hDC, P.x, P.y, NULL); // make sure cards aligned with rectangle Rectangle(hDC, i*1400+200, 10000, i*1400+200+width*30/2+1, 10000+height*30/2+1); SelectObject(hDC, hOld); DeleteObject(hBrush); } } }
CAR_API HANDLE carCreate(TVAInitParams* params, double scale, int NumObjects) { // todo: set params TheCar* car = new TheCar(); car->size = sizeof(TheCar); car->f = new TLFCarEngine(); car->max_objects = NumObjects; if (car->f == NULL) { delete car; return NULL; } car->f->SetResize(true); car->f->SetBaseImageWidth(320); try { HMODULE hModule = GetModuleHandle(L"car.dll"); if (hModule == NULL) throw 0; HRSRC hRC = NULL; hRC = FindResource(hModule, L"#108", L"AWPIMAGE"); if (hRC == NULL) throw 0; int DumpSize = 0; DumpSize = SizeofResource(hModule, hRC); if (DumpSize == 0) throw 0; HGLOBAL hgTempl = NULL; hgTempl = LoadResource(hModule, hRC); if (hgTempl == NULL) throw 0; char* pDump = NULL; pDump = (char*)LockResource(hgTempl); if (pDump == NULL) throw 0; stringstream s; string str; str = pDump; s << str; if (!car->f->LoadStream(s)) throw 0; } catch (...) { delete car->f; delete car; return NULL; } ILFScanner* scr = car->f->GetScanner(); for (int i = 0; i < scr->GetParamsCount(); i++) { TLFParameter* p = scr->GetParameter(i); if (strcmp(p->GetPName(), "MinSize") == 0) { if (scale < 1) scale = 1; p->SetValue(scale); } } car->f->SetNeedCluster(true); car->f->SetSaveToDb(false); std::string path = "c:\\_alt\\data\\car_out\\"; //face->f->SetOutDatabase(path); car->f->SetOutDatabase(path); //std::string path = params->Path; //face->f->SetOutDatabase(path); // all ok return (HANDLE)car; }
int WINAPI WinMain(HINSTANCE inst, HINSTANCE inst2, LPSTR arg, int style) { HRSRC nameres, shyres, setupres, dnlsiteres, dnlpathres; DWORD len = 0, rlen = 0, tid = 0; LPVOID data = NULL; TCHAR buf[BUFSIZE], path[BUFSIZE], cmd[BUFSIZE]; HKEY hkey; BOOL shoes; DWORD plen; HANDLE payload, th; MSG msg; char *key = "SOFTWARE\\Hackety.org\\Shoes"; //char *key = "Software\\Hackety.org\\Shoes"; // Allow old String lookups first, then id# nameres = FindResource(inst, "SHOES_FILENAME", RT_STRING); if (nameres == NULL) { nameres = FindResource(inst, MAKEINTRESOURCE(SHOES_APP_NAME), RT_STRING); } shyres = FindResource(inst, "SHOES_PAYLOAD", RT_RCDATA); if (shyres == NULL) { shyres = FindResource(inst, MAKEINTRESOURCE(SHOES_APP_CONTENT), RT_RCDATA); } if (nameres == NULL || shyres == NULL) { // Test - find a numbered resource if (nameres == NULL) { MessageBox(NULL, "No Filename", "Magic Happens!!", MB_OK); return 0; } else { // MessageBox(NULL, "This is an empty Shoes stub.", "shoes!! feel yeah!!", MB_OK); MessageBox(NULL, "Missing contents", "shoes!! feel yeah!!", MB_OK); return 0; } } setupres = FindResource(inst, "SHOES_SETUP", RT_RCDATA); //msvc way if (setupres == NULL) { setupres = FindResource(inst, MAKEINTRESOURCE(SHOES_SYS_SETUP), RT_RCDATA); } plen = sizeof(path); if (!(shoes = reg_s((hkey=HKEY_LOCAL_MACHINE), key, "", (LPBYTE)&path, &plen))) shoes = reg_s((hkey=HKEY_CURRENT_USER), key, "", (LPBYTE)&path, &plen); if (shoes) { //sprintf(cmd, "%s\\shoes.exe", path); //printf("bfr: %s\n", cmd); //if (!file_exists(cmd)) shoes = FALSE; //memset(cmd, 0, BUFSIZE); if (!file_exists(path)) shoes = FALSE; memset(cmd, 0, BUFSIZE); } if (!shoes) { /* * Need to download Shoes installer. Get the site and path * from the resources and stuff in globals vars - wide strings */ LPVOID tmpptr; int tlen; dnlsiteres = FindResource(inst, MAKEINTRESOURCE(SHOES_DOWNLOAD_SITE), RT_STRING); tmpptr = LoadResource(inst, dnlsiteres); tlen = SizeofResource(inst, dnlsiteres); wcscpy(download_site, tmpptr+2); // cjc: I hate that +2 offset hack dnlpathres = FindResource(inst, MAKEINTRESOURCE(SHOES_DOWNLOAD_PATH), RT_STRING); tmpptr = LoadResource(inst, dnlpathres); tlen = SizeofResource(inst, dnlpathres); wcscpy(download_path, tmpptr+2); // more hack LPTHREAD_START_ROUTINE back_action = (LPTHREAD_START_ROUTINE)shoes_auto_setup; INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_PROGRESS_CLASS; InitCommonControlsEx(&InitCtrlEx); dlg = CreateDialog(inst, MAKEINTRESOURCE(ASKDLG), NULL, stub_win32proc); ShowWindow(dlg, SW_SHOW); if (setupres == NULL) back_action = (LPTHREAD_START_ROUTINE)shoes_http_thread; if (!(th = CreateThread(0, 0, back_action, inst, 0, &tid))) return 0; while (WaitForSingleObject(th, 10) != WAIT_OBJECT_0) { //while (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } CloseHandle(th); if (!(shoes = reg_s((hkey=HKEY_LOCAL_MACHINE), key, "", (LPBYTE)&path, &plen))) shoes = reg_s((hkey=HKEY_CURRENT_USER), key, "", (LPBYTE)&path, &plen); } if (shoes) { GetTempPath(BUFSIZE, buf); char *str = shoes_str_load(inst, SHOES_APP_NAME); strcat(buf, (LPTSTR)str); //data = LoadResource(inst, nameres); //len = SizeofResource(inst, nameres); //strncat(buf, (LPTSTR)data+2, len); // cjc hack payload = CreateFile(buf, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); len = SizeofResource(inst, shyres); if (GetFileSize(payload, NULL) != len) { HGLOBAL resdata = LoadResource(inst, shyres); data = LockResource(resdata); SetFilePointer(payload, 0, 0, FILE_BEGIN); SetEndOfFile(payload); WriteFile(payload, (LPBYTE)data, len, &rlen, NULL); } CloseHandle(payload); #ifdef STUB_DEBUG printf("payload %s, len: %d\n", buf, (int)len); printf("cmd: %s\n", path); #endif HINSTANCE retcode; retcode = ShellExecute(NULL, "open", path, buf, NULL, SW_SHOWNORMAL); #ifdef STUB_DEBUG printf("Return: %i\n", (int)retcode); #endif } return 0; }
/**************************************************************************** * * FUNCTION: ReadIconFromEXEFile * * PURPOSE: Load an Icon Resource from a DLL/EXE file * * PARAMS: LPCTSTR szFileName - name of DLL/EXE file * * RETURNS: LPICONRESOURCE - pointer to icon resource * * History: * July '95 - Created * \****************************************************************************/ LPICONRESOURCE ReadIconFromEXEFile( LPCTSTR szFileName ) { LPICONRESOURCE lpIR = NULL, lpNew = NULL; HINSTANCE hLibrary; LPTSTR lpID; EXEDLLICONINFO EDII; // Load the DLL/EXE - NOTE: must be a 32bit EXE/DLL for this to work if( (hLibrary = LoadLibraryEx( szFileName, NULL, LOAD_LIBRARY_AS_DATAFILE )) == NULL ) { // Failed to load - abort MessageBox( hWndMain, "Error Loading File - Choose a 32bit DLL or EXE", szFileName, MB_OK ); return NULL; } // Store the info EDII.szFileName = szFileName; EDII.hInstance = hLibrary; // Ask the user, "Which Icon?" if( (lpID = ChooseIconFromEXEFile( &EDII )) != NULL ) { HRSRC hRsrc = NULL; HGLOBAL hGlobal = NULL; LPMEMICONDIR lpIcon = NULL; UINT i; // Find the group icon resource if( (hRsrc = FindResource( hLibrary, lpID, RT_GROUP_ICON )) == NULL ) { FreeLibrary( hLibrary ); return NULL; } if( (hGlobal = LoadResource( hLibrary, hRsrc )) == NULL ) { FreeLibrary( hLibrary ); return NULL; } if( (lpIcon = LockResource(hGlobal)) == NULL ) { FreeLibrary( hLibrary ); return NULL; } // Allocate enough memory for the images if( (lpIR = malloc( sizeof(ICONRESOURCE) + ((lpIcon->idCount-1) * sizeof(ICONIMAGE)) )) == NULL ) { MessageBox( hWndMain, "Error Allocating Memory", szFileName, MB_OK ); FreeLibrary( hLibrary ); return NULL; } // Fill in local struct members lpIR->nNumImages = lpIcon->idCount; lstrcpy( lpIR->szOriginalDLLFileName, szFileName ); lstrcpy( lpIR->szOriginalICOFileName, "" ); // Loop through the images for( i = 0; i < lpIR->nNumImages; i++ ) { // Get the individual image if( (hRsrc = FindResource( hLibrary, MAKEINTRESOURCE(lpIcon->idEntries[i].nID), RT_ICON )) == NULL ) { free( lpIR ); FreeLibrary( hLibrary ); return NULL; } if( (hGlobal = LoadResource( hLibrary, hRsrc )) == NULL ) { free( lpIR ); FreeLibrary( hLibrary ); return NULL; } // Store a copy of the resource locally lpIR->IconImages[i].dwNumBytes = SizeofResource( hLibrary, hRsrc ); lpIR->IconImages[i].lpBits = malloc( lpIR->IconImages[i].dwNumBytes ); memcpy( lpIR->IconImages[i].lpBits, LockResource( hGlobal ), lpIR->IconImages[i].dwNumBytes ); // Adjust internal pointers if( ! AdjustIconImagePointers( &(lpIR->IconImages[i]) ) ) { MessageBox( hWndMain, "Error Converting to Internal Format", szFileName, MB_OK ); free( lpIR ); FreeLibrary( hLibrary ); return NULL; } } } FreeLibrary( hLibrary ); return lpIR; }
BOOL CShortcut::GetDefaultShortcuts(CArrayFP<CShortcut*>& aShortcuts,BYTE bLoadFlag) { // This code saves currently saved shortcuts to correct file // Uncommend and run once /* // BEGIN { LPCSTR szFile="C:\\Users\\jmhuttun\\Programming\\projects\\Locate\\Locate32\\commonres\\defaultshortcuts.dat"; CRegKey2 RegKey; if (RegKey.OpenKey(HKCU,"\\General",CRegKey::defRead)!=ERROR_SUCCESS) return FALSE; DWORD dwDataLength=RegKey.QueryValueLength("Shortcuts"); if (dwDataLength<4) return FALSE; BYTE* pData=new BYTE[dwDataLength]; RegKey.QueryValue("Shortcuts",(LPSTR)pData,dwDataLength,NULL); RegKey.CloseKey(); CFile File(TRUE); File.CloseOnDelete(); try { File.Open(szFile,CFile::defWrite); File.Write(pData,dwDataLength); File.Close(); } catch (...) { } } // END */ // Check file CStringW Path(GetLocateApp()->GetExeNameW()); Path.FreeExtra(Path.FindLast(L'\\')+1); Path << L"defshrtc.dat"; BYTE* pData=NULL; DWORD dwLength; try { CFile File(Path,CFile::defRead|CFile::otherErrorWhenEOF,TRUE); File.CloseOnDelete(); dwLength=File.GetLength(); pData=new BYTE[dwLength]; File.Read(pData,dwLength); File.Close(); BOOL bRet=LoadShortcuts(pData,dwLength,aShortcuts,bLoadFlag); delete[] pData; if (bRet) return TRUE; } catch (...) { if (pData!=NULL) delete[] pData; } HRSRC hRsrc=FindResource(GetInstanceHandle(),MAKEINTRESOURCE(IDR_DEFAULTSHORTCUTS),"DATA"); if (hRsrc==NULL) return FALSE; dwLength=SizeofResource(GetInstanceHandle(),hRsrc); if (dwLength<4) return FALSE; HGLOBAL hGlobal=LoadResource(GetInstanceHandle(),hRsrc); if (hGlobal==NULL) return FALSE; return LoadShortcuts((const BYTE*)LockResource(hGlobal),dwLength,aShortcuts,bLoadFlag); }
BOOL RelayoutDialog(HINSTANCE hInst, HWND hDlg, LPCWSTR iddTemplate) { HRSRC hRsrc = FindResource((HMODULE)hInst, iddTemplate, RT_DIALOG); if (hRsrc == NULL) { return FALSE; } HGLOBAL hGlobal = LoadResource((HMODULE)hInst, hRsrc); if (hGlobal == NULL) { return FALSE; } INT nStatics = 0; LPBYTE lpData = (LPBYTE)LockResource(hGlobal); LPDLGTEMPLATE lpTemplate = (LPDLGTEMPLATE)lpData; HDWP hDWP = BeginDeferWindowPos(lpTemplate->cdit); // // For more information about the data structures that we are walking, // consult the DLGTEMPLATE and DLGITEMTEMPLATE documentation on MSDN. // lpData += sizeof(DLGTEMPLATE); lpData = WalkDialogData(lpData); // menu lpData = WalkDialogData(lpData); // class lpData = WalkDialogData(lpData); // title if (lpTemplate->style & DS_SETFONT) { lpData += sizeof(WORD); // font size. lpData = WalkDialogData(lpData); // font face. } for (int i = 0; i < lpTemplate->cdit; i++) { lpData = (LPBYTE) (((INT)lpData + 3) & ~3); // force to DWORD boundary. LPDLGITEMTEMPLATE lpDlgItem = (LPDLGITEMTEMPLATE)lpData; HWND hwndCtl = GetDlgItem(hDlg, lpDlgItem->id); if (lpDlgItem->id == 0xFFFF) { nStatics++; } // // Move the item around. // { RECT r; r.left = lpDlgItem->x; r.top = lpDlgItem->y; r.right = lpDlgItem->x + lpDlgItem->cx; r.bottom = lpDlgItem->y + lpDlgItem->cy; MapDialogRect(hDlg, &r); DeferWindowPos(hDWP, hwndCtl, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER); } lpData += sizeof(DLGITEMTEMPLATE); LPWORD lpClass = (LPWORD)lpData; lpData = WalkDialogData(lpData); // class // // Do some special handling for each dialog item (changing text, // bitmaps, ensuring visible, etc. // FixupDialogItem(hInst, hDlg, lpDlgItem, lpClass, (LPWORD)lpData); lpData = WalkDialogData(lpData); // title WORD cbExtra = *((LPWORD)lpData); // extra class data. lpData += (cbExtra ? cbExtra : sizeof(WORD)); } EndDeferWindowPos(hDWP); return nStatics < 2 ? TRUE : FALSE; }