帮人帮到底,GetFileAttributes函数怎么用啊 参数什么的都怎么传啊 最好能整段代码 不胜感激
解决方案 »
- TCP 丢包问题
- 修改OCX的敏感问题
- 如何根据一个路径把一幅图片显示在一个CStatic上?(请回复至[email protected])
- VC++程序问题....赤
- 如何实现像xp的“任务管理器”下的“联网”的那个监视网络的功能?
- 关于如何重画CScrollView的滚动条的问题?
- 如何在菜单中画上相应的字体????(急)
- 急急,大问题小分数,之六!!!!!!!!!!
- 请问谁有操作WAB文件的资料,可以给我一份吗?
- 如何delete 在程序运行中new 出来的对话框?急!!!
- 图形透明问题
- Directshow中,VMR9播放wmv文件为什么只有声音,没有图像?请从这里下载源码,高手指教。在线给高分
LPCTSTR lpFileName // name of file or directory
);WIN32_FIND_DATA FileData;
HANDLE hSearch;
DWORD dwAttrs;
char szDirPath[] = "c:\\TEXTRO\\";
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
BOOL fFinished = FALSE;
// Create a new directory.
if (!CreateDirectory(szDirPath, NULL))
{
ErrorHandler("Couldn't create new directory.");
}
// Start searching for .TXT files in the current directory.
hSearch = FindFirstFile("*.txt", &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
ErrorHandler("No .TXT files found.");
}
// 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 & FILE_ATTRIBUTE_READONLY))
{
SetFileAttributes(szNewPath,
dwAttrs | FILE_ATTRIBUTE_READONLY);
}
}
else
{
ErrorHandler("Couldn't copy file.");
}
if (!FindNextFile(hSearch, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
MessageBox(hwnd, "No more .TXT files.",
"Search completed.", MB_OK);
fFinished = TRUE;
}
else
{
ErrorHandler("Couldn't find next file.");
}
}
}
// Close the search handle.
if (!FindClose(hSearch))
{
ErrorHandler("Couldn't close search handle.");
}