設置 | 登錄 | 註冊

作者共發了1篇帖子。

【方法】在指定文件夹中搜索文件

1樓 巨大八爪鱼 2016-3-25 21:40
【程序】
#include "stdafx.h"
#include <Windows.h>

#define echo(str) WriteConsole(hConsoleOutput, str, _tcslen(str), NULL, NULL)
#define echo_t(str) echo(TEXT(str))

int _tmain(int argc, _TCHAR* argv[])
{
    LPTSTR szFileName = TEXT("D:\\Codes\\PHP\\Arslanbar\\2\\classes\\*t.*");
    WIN32_FIND_DATA ffd;
    HANDLE hFindFile = FindFirstFile(szFileName, &ffd);
    HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hFindFile == INVALID_HANDLE_VALUE)
    {
        echo_t("No file");
    }
    else
    {
        do
        {
            echo(ffd.cFileName);
            echo_t("\r\n");
        } while (FindNextFile(hFindFile, &ffd));
        FindClose(hFindFile);
    }
    return 0;
}

【输出】
DataObject.php
DataObject.php.LCK
Request.php
ZhSupport.php
Press any key to continue . . .

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。