发信人: lofe ()感激生活(), 信区: BorlandDev
标 题: .C调用Delphi编写的DLL
发信站: 哈工大紫丁香 (Mon Sep 4 16:13:41 2000), 转信
Calling a DLL from your C Code.
First create a simple DLL in Delphi:
{ Begin DLL code }
Library MinMax;
Function Min(X, Y: Integer): Integer; export;
begin
if X < Y then Min := X else Min := Y;
end;
Function Max(X, Y: Integer): Integer; export;
begin
if X > Y then Max := X else Max := Y;
end;
Exports
Min index 1,
Max index 2;
begin
end.
{ End DLL code }
Then to Call it from your C Code:
1. In your .DEF File add:
IMPORTS
Min =MINMAX.Min
Max =MINMAX.Max
2. In your C application, you must prototype the functions as:
int FAR PASCAL Min(int x, y);
int FAR PASCAL Min(int x, y);
3. Now you can call Min or Max anywhere in your application.
--
※ 修改:.haojs 于 Sep 4 16:11:13 修改本文.[FROM: bbs.hit.edu.cn]
--
※ 转寄:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: bbs.hit.edu.cn]
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: haojs.bbs@bbs.whnet.]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.657毫秒