ファイルの属性をコピー

Win98, Win2000 or lator
(2003.09.18)
    static HRESULT CopyFileAttributes(LPCTSTR szFileName1, LPCTSTR szFileName2)
    {
        DWORD dwFileAttributes = ::GetFileAttributes(szFileName1);
        if (dwFileAttributes == -1)
        {
            DWORD dwError = ::GetLastError();
            return HRESULT_FROM_WIN32(dwError);
        }
 
        BOOL br = ::SetFileAttributes(szFileName2, dwFileAttributes);
        if (br == 0)
        {
            DWORD dwError = ::GetLastError();
            return HRESULT_FROM_WIN32(dwError);
        }
 
        return S_OK;
    }
一覧に戻る
© 2003 WAC.com All Right Reserved.