百度空间 | 百度首页 
 
查看文章
 
delphi调用cuteFTP的TE[为Delphi开拓一片新的空间]
2009-07-01 17:17

楼主miaoyuli(恶魔厕所里的神)2005-04-0322:27:47
在Delphi/VCL组件开发及应用提问
用CuteFTP录制了一段宏,保存成了VBS文件,内容大致如下
SetMySite=CreateObject("CuteFTPPro.TEConnection")
MySite.Host="192.168.3.139"
MySite.Protocol="FTP"
MySite.Port=21
MySite.Retries=3
MySite.Delay=30
MySite.MaxConnections=2
MySite.TransferType="AUTO"
MySite.DataChannel="DEFAULT"
MySite.AutoRename="OFF"
MySite.Login="123456"
MySite.Password="123456"
MySite.SocksInfo=""
MySite.ProxyInfo=""
MySite.Connect
MySite.Upload "c:1.txt", "/d:/ftpdata/users/123456/1.txt"
MySite.Upload "C:1.jpg", "/d:/ftpdata/users/123456/1.jpg"
MySite.Disconnect
请问用DELPHI如何调用执行这段宏?

解题关键:
CreateOleObject(ComObj)

回答:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;

implementation
uses ComObj;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
MySite : OleVariant;
begin
MySite := CreateOleObject('CuteFTPPro.TEConnection');
if not VarIsEmpty(MySite) then
begin
MySite.Host   :=   'ip地址';
MySite.Protocol   :=   'FTP';
MySite.Port   :=   21;
MySite.Retries   :=   3;
MySite.Delay   :=   30;
MySite.MaxConnections   :=   2;
MySite.TransferType   :=   'AUTO';
MySite.DataChannel   :=   'DEFAULT';
MySite.AutoRename   :=   'OFF';

MySite.Login   :=   '用户名';
MySite.Password   :=   '密码';
MySite.SocksInfo   :=   '';
MySite.ProxyInfo   :=   '';
  
MySite.Connect;
MySite.Download('/1.txt', 'd:\1.txt');
MySite.Download('/1.jpg', 'd:\1.jpg');

// MySite.Upload('c:\1.txt',   '/1.txt');
// MySite.Upload('C:\1.jpg',   '/1.jpg');
end
else begin
//这里处理没有安装的提示~!
end;
end;
end.


其他:

COM Registration of the TE (for Distribution)
As a typical COM Component, the TE must be registered as such on the target system. The TE will automatically perform COM Registration if it has been manually executed prior to

a script or application instantiating the TE Object.

The preferred method (for distributed versions of the TE on end-user's systems) is to set the appropriate registry entries before trying to call the TE.

COM Registration via the Registry

From your installation program, script, or custom application, write the registry entries below to the target computer. The entries are shown in the standard .reg file notation.


Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CuteFTPPro.TEConnection]
@="TEConnection Class"
[HKEY_CURRENT_USER\Software\Classes\CuteFTPPro.TEConnection\CLSID]
@="{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}"
[HKEY_CURRENT_USER\Software\Classes\CuteFTPPro.TEConnection\CurVer]
@="CuteFTPPro.TEConnection.8"
[HKEY_CURRENT_USER\Software\Classes\CuteFTPPro.TEConnection.8]
@="TEConnection Class"
[HKEY_CURRENT_USER\Software\Classes\CuteFTPPro.TEConnection.8\CLSID]
@="{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}]
@="TEConnection Class"
"AppID"="{DA15006A-FADA-495b-9A0C-EC2107E2FB9F}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}\LocalServer32]
@="\"C:\\Program Files\\GlobalSCAPE\\CuteFTP 8 Professional\\ftpte.exe\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}\ProgID]
@="CuteFTPPro.TEConnection.8"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}\Programmable]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}\TypeLib]
@="{1B04F22B-5012-432d-8EA0-B57DD75EBF9D}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{112EA537-7AB9-4e22-8BFB-7FD5FCB19849}\VersionIndependentProgID]
@="CuteFTPPro.TEConnection"

详细内容参考:

Transfer Engine

The topics below provides the procedures for using the Transfer Engine.

Transfer Engine Overview

Distributing the Transfer Engine

Methods

Properties

Troubleshooting


类别:资料 | 添加到搜藏 | 浏览() | 评论 (2)
 
最近读者:
 
网友评论:
1
2009-07-01 17:26 | 回复
注意这里的
var
MySite : OleVariant;
begin
MySite := CreateOleObject('CuteFTPPro.TEConnection');
if not VarIsEmpty(MySite) then
足可以把任何的CreateOleObject相关VBS代码换成Delphi代码,
所以说虽然很懒,但是,
为Delphi程序设计的确开拓了一个新的天地,

...COM的应用...
..才开始了解...
还能够绑定一些事件,
这样的资料在互联网上比较多,
只要是打开这个思路,
就明白了.
 
2
2009-07-01 17:28 | 回复
http://www.liqiuyun.com/logs/39648406.html
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu