Delphi 调用 C代码的DLL 问题 有点点难 望大家帮助下 300 ( 积分: 300 )

  • 主题发起人 主题发起人 fz97534
  • 开始时间 开始时间
F

fz97534

Unregistered / Unconfirmed
GUEST, unregistred user!
_int16_stdcall1&nbsp;&nbsp;z8_setime(HANDLE&nbsp;icdev,unsigned&nbsp;char&nbsp;addr,unsigned&nbsp;char*time);<br>&nbsp;&nbsp;&nbsp;&nbsp;功能:设置设备时间<br>&nbsp;&nbsp;&nbsp;&nbsp;参数:time&nbsp;给入时间格式十六进制形式:如果当前时间为了&nbsp;2006-3-8&nbsp;11:05:18&nbsp;&nbsp;&nbsp;&nbsp;则time给入值为<br>&nbsp;&nbsp;&nbsp;&nbsp;0x06&nbsp;0x03&nbsp;0x08&nbsp;0x11&nbsp;0x05&nbsp;0x18<br><br>===========================<br>该怎么申明&nbsp;怎么调用啊<br>望大家给我解释下&nbsp;<br>给&nbsp;900分&nbsp;在&nbsp;再贴给&nbsp;600&nbsp;分
 
在单元头部声明<br>function&nbsp;z8_setime(icdev:THANDLE;addr:BYTE;time:PCHAR):Smallint;stdcall&nbsp;external&nbsp;'yourdll.dll';<br><br>声明一个数组mytime:array[0..5]&nbsp;of&nbsp;char;<br>mytime[0]&nbsp;:=&nbsp;$06;<br>mytime[1]&nbsp;:=&nbsp;$03;<br>mytime[2]&nbsp;:=&nbsp;$08;<br>mytime[3]&nbsp;:=&nbsp;$11;<br>mytime[4]&nbsp;:=&nbsp;$05;<br>mytime[5]&nbsp;:=&nbsp;$18;<br><br>调用<br>z8_setime(myicdev,myaddr,@mytime)
 
这是静态调用,如果要动态调用,你就用LoadLibrary、GetProcAddress的方法。
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3529211<br><br>看看这里吧
 
请问下&nbsp;一个字符变量怎么转换啊<br><br>Str:='2007-08-06'<br><br>怎么给这个转换啊<br><br>mytime[0]&nbsp;:=&nbsp;$06;<br>mytime[1]&nbsp;:=&nbsp;$03;<br>mytime[2]&nbsp;:=&nbsp;$08;<br>mytime[3]&nbsp;:=&nbsp;$11;<br>mytime[4]&nbsp;:=&nbsp;$05;<br>mytime[5]&nbsp;:=&nbsp;$18;
 
就是&nbsp;Str&nbsp;=&nbsp;'06'&nbsp;怎么&nbsp;mytime[0]&nbsp;:=&nbsp;$06;<br>给这个转换啊<br>需要一个&nbsp;Function&nbsp;FCharToHex(str:String):Hex<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;着而这么写啊????<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result:=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3820069<br>送分贴&nbsp;已经开好<br>crazycock,来拿分
 
鉴于此楼主一贯倒分,注册一堆账号(fz97534、fz97535、f643208)转来转去,请大家考虑清楚了再回复:<br>http://www.delphibbs.com/delphibbs/listq.asp?type=2&amp;userfrom=fz97534<br>http://www.delphibbs.com/delphibbs/listq.asp?sort=6&amp;type=2&amp;expert=fz97534<br>http://www.delphibbs.com/delphibbs/listq.asp?type=2&amp;userfrom=f643208
 
如果你的年份格式固定就比较方便。<br><br>Str:='2007-08-06'<br><br>Function&nbsp;FCharToHex(str:String):Char;&nbsp;&nbsp;//这里用char不是什么hex<br>begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Chr(IntToHex(StrToInt(str),2));<br>end&nbsp;&nbsp;&nbsp;<br><br><br>mytime[0]&nbsp;:=&nbsp;FCharToHex('07');<br>mytime[1]&nbsp;:=&nbsp;FCharToHex('');<br>mytime[2]&nbsp;:=&nbsp;FCharToHex('');<br>mytime[3]&nbsp;:=&nbsp;FCharToHex('');<br>mytime[4]&nbsp;:=&nbsp;FCharToHex('');<br>mytime[5]&nbsp;:=&nbsp;FCharToHex('');
 
ok<br>太好了&nbsp;&nbsp;谢谢&nbsp;省了很多时间<br>看来程序员&nbsp;的享受就是&nbsp;&nbsp;省时间来做事情
 
crazycock<br><br>来这儿接&nbsp;300&nbsp;分<br><br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3820288
 
我那里也有600分的帖,帮我解决问题,你也可以挣分咯~~
 
后退
顶部