16,472
社区成员
发帖
与我相关
我的任务
分享
HRSRC hrFile = FindResource(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_CHM1), _T("CHM"));
if(hrFile == NULL)
{
AfxMessageBox( _T("没有找到资源"));
}
DWORD dwSize = SizeofResource(NULL,hrFile); //获取资源大小
HGLOBAL hgFile = LoadResource(AfxGetInstanceHandle(),hrFile);
if(hgFile==NULL)
{
AfxMessageBox( _T("加载资源失败 "));
}
LPVOID pvFile = LockResource(hgFile);
if(pvFile==NULL)
{
AfxMessageBox( _T("不能加载内存 "));
}
HINSTANCE hInstance = AfxGetResourceHandle();
ASSERT(hInstance != NULL);
CString strResourceURL;
BOOL bRetVal = TRUE;
LPTSTR lpszModule = new TCHAR[_MAX_PATH];
if (GetModuleFileName(hInstance, lpszModule, _MAX_PATH))
{
strResourceURL.Format(_T("res://%s/%d"), lpszModule, nRes);
AfxMessageBox(strResourceURL);
m_WebBrowser.Navigate(strResourceURL, 0, 0, 0, 0);
}
else
bRetVal = FALSE;
delete [] lpszModule;
HINSTANCE hInstance = AfxFindResourceHandle (MAKEINTRESOURCE (IDR_EXCEL1), RT_RCDATA) ;
HRSRC hRes = FindResource (hInstance, MAKEINTRESOURCE (IDR_EXCEL1), _T("excel")) ;
HGLOBAL hResData = LoadResource (hInstance, hRes) ;
void * lpvData = LockResource (hResData) ;
int cbSize = SizeofResource (hInstance, hRes) ;
char path[512] ;
::GetCurrentDirectory (512, path) ;
CString temp;
temp.Format ("%s\\运动员.dat", path) ;
CFile file(temp, CFile::modeCreate | CFile::modeWrite);
file.SetLength (cbSize) ;
file.SeekToBegin () ;
file.WriteHuge (lpvData, cbSize) ;
file.Close () ;