起步软件技术论坛-X3

 找回密码
 立即注册
搜索
楼主: sun840330

【结帖】dll 引入到x3平台报错**

[复制链接]
 楼主| 发表于 2007-11-2 14:05:56 | 显示全部楼层
快帮看看啊!!急啊!!
回复 支持 反对

使用道具 举报

发表于 2007-11-2 14:11:57 | 显示全部楼层
在客户端使用导入第三方控件要三个文件,
控件文件(*.dll或*.ocx)
使用平台的导入工具生成的
bpl包文件
和dll文件
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 14:17:03 | 显示全部楼层
有啊,都在包里了,可以导入进去的,也可以引用到spacecheck.CheckUrl.CheckedUrl('www.baidu.com',5000);这个方法,就是,运行时就报错了,实在找不到哪错了,请帮忙看看把
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 14:26:03 | 显示全部楼层
在看吗??up!!up
回复 支持 反对

使用道具 举报

发表于 2007-11-2 14:38:17 | 显示全部楼层
网速太慢,下不了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 14:48:17 | 显示全部楼层
哎,和dll里的语句有关吗??我把代码给你发上去看看把
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 14:50:41 | 显示全部楼层
以下是dll的代码.


library Project1;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  ShareMem,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, IdTCPServer, IdHTTPServer, IdMessageClient, IdNNTP,wininet;



  //通过ping url 返回错误信息值如:(404……)。
function CheckedUrl(url: String;TimeOut: integer = 50000 ): integer;stdcall;
var
  hSession, hfile, hRequest: hInternet;
  dwindex, dwcodelen: dword;
  dwcode: array[1..20] of char;
  res: pchar;
  re: integer;
  Err1: integer;
  j,i: integer;
  AResponseText:String;
begin
  if pos('http://', lowercase(url)) = 0 then
    url := 'http://'+ url;
  //Result := false;
  InternetSetOption(hSession, Internet_OPTION_CONNECT_TIMEOUT, @TimeOut, 4);
  hSession := InternetOpen('Mozilla/4.0', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  //设置超时
  if assigned(hsession) then begin
     j := 1;
     while true do begin
       hfile := InternetOpenUrl(hsession, pchar(url), nil, 0, INTERNET_FLAG_RELOAD, 0);
       if hfile = nil then begin
          j := j + 1;
          Err1 := GetLastError;
          if j > 5 then break;
          if (Err1 <> 12002) or (Err1 <> 12152) then break;
         sleep(2);
       end
    else begin
      break;
    end;
  end;
  dwIndex := 0;
  dwCodeLen := 10;
  HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex);
  res := pchar(@dwcode);
  re := strtointdef(res, 404) ;
  result :=re;
  //sleep(3);
// result:=AResponseText;
{ case re of
     400..450: result := false;
  else
      result := true;
  end; }


   if assigned(hfile) then
      InternetCloseHandle(hfile);
      InternetCloseHandle(hsession);
   end;
end;

{$R *.res}
  exports CheckedUrl;
begin
end.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 14:52:25 | 显示全部楼层
HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex);
  res := pchar(@dwcode);
代码里的 @如果用x3来做该怎么写啊??
回复 支持 反对

使用道具 举报

发表于 2007-11-2 14:56:54 | 显示全部楼层
应该和你的dll无关,保证它能在delphi程序中被调用就可以来。

估计还是你导入的控件有问题。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-11-2 15:00:51 | 显示全部楼层
在delphi 里可以被调用的,我都是一步步导入的啊,也没发现什么错误啊.麻烦了,再帮忙看看,想想办法把,谢谢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-6-30 05:29 , Processed in 0.039428 second(s), 14 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表