delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
问一个调用VC下编写的dll的问题???好怪哦 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061220075845111.html
接口函数定义:  
  extern   "C"   DllExport   int   PCFileCopyToOther(char   Disk,    
  LPCSTR   PCFileName,    
  LPCSTR   OtherFileName,  
  BOOL   IsDispProgress,  
  LPCSTR   Message)  
  我在delphi引入如下:  
      function   PCFileCopyToOther(Disk:Byte;PCFileName:PChar;OtherFileName:PChar;  
          IsDispProgress:Boolean;mess:PChar):Integer;stdcall;  
  function   PCFileCopyToDev;external   f3200_dll   name   'PCFileCopyToOther';  
  调用时我是这么调用的:  
  PCFileCopyToOther(0,PChar('1.txt'),PChar('2.txt'),True,PChar('请稍后...'));  
  当运行时在XP系统下就很少出错误,但到了2003   server系统下运行时就出现“内存不能read的错误”;当我将PChar改成shortstring时虽然不出错了,但是传参数时的值可能就不对了,每次调用都得不到预期的值。  
  LPCSTR应该对应是PChar吧

delphi中stdcall->cdecl

楼上,还是不行啊,XP和2003   server不一样吗

用shortstring倒是没出错,但是该怎么传递参数呢

Debug~~

楼上什么意思?

就是相对于RELEASE

没人知道吗

看来分发不下去了

可能的原因为,函数中要改参数的值,你用常量,就会出错  
  解决方法,用array   [0..xxx]   of   char代替pchar  
  或用pchar,但先申请内存,再赋值,最后再调函数

posted on 2008-10-14 16:35 delphi2007 阅读(99) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。