vs2010 MFC 释放资源

vs2010 MFC 释放资源


BOOL  ReleaseRes(CString strFileName, WORD wResID, CString strFileType)
{
	 DWORD   dwWrite=0;        
  
    // 创建文件   
    HANDLE  hFile = CreateFile(strFileName, GENERIC_WRITE,FILE_SHARE_WRITE,NULL,  
                                CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);  
    if ( hFile == INVALID_HANDLE_VALUE )  
    {  
        return FALSE;  
    }  
  
    // 查找资源文件中、加载资源到内存、得到资源大小   
    HRSRC   hrsc =  FindResource(NULL, MAKEINTRESOURCE(wResID), strFileType);  
    HGLOBAL hG = LoadResource(NULL, hrsc);  
    DWORD   dwSize = SizeofResource( NULL,  hrsc);  
	if (!(hrsc&&hG&&dwSize))
	{
		return FALSE;
	}
    // 写入文件   
    WriteFile(hFile,hG,dwSize,&dwWrite,NULL);     
    CloseHandle( hFile );  
    return TRUE;  
}



ReleaseRes("test.dll",(WORD)IDR_BIN4,"BIN");  


你可能感兴趣的:(c++)