开发者

Problem with FtpFindFirstFile

I want to download all file from ftp directory i want use for that FtpFindFirstFile and FtpGetFile;

LPWIN32_FIND_DATA FileData; 
TCHAR* APP_NAME = TEXT("ftpcli");
TCHAR* PATH_FTP = TEXT("ftp://127.0.01");
TCHAR* ADR_FTP = TEXT("127.0.0.1");
TCHAR* LC_FILE = TEXT("C:\\!");
TCHAR* PATH_FILE = TEXT("/Soft/DVD_Players/WinDVD6");
UINT a;
HINTERNET opn;
HINTERNET conn;
a = InternetAttemptConnect(0);
if (a == ERROR_SUCCESS ) {
    if(InternetCheckConnection(PATH_FTP,FLAG_ICC_FORCE_CONNECTION, NULL)) {
        opn = InternetOpen(APP_NAME, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
        conn = InternetConnect(opn, ADR_FTP, INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, NULL, NULL);          
        FtpSetCurrentDirectory(conn, PATH_FILE);
        FtpFindFirstFile(conn, NULL, &FileData, INTERN开发者_开发问答ET_FLAG_NEED_FILE, NULL);
        FtpGetFile(conn, FileData->cFileName, LC_FILE, FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, NULL);
    }
}

That code return error i know that because i do not identified memory on LPWIN32_FIND_DATA. But i do not know how do it.


You've declared a pointer to WIN32_FIND_DATA, you need a concrete instance of that structure. Fix:

WIN32_FIND_DATA FileData;   // NOTE: not LP


At a minimum:

FileData->cFileName

should be

FileData.cFileName

I misread LPWIN32_FIND_DATA as WIN32_FIND_DATA; nobugs is right that this is just a pointer (and if using the pointer my advice here is wrong, but then there's no struct allocated.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜