Не получается найти ресурс
От: Buggy  
Дата: 21.10.02 17:12
Оценка:
Прива.
Вот уменя такая проблема. Он мне тут пишет что не может найти ресурс
Вот сделал кака посоветовали написать с UpdateResource. НО ладно я написал два приложения на MFC они обсолютно индентичны кроме того что у каждого из окошко разное рисуночек IDR_MAINFRAME.
Делаю а он пишет с того места когбудто он не может найти в паке Icon не может найти IDR_MAINFRAME.
Что такое не пойму а вот код



#include <iostream.h> 
#include <windows.h> 
#include <stdio.h> 
#include <winbase.h> 
int main() 
{ 
HGLOBAL hResLoad; // handle to loaded resource 
HMODULE hExe; // handle to existing .EXE file 
HRSRC hRes; // handle/ptr. to res. info. in hExe 
HANDLE hUpdateRes; // update resource handle 
LPVOID lpResLock; // pointer to resource data 
BOOL result; 
// Load the .EXE file that contains the dialog box you want to copy. 
hExe = LoadLibrary("c:\\hand.exe"); 
if (hExe == NULL) 
{ 
cout<<"Could not load exe.\n"; 
return 0;
} 

// Locate the dialog box resource in the .EXE file. 
hRes = FindResource(hExe, "IDR_MAINFRAME", RT_ICON); 
if (hRes == NULL) 
{ 
cout<<"Could not locate dialog box.\n" ; 
return 0;
} 

// Load the dialog box into global memory. 
hResLoad = LoadResource(hExe, hRes); 
if (hResLoad == NULL) 
{ 
cout<<"Could not load dialog box.\n"; 
return 0;
} 

// Lock the dialog box into global memory. 
lpResLock = LockResource(hResLoad); 
if (lpResLock == NULL) 
{ 
cout<<"Could not lock dialog box.\n"; 
return 0;
} 

// Open the file to which you want to add the dialog box resource. 
hUpdateRes = BeginUpdateResource("c:\\foot.exe", FALSE); 
if (hUpdateRes == NULL) 
{ 
cout<<"Could not open file for writing.\n"; 
return 0;
} 

// Add the dialog box resource to the update list. 
result = UpdateResource(hUpdateRes, // update resource handle 
RT_ICON, // change dialog box resource 
"IDR_MAINFRAME", // dialog box name 
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language 
lpResLock, // ptr to resource info 
SizeofResource(hExe, hRes)); // size of resource info. 
if (result == FALSE) 
{ 
cout<<"Could not add resource.\n"; 
return 0; 
} 

// Write changes to FOOT.EXE and then close it. 
if (!EndUpdateResource(hUpdateRes, FALSE)) 
{ 
cout<<"Could not write changes to file.\n"; 
return 0;
} 

// Clean up. 
if (!FreeLibrary(hExe)) 
{ 
cout<<"Could not free executable.\n"; 
return 0;
} 
return(TRUE); 
}

Заранее спасибо...
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.