呵呵呵呵呵

萝莉有三好,柔体 轻音 易推倒。女神有三宝,干嘛 呵呵 去洗澡。宅男有三好:Dota 基友 破电脑。


BCB 获取并修改文件属性

Retrieving and Changing File AttributesBCB 获取并修改文件属性,示例代码如下

#include <windows.h>
#include <stdio.h>

void main()
{
   WIN32_FIND_DATA FileData;
   HANDLE hSearch;
   DWORD dwAttrs;   
   TCHAR szDirPath[] = TEXT("c:\\TextRO\\");
   TCHAR szNewPath[MAX_PATH];   
 
   BOOL fFinished = FALSE;
 
// Create a new directory.
 
   if (!CreateDirectory(szDirPath, NULL))
   {
      printf("Could not create new directory.\n");
      return;
   }
 
// Start searching for text files in the current directory.
 
   hSearch = FindFirstFile(TEXT("*.txt"), &FileData);
   if (hSearch == INVALID_HANDLE_VALUE)
   {
      printf("No text files found.\n");
      return;
   }
 
// Copy each .TXT file to the new directory
// and change it to read only, if not already.
 
   while (!fFinished)
   {
      lstrcpy(szNewPath, szDirPath);
      lstrcat(szNewPath, FileData.cFileName);
      if (CopyFile(FileData.cFileName, szNewPath, FALSE))
      {
         dwAttrs = GetFileAttributes(FileData.cFileName);
         if (dwAttrs==INVALID_FILE_ATTRIBUTES) return;

         if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))
         {
            SetFileAttributes(szNewPath,
                dwAttrs | FILE_ATTRIBUTE_READONLY);
         }
      }
      else
      {
         printf("Could not copy file.\n");
         return;
      }
 
      if (!FindNextFile(hSearch, &FileData))
      {
         if (GetLastError() == ERROR_NO_MORE_FILES)
         {
            printf("Copied all text files.\n");
            fFinished = TRUE;
         }
         else
         {
            printf("Could not find next file.\n");
            return;
         }
      }
   }
 
// Close the search handle.
 
   FindClose(hSearch);
}
 

更多内容:

Delphi2010中TResourceStream流使用
Windows Server 2008 IIS7 安装 Perl 环境
windows下用wmic查看正在运行程序的命令行参数
CGI工作原理以及获得输入的方式
Windows下CGI程序取得的所有环境变量(系统和CGI环境变量)

本文链接地址:http://www.hehehehehe.cn/i/714.html