zoukankan      html  css  js  c++  java
  • 文件操作

     1 // 释放【TXT文件】到指定的文件夹
     2 BOOL ReleaseTXTRes(LPCTSTR szFullPath, UINT uResID, LPCTSTR szResType)
     3 {
     4     if (uResID<=0 || !szResType)
     5     {
     6         return FALSE;
     7     }
     8 
     9     HRSRC hRsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(uResID), szResType);
    10     if ( NULL == hRsrc )
    11     {
    12         return FALSE;
    13     }
    14 
    15     DWORD dwSize = SizeofResource(AfxGetApp()->m_hInstance, hRsrc);
    16     if ( dwSize <= 0)
    17     {
    18         return FALSE;
    19     }
    20 
    21     HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hRsrc);
    22     if ( NULL == hGlobal )
    23     {
    24         return FALSE;
    25     }
    26 
    27     LPVOID pBuffer = (LPSTR)LockResource(hGlobal);
    28     if ( NULL ==pBuffer )
    29     {
    30         return FALSE;
    31     }
    32 
    33     CFile file;
    34     file.Open(szFullPath, CFile::modeCreate | CFile::modeWrite);
    35     char *pLine = (char *)pBuffer;
    36     for (int i = 0; i < dwSize; i++)
    37     {
    38         file.Write(pLine++, 1);
    39     }
    40 
    41     file.Close();
    42     UnlockResource(hGlobal);
    43     FreeResource(hGlobal);    
    44     return TRUE;
    45 }
  • 相关阅读:
    Linux正则和grep命令
    Linux用户和权限
    XP下安装ubuntu
    Linux命令行和shell编程
    Linux软件安装及基本概念
    Linux历史,安装,分区,版本
    Eric Linux
    批量插入数据
    Django 相关
    标签,
  • 原文地址:https://www.cnblogs.com/DuanLaoYe/p/5446964.html
Copyright © 2011-2022 走看看