DELPHI如何调用C语言编写的函数(50分)

B

borland

Unregistered / Unconfirmed
GUEST, unregistred user!
我在DOS下用C语言编写了一个函数,已编译成OBJ文件,但
不知如何在DELPHI中调用它,希望各位高手帮忙,最好能提
供一小段源程序。另外,C程序中的函数该如何声明。
 
试试将C程序写成DLL给Delphi调用!
 
用DLL方式较好,不过用 Obj也是可行的
具体如下:

C程序: samp1.cpp
int iGlobal = 0
int _stdcall GetGlobalValue()
{return iGlobal}
将C程序编译成obj
delphi 程序:
var Form1:TForm1;
implementation
{$R *.dfm)
{$L Samp1} //here's the inlcude of samp1.obj
function GetGlobalValue:integer;stdcall;external
就可以使用的
关键是{$L filename}
delphi will link the file to exe,this is the static link
the default extension of file is .obj
也是连接静态库的方法
 
接受答案了.
 
顶部