zoukankan      html  css  js  c++  java
  • MFC从资源加载文本

    bool CWizardSheet::GetTextResource(UINT uID, CString& csContent)  
    {  
        HMODULE hModule=GetModuleHandle(NULL);     
        HRSRC hRes = FindResource(hModule,MAKEINTRESOURCE(uID),_T("txt"));  
        if(hRes == NULL)  
        {  
            FreeResource(hRes);  
        }  
        else  
        {  
            HGLOBAL hglobal = LoadResource(hModule,hRes);  
            if(hglobal == NULL)  
            {  
                FreeResource(hglobal);  
                return false;  
            }  
            else  
            {  
                //get text  
                csContent.Format(_T("%s"),(LPVOID)hglobal);  
            }  
        }  
        return true;  
    }  
    

      

    bool CWizardSheet::GetResource(UINT uID, CString csType, CString csOutputPath)  
    {  
        CFile file;  
        HMODULE hModule=GetModuleHandle(NULL);     
        HRSRC hRes = FindResource(hModule,MAKEINTRESOURCE(uID),csType);  
        if(hRes == NULL)  
        {  
            FreeResource(hRes);  
        }  
        else  
        {  
            HGLOBAL hglobal = LoadResource(hModule,hRes);  
            if(hglobal == NULL)  
            {  
                FreeResource(hglobal);  
                return false;  
            }  
            else  
            {  
                //释放文件  
                LPBYTE lpByte=(LPBYTE)LockResource(hglobal);     
                DWORD dwRcSize=SizeofResource(hModule,hRes);  
                file.Open(csOutputPath,CFile::modeCreate | CFile::modeWrite);  
                file.Write(lpByte,dwRcSize);  
                file.Close();  
            }  
        }  
        return true;  
    }  
    

      

  • 相关阅读:
    各种排序
    最大子数组的和与积
    字符串距离
    二叉树的基本操作
    C++11创建线程的几种方式
    二分查找
    汉诺塔问题
    读写锁实现
    全排列
    数字转汉字
  • 原文地址:https://www.cnblogs.com/mypsq/p/6854596.html
Copyright © 2011-2022 走看看