将C++资源文件读取出来

HRSRC   hResource   =   FindResource(GetModuleHandle(NULL),     
MAKEINTRESOURCE(IDR_CALC),   TEXT("MYFILE"));  
  if(hResource)  
  {   
      HGLOBAL   hg   =   LoadResource(GetModuleHandle(NULL),   hResource);  
      if(hg)  
      {  
            LPVOID   pData   =   LockResource(hg);  
           if(pData)  
           {  
                DWORD   dwSize   =   SizeofResource(GetModuleHandle(NULL),   hResource);  
                CFile   calcFile;  
                if(calcFile.Open("c://calc.exe",   CFile::modeCreate   |   CFile::modeReadWrite))  
                {  
                    calcFile.Write(pData,   dwSize);  
                    calcFile.Close();   
                }   
            }  
       }  
  }  

posted @ 2019-05-21 18:12  狂客  阅读(2845)  评论(0编辑  收藏  举报