delphi使用Chilkat 组件和库从SFTP下载文件
官网地址:https://www.example-code.com/delphiDll/default.asp
实例代码:(不包括全局解锁) 密码生成器:https://www.cnblogs.com/hhmm99/p/11383027.html
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SFtp; ... procedure TForm1.Button1Click(Sender: TObject);
var
sftp: HCkSFtp;
hostname: PWideChar;
port: Integer;
success: Boolean;
remoteFilePath: PWideChar;
localFilePath: PWideChar; begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code. sftp := CkSFtp_Create(); // Set some timeouts, in milliseconds:
CkSFtp_putConnectTimeoutMs(sftp,);
CkSFtp_putIdleTimeoutMs(sftp,); // Connect to the SSH server.
// The standard SSH port =
// The hostname may be a hostname or IP address.
hostname := 'sftp.example.com';// ip
port := ;// 端口
success := CkSFtp_Connect(sftp,hostname,port);
if (success <> True) then
begin
Memo1.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end; // Authenticate with the SSH server. Chilkat SFTP supports
// both password-based authenication as well as public-key
// authentication. This example uses password authenication.
success := CkSFtp_AuthenticatePw(sftp,'myLogin','myPassword');// 账号密码
if (success <> True) then
begin
Memo1.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end; // After authenticating, the SFTP subsystem must be initialized:
success := CkSFtp_InitializeSftp(sftp);
if (success <> True) then
begin
Memo1.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end; // Download the file: localFilePath := 'c:/temp/hamlet.xml';// 本地保存路径
remoteFilePath := 'subdir1/subdir2/hamlet.xml'; // 服务器文件路径
// The ResumeDownloadFileByName method will check
// the local file and begin downloading the remote file
// at the appropriate point. For example, if the local
// file is already bytes long, it will begin downloading
// the remote file at the 'th byte -- appending to
// the local file.
success := CkSFtp_ResumeDownloadFileByName(sftp,remoteFilePath,localFilePath);
if (success <> True) then
begin
Memo1.Lines.Add(CkSFtp__lastErrorText(sftp));
Exit;
end; Memo1.Lines.Add('Success.'); CkSFtp_Dispose(sftp); end; © - Chilkat Software, Inc. All Rights Reserved.
解锁:

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Global; ... procedure TForm1.Button1Click(Sender: TObject);
var
glob: HCkGlobal;
success: Boolean;
status: Integer; begin
// The Chilkat API can be unlocked for a fully-functional -day trial by passing any
// string to the UnlockBundle method. A program can unlock once at the start. Once unlocked,
// all subsequently instantiated objects are created in the unlocked state.
//
// After licensing Chilkat, replace the "Anything for -day trial" with the purchased unlock code.
// To verify the purchased unlock code was recognized, examine the contents of the LastErrorText
// property after unlocking. For example:
glob := CkGlobal_Create();
success := CkGlobal_UnlockBundle(glob,'Anything for 30-day trial');
if (success <> True) then
begin
Memo1.Lines.Add(CkGlobal__lastErrorText(glob));
Exit;
end; status := CkGlobal_getUnlockStatus(glob);
if (status = ) then
begin
Memo1.Lines.Add('Unlocked using purchased unlock code.');
end
else
begin
Memo1.Lines.Add('Unlocked in trial mode.');
end; // The LastErrorText can be examined in the success case to see if it was unlocked in
// trial more, or with a purchased unlock code.
Memo1.Lines.Add(CkGlobal__lastErrorText(glob)); CkGlobal_Dispose(glob); end;
成功:

delphi使用Chilkat 组件和库从SFTP下载文件的更多相关文章
- python 读取csv中的文件,从sftp下载文件
需要从sftp上下载一些图片文件,文件名存放在一个csv文件中.代码如下: # -*- coding:utf-8 -*- import paramiko import csv import os de ...
- SSIS 通过 WINscp 从SFTP下载文件
1.通过SSIS的process task调用 winscp :C:\Program Files (x86)\WinSCP\WinSCP.exe /script="C:\SFTPFile\T ...
- 转:Windows下用sftp自动下载文件
远程服务器是Linux操作系统,没有ftp服务,可以ssh,数据库每天2:00会自动创建一个备份文件,本地计算机是windows操作系统,希望用sftp每天3:00下载远程服务器上的备份文件.本地系统 ...
- Linux - 通过SecureCRT的rz、sz和sftp实现文件的上传和下载
目录 1 通过rz/sz命令上传/下载 1.1 安装lrzsz软件 1.2 rz - 上传文件 1.3 sz - 下载文件 2 通过sftp上传/下载文件 2.1 关于SFTP的简介 2.2 SFTP ...
- libcurl开源库在Win7 + VS2012环境下编译、配置详解 以及下载文件并显示下载进度 demo(转载)
转载:http://blog.csdn.net/fengshuiyue/article/details/39530093(基本教程) 转载:https://my.oschina.net/u/14207 ...
- 如何在Linux中使用sFTP上传或下载文件与文件夹
如何在Linux中使用sFTP上传或下载文件与文件夹 sFTP(安全文件传输程序)是一种安全的交互式文件传输程序,其工作方式与 FTP(文件传输协议)类似. 然而,sFTP 比 FTP 更安全;它通过 ...
- Delphi - Windows系统下,Delphi调用API函数和7z.dll动态库,自动把文件压缩成.tar.gz格式的文件
项目背景 应欧美客户需求,需要将文件压缩成.tar.gz格式的文件,并上传给客户端SFTP服务器. 你懂的,7-Zip软件的显著特点是文件越大压缩比越高,在Linux系统上相当于我们Windows系统 ...
- Mozilla Brick:一个Web组件Polyfill库
Web组件是一个W3C规范,它旨在使Web开发人员能够定义具有非常丰富的视觉效果和高可交互性且易于组合的小组件.Brick库提供了新的自定义HTML标签,从而抽象了用户常用接口模式.在浏览器本身支持类 ...
- Delphi 利用TComm组件 Spcomm 实现串行通信
Delphi 利用TComm组件 Spcomm 实现串行通信 摘要:利用Delphi开发工业控制系统软件成为越来越多的开发人员的选择,而串口通信是这个过程中必须解决的问题之一.本文在对几种常用串口通信 ...
随机推荐
- Objective-C面试题(精心整理的,附答案)
转自:http://www.mianwww.com/html/2014/03/20372.html 1.objective-c 是所有对象间的交互是如何实现的? 在对象间交互中每个对象承担的角色不同, ...
- git 使用详解 (1)——历史
版本控制系统(VCS) 有了它你就可以将某个文件回溯到之前的状态,甚至将整个项目都回退到过去某个时间点的状态.你可以比较文件的变化细节,查出最后是谁修改了哪个地方,从而导致出现怪异问题,又是谁在何时报 ...
- Zookeeper Watcher接口
在ZooKeeper中,接口类Watcher用于表示一个标准的事件处理器,其定义了事件通知相关的逻辑,包含KeeperState和EventType两个枚举类,分别代表了通知状态和事件类型,同时定义了 ...
- mysql主从复制原理及实践
Mysql主从复制原理及实践 mysql主从框架 MySQL主从架构是MySQL集群中最基本也是最常用的一种架构部署,能够满足很多业务需求,常见的有一主一从或者一主多从.可以防止单一主机的 ...
- 尺取法two pointers
目的:对给定的一个序列,在序列中寻找包含全部需求的.长度最小的一段子序列.一般用来解决具有单调性的区间问题. 时间复杂度:O(n) https://blog.csdn.net/lxt_lucia/ar ...
- django学习03-模版
新手做的笔记,很可能会有理解错误的地方.欢迎拍砖. 在polls/views.py中增加下面内容,完善功能. def detail(request, question_id): return Http ...
- win10配置git SSH
1.安装的过程就不说了,直接去官网下载git for windows 安装便可 安装完了,无非就是像用它,就想从github上clone项目下来,仅仅是安装了git还不能直接从远程下载项目下来哦,还需 ...
- 超简单!asp.net core前后端分离项目使用gitlab-ci持续集成到IIS
现在好多使用gitlab-ci的持续集成的教程,大部分都是发布到linux系统上的,但是目前还是有很大一部分企业使用的都是windows系统使用IIS在部署.NET应用程序.这里写一下如何使用gitl ...
- NIO-SocketChannel源码分析
目录 NIO-SocketChannel源码分析 目录 前言 ServerSocketChannelImpl 创建ServerSocketChannel 绑定和监听 接收 SocketChannelI ...
- 从项目中理解SSM框架
我们看招聘信息的时候,经常会看到这一点,需要具备SSH框架的技能:而且在大部分教学课堂中,也会把SSH作为最核心的教学内容. 但是,我们在实际应用中发现,SpringMVC可以完全替代Struts,配 ...