ftp自動更新相關API

來源:互聯網
上載者:User

 

1.InternetOpen Function
Initializes an application's use of the WinINet functions.
Syntax

HINTERNET InternetOpen(
  __in  LPCTSTR lpszAgent,
  __in  DWORD dwAccessType,
  __in  LPCTSTR lpszProxyName,
  __in  LPCTSTR lpszProxyBypass,
  __in  DWORD dwFlags
);

hSession = ::InternetOpen(_T("star"), PRE_CONFIG_INTERNET_ACCESS, _T(""),INTERNET_INVALID_PORT_NUMBER,0 );
if(hSession == NULL)
{
return -1;  
}
2.InternetConnectA  (WININET.@)
SYNOPSIS
HINTERNET InternetConnectA
(
  HINTERNET     hInternet,
  LPCSTR        lpszServerName,
  INTERNET_PORT nServerPort,
  LPCSTR        lpszUserName,
  LPCSTR        lpszPassword,
  DWORD         dwService,
  DWORD         dwFlags,
  DWORD_PTR     dwContext
)
DESCRIPTION
Open a ftp, gopher or http session.
RETURNS
HINTERNET a session handle on success NULL on failure
IMPLEMENTATION
Defined in "wininet.h".

hConnectFTP = ::InternetConnectA( hSession, sUrl.c_str(), INTERNET_DEFAULT_FTP_PORT, "sc", "sc123456", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 );
if (hConnectFTP == NULL)
{
return -1;
}
3.
FtpOpenFileA  (WININET.@)
SYNOPSIS
HINTERNET FtpOpenFileA
(
  HINTERNET hFtpSession,
  LPCSTR    lpszFileName,
  DWORD     fdwAccess,
  DWORD     dwFlags,
  DWORD_PTR dwContext
)
DESCRIPTION
Open a remote file for writing or reading.
RETURNS
HINTERNET handle on success NULL on failure
IMPLEMENTATION
Defined in "wininet.h".
HINTERNET hOpenFile = ::FtpOpenFileA( hConnectFTP, (string("./") + sPath).c_str() , GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0 ); //ServerUpdate4.ini   ./20081027/0_116_115517.dat
4.FtpGetFileSize Function
Retrieves the file size of the requested FTP resource.
Syntax

DWORD FtpGetFileSize(
  __in   HINTERNET hFile,
  __out  LPDWORD lpdwFileSizeHigh
);

Parameters
hFile [in]
Handle returned from a call to FtpOpenFile.
lpdwFileSizeHigh [out]
Pointer to the high-order unsigned long integer of the file size of the requested FTP resource.
Return Value
Returns the low-order unsigned long integer of the file size of the requested FTP resource.

DWORD filesize = FtpGetFileSize(hOpenFile , NULL) ;
5.CreateDirectory
This function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
  A RAPI version of this function exists, and it is named CeCreateDirectory (RAPI).
  BOOL CreateDirectory(
  LPCTSTR lpPathName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes
  );
  Parameters
  lpPathName
  [in] Long pointer to a null-terminated string that specifies the path of the directory to be created.
  There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the CreateDirectory function parses paths.
  lpSecurityAttributes
  [in] Ignored; set to NULL.
  Return Values
  Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
  Remarks
  Some file systems, such as NTFS file system, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.
  Requirements
  OS Versions: Windows CE 1.0 and later.
  Header: Winbase.h.
  Link Library: Coredll.lib.
  See Also
  CeCreateDirectory (RAPI) | CreateFile | RemoveDirectory

6.InternetCloseHandle

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.