delphi调vc动态库问题

xiaoyecsdn 2003-08-18 09:49:40
这是在vc动态库中的声明
class OSDDLL_API COSDDLL {
public:
COSDDLL(void);
// TODO: add your methods here.
};

extern OSDDLL_API int nOSDDLL;


OSDDLL_API BOOL OpenConnection(WORD dwPort);
OSDDLL_API BOOL CloseConnection(WORD dwPort, DWORD dwBaudRate);
OSDDLL_API BOOL SetOsdTime(TIMESTRUCT* tm);
OSDDLL_API BOOL GetOsdTime(TIMESTRUCT* tm);
OSDDLL_API BOOL SetInitCharModel(unsigned char totallen,unsigned char index, unsi
gned char * model);
OSDDLL_API BOOL SetDynamicCharModel(unsigned char totallen,unsigned char index, u
nsigned char * model);
OSDDLL_API BOOL SetInitDispInfo(unsigned char index, unsigned char xpos,
unsigned char ypos,unsigned char blink,unsigned char backfill,unsigned char si
ze);
OSDDLL_API BOOL SetDynamicDispInfo(unsigned char index, unsigned char xpos,
unsigned char ypos,unsigned char blink,unsigned char backfill,unsigned char si
ze);
OSDDLL_API BOOL DelInitCharModel();
OSDDLL_API BOOL DelDynamicCharModel();
OSDDLL_API BOOL DelInitDispInfo();
OSDDLL_API BOOL DelDynamicDispInfo(unsigned char line); //0xff means delete all
OSDDLL_API BOOL SetDeviceID(unsigned char id1,unsigned char id2,BOOL bWriteDevice
);
OSDDLL_API BOOL GetDeviceID(unsigned char& id1,unsigned char& id2);
OSDDLL_API BOOL SetTimeFormat(unsigned char format,unsigned char xpos,unsigned ch
ar ypos);

我在delphi中是这样声明的

Function OpenConnection(dwPort:word): Bool;stdcall;external 'OSDDLL.dll'name '?O
penConnection@@YAHG@Z';
Function CloseConnection(dwPort:WORD;dwBaudRate:DWORD): Bool;stdcall;external '
OSDDLL.dll'name '?CloseConnection@@YAHGK@Z';
{Function SetOsdTime(TIMESTRUCT* tm):

上面那个引用参数怎么改?



Bool;stdcall;external 'OSDDLL.dll'name '?SetOsdTime@@YAHPAU_TIMESTRUCT@@@Z';
Function GetOsdTime(TIMESTRUCT* tm): Bool;stdcall;external 'OSDDLL.dll'name '?G
etOsdTime@@YAHPAU_TIMESTRUCT@@@Z';
Function SetInitCharModel(unsigned char totallen,unsigned char index, unsigned
char * model): Bool;stdcall;external 'OSDDLL.dll'name '?SetInitCharModel@@YAHEEPA
E@Z';
Function SetDynamicCharModel(unsigned char totallen,unsigned char index, unsign
ed char * model): Bool;stdcall;external 'OSDDLL.dll'name '?SetDynamicCharModel@@Y
AHEEPAE@Z';
Function SetInitDispInfo(unsigned char index, unsigned char xpos,unsigned char
ypos,unsigned char blink,unsigned char backfill,unsigned char size): Bool;stdcall
;external 'OSDDLL.dll'name '?SetInitDispInfo@@YAHEEEEEE@Z';
Function SetDynamicDispInfo(unsigned char index, unsigned char xpos,unsigned ch
ar ypos,unsigned char blink,unsigned char backfill,unsigned char size): Bool;stdc
all;external 'OSDDLL.dll'name '?SetDynamicDispInfo@@YAHEEEEEE@Z';
Function DelInitCharModel(): Bool;stdcall;external 'OSDDLL.dll'name '?DelInitCh
arModel@@YAHXZ';
Function DelDynamicCharModel(): Bool;stdcall;external 'OSDDLL.dll'name '?DelDyn
amicCharModel@@YAHXZ;
}Function DelInitDispInfo(): Bool;stdcall;external 'OSDDLL.dll'name '?DelInitDi
spInfo@@YAHXZ';
Function DelDynamicDispInfo(line: Pchar): Bool;stdcall;external 'OSDDLL.dll'nam
e '?DelDynamicDispInfo@@YAHE@Z';
{Function SetDeviceID(unsigned char id1,unsigned char id2,BOOL bWriteDevice): B
ool;stdcall;external 'OSDDLL.dll'name '?SetDeviceID@@YAHEEH@Z';
Function GetDeviceID(unsigned char& id1,unsigned char& id2): ):

上面那个指针参数怎么改?

Bool;stdcall;external 'OSDDLL.dll'name '?GetDeviceID@@YAHAAE0@Z';
Function SetTimeFormat(unsigned char format,unsigned char xpos,unsigned char yp
os): Bool;stdcall;external 'OSDDLL.dll'name '?SetTimeFormat@@YAHEEE@Z'; }

function GetChineseLattice(ChineseText: String; out LatticeData: array of char;
Style: Integer): Boolean; stdcall;far;external 'Lattices.dll'
implementation

uses Unit2, Unit3, Unit4, Unit5;

{$R *.dfm}

procedure TForm1.Button8Click(Sender: TObject);
var
Rego:Tregistry;
nindex:integer;
begin
Rego:=Tregistry.Create;
Rego.RootKey:=HKEY_USERS;
Rego.OpenKey('.DEFAULT\Software\AngelSoft\Dset',False);
Rego.OpenKey('.DEFAULT\Software\AngelSoft\Iset',False) ;
Rego.OpenKey('.DEFAULT\Software\AngelSoft\Tset',False) ;
//Label1.Caption:=rego.ReadString('sx');
//Label2.Caption:=IntToStr(Rego.ReadInteger('sy'));
rego.Free;
{ case combobox3.ItemIndex of
1:SetOsdTime()
2:GetOsdTime()
3:SetInitCharModel()
4:SetDynamicCharModel()
5:SetInitDispInfo()
6:SetDynamicDispInfo()
7:DelInitCharModel()
8:SetDynamicDispInfo()
9:DelDynamicCharModel()
10:DelInitDispInfo()
11:SetDeviceID()
12:DelDynamicDispInfo()
end }

end;



procedure TForm1.Button7Click(Sender: TObject);
var
nCom:word;
begin
if Combobox1.ItemIndex= 0
then
nCom:=0
else
nCom:=1;

if OpenConnection(ncom)
then
ShowMessage('open') 到这儿就死机了,光标能用,但按不动按钮?
else
raise EcomInvalid.Create('com error');

// else CloseConnection(0,9600);
end;

end.

请帮忙赐教.
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eastunfail 2003-08-18
  • 打赏
  • 举报
回复
OSDDLL_API的定义改为:
#define OSDDLL_API extern "C" __declspec(dllexport)
jerrymousenet2 2003-08-18
  • 打赏
  • 举报
回复
Function SetOsdTime(tm: Pointer):
jerrymousenet2 2003-08-18
  • 打赏
  • 举报
回复
Function GetDeviceID(id1: PChar; id2: PChar);

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧