DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: randy522732557
今日帖子: 21
在线用户: 18
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 blueicemei (blueicemei) ★☆☆☆☆ -
盒子活跃会员
2004/1/2 14:11:41
标题:
请教各位老师关于本地POST的问题,在D5能编译通过。在D7就不行了?在线等! 浏览:1871
加入我的收藏
楼主: 如下代码在DELPHI5能通过。今天新装了DELPHI7就不能通过了?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs ,HTTPApp,
  OleCtrls, SHDocVw, StdCtrls;

type
  TForm1 = class(TForm)
    name: TEdit;
    WebBrowser1: TWebBrowser;
    Button1: TButton;
    email: TEdit;
    address: TEdit;
    mailsubject: TEdit;
    text1: TEdit;
    text2: TEdit;
    text3: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  EncodedDataString: string;
  PostData: OleVariant;
  Headers: OleVariant;
  I: Integer;
begin
  // First, create a URL encoded string of the data
  EncodedDataString := 'Name=' + HTTPEncode(Name.Text)
  + '&' + 'email=' + HttpEncode(email.Text)
  + '&' + 'address=' + HttpEncode(address.Text)
  + '&' + 'mailsubject=' + HttpEncode(mailsubject.Text)
  + '&' + 'text1=' + HttpEncode(text1.Text)
  + '&' + 'text2=' + HttpEncode(text2.Text)
  + '&' + 'text3=' + HttpEncode(text3.Text)
  ;
  // The PostData OleVariant needs to be an array of bytes as large
  // as the string (minus the NULL terminator)
  PostData := VarArrayCreate([0, Length(EncodedDataString) - 1], varByte);
  // Now, move the Ordinal value of the character into the PostData array
  for I := 1 to Length(EncodedDataString) do
    PostData[I-1] := Ord(EncodedDataString[I]);
  Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
  // Finally, we just Navigate to the URL. Note that you may have to modify
  // the path to your ASP page’s location.
  WebBrowser1.Navigate('http://127.0.0.1/post/send.asp', EmptyParam,
    EmptyParam, PostData, Headers);
end;

end.



-----在D7提示错误:
[Error] Unit1.pas(52): Undeclared identifier: 'VarArrayCreate'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'


----------------------------------------------
-
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/1/2 14:18:57
1楼: 在 uses 里添加 Variants

D7不象D5,建立新窗口的时候没有引用Variants单元的,自己加
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 blueicemei (blueicemei) ★☆☆☆☆ -
盒子活跃会员
2004/1/2 14:21:48
2楼: 好的。谢谢!
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行70.3125毫秒 RSS