zoukankan      html  css  js  c++  java
  • CFtpFileFind例子

    #include <afx.h>
    #include <afxwin.h>
    #include <afxinet.h>
    #include <stdio.h>
    
    // compile for release with
    //   cl /MT /GX
    // or for debug with
    //   cl /MTd /GX
    
    CWinApp theApp;
    
    void main()
    {
       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
       {
          // catastropic error! MFC can't initialize
          return;
       }
    
       // create a session object to initialize WININET library
       // Default parameters mean the access method in the registry
       // (that is, set by the "Internet" icon in the Control Panel)
       // will be used.
    
       CInternetSession sess(_T("MyProgram/1.0"));
    
       CFtpConnection* pConnect = NULL;
    
       try
       {
          // Request a connection to ftp.microsoft.com. Default
          // parameters mean that we'll try with username = ANONYMOUS
          // and password set to the machine name @ domain name
          pConnect = sess.GetFtpConnection(_T("ftp.microsoft.com"));
    
          // use a file find object to enumerate files
          CFtpFileFind finder(pConnect);
    
          // start looping
          BOOL bWorking = finder.FindFile(_T("*"));
    
          while (bWorking)
          {
             bWorking = finder.FindNextFile();
             printf("%s
    ", (LPCTSTR) finder.GetFileURL());
          }
       }
       catch (CInternetException* pEx)
       {
          TCHAR sz[1024];
          pEx->GetErrorMessage(sz, 1024);
          printf("ERROR!  %s
    ", sz);
          pEx->Delete();
       }
    
       // if the connection is open, close it
       if (pConnect != NULL)
          pConnect->Close();
       delete pConnect;
    
       return;
    }
  • 相关阅读:
    HDU 5883 F
    关于codeblock 为什么不能调试
    Codeforces Round #378 (Div. 2) D. Kostya the Sculptor 分组 + 贪心
    51NOD 区间的价值 V2
    NYOJ 42 一笔画问题
    如何对二维字符数组进行排序
    hihoCoder 1383 : The Book List 北京网络赛
    利用IDA学习一个简单的安卓脱壳
    iOS APP可执行文件的组成
    Mac10.11 搭建php开发环境
  • 原文地址:https://www.cnblogs.com/liaocheng/p/4243384.html
Copyright © 2011-2022 走看看