📄 ftpdll.cpp
字号:
// FtpDll.cpp : 定义 DLL 应用程序的入口点。
//
#include "stdafx.h"
#include "FtpDll.h"
#include <windows.h>
#include <commctrl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一的应用程序对象
CWinApp theApp;
using namespace std;
//nsFTP::CLogonInfo m_LogonInfo;
//nsFTP::CFTPClient m_FTPClient;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// 初始化 MFC 并在失败时显示错误
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("错误: MFC 初始化失败\n"));
nRetCode = 1;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
}
return nRetCode;
}
extern "C" FTPDLL_API bool SetHostInfo(wchar_t* lpHostName,int nHostPort,wchar_t* lpUsername, wchar_t* lpPwd, wchar_t* lpAccount)
{
try
{
m_LogonInfo.SetHost(lpHostName, nHostPort, lpUsername,lpPwd, lpAccount);
return true;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool SetFirewallInfo(wchar_t* lpFwHostName,wchar_t* lpFwUsername,wchar_t* lpFwPwd, int nFwHostPort)
{
try
{
nsFTP::CFirewallType m_FwType;
m_LogonInfo.SetFirewall(lpFwHostName, lpFwUsername,lpFwPwd, nFwHostPort,m_FwType);
return true;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool LoginHost(void)
{
try
{
nsFTP::CFTPClient *m_FTPClient;
m_FTPClient=nsFTP::CFTPClient::Instance();
bool bResult = m_FTPClient->Login(m_LogonInfo);
return bResult;
}
catch(...)
{
return 1;
}
}
extern "C" FTPDLL_API bool GetHostFileAndFolderList(wchar_t* lpRemoteFolder, wchar_t* lpFileAndFolder)
{
try
{
nsFTP::CFTPClient *m_FTPClient;
m_FTPClient=nsFTP::CFTPClient::Instance();
nsFTP::TSpFTPFileStatusVector list;
if (!m_FTPClient->List(lpRemoteFolder, list))
{
return false;
}
for( nsFTP::TSpFTPFileStatusVector::iterator it=list.begin();it!=list.end(); ++it)
{
wchar_t lpTemp[1024] = {'\0'};
wsprintf(lpTemp,L"%s%s", (*it)->Name().c_str(),"|");
wcscat(lpFileAndFolder, lpTemp);
}
return true;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool Upload(wchar_t* lpLocalFile, wchar_t* lpRemoteFile)
{
try
{
nsFTP::CFTPClient *m_FTPClient;
m_FTPClient=nsFTP::CFTPClient::Instance();
bool bResult = m_FTPClient->UploadFile(lpLocalFile, lpRemoteFile);
return bResult;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool DownLoad(wchar_t* lpLocalFile, wchar_t* lpRemoteFile)
{
try
{
nsFTP::CFTPClient *m_FTPClient;
m_FTPClient=nsFTP::CFTPClient::Instance();
bool bResult = m_FTPClient->DownloadFile(lpRemoteFile, lpLocalFile);
return bResult;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool FreeBuffer(void)
{
try
{
nsFTP::CFTPClient *m_FTPClient;
m_FTPClient=nsFTP::CFTPClient::Instance();
m_FTPClient->Logout();
delete &m_FTPClient;
return true;
}
catch(...)
{
return false;
}
}
extern "C" FTPDLL_API bool GetVersion(wchar_t* lpVersion)
{
try
{
wcscpy(lpVersion, L"1.0.0");
return true;
}
catch(...)
{
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -