在Delphi中使用Interbase-Api

在Delphi中使用Interbase-Api,delphi,Delphi,这是我的Delphi代码,用于将用户添加到Interbase安全数据库 uses IBHeader,IBExternals var Form7: TForm7; userData: TUserSecData; userDataPtr: PUserSecData; status: array[0..19] of ISC_STATUS; isc_status: PISC_STATUS; procedure TForm7.Create_UserClick(Sender:

这是我的Delphi代码,用于将用户添加到Interbase安全数据库

uses 
  IBHeader,IBExternals

var
  Form7: TForm7;
  userData: TUserSecData;
  userDataPtr: PUserSecData;
  status: array[0..19] of ISC_STATUS;
  isc_status: PISC_STATUS;

procedure TForm7.Create_UserClick(Sender: TObject);
begin
  { setup isc_status pointer }
  isc_status :=@status;
  { setup user data pointer to point to user data structure }
  userDataPtr :=@userData;
  { setup user data structure }
  userData.user_name :='aseem';

  userData.password :='xxxxxxx';

  userData.protocol :=sec_protocol_local;

  userData.dba_user_name :='SYSDBA';

  userData.dba_password :='xxxxxxx'; { Don_t hardcode this }

  userData.first_name :='asa';

  userData.last_name :='sad';

  userData.sec_flags :=sec_password_spec or sec_dba_user_name_spec or
    sec_dba_password_spec or sec_first_name_spec or sec_last_name_spec;

  { add user to security database }
  isc_add_user(isc_status,userDataPtr);

end;
但有一个错误是

isc_添加_用户(isc_状态,userDataPtr)

在IBheader.pas、IBExternals中找不到函数

你能告诉我这个代码有什么问题吗


我使用的是Delphi 2007 professional edition,我使用的是CodeGear内源文件夹中的IBheader.pas、IBExternals.pas文件。

您可能需要使用IBIntf.pas中定义的接口:

uses IBHeader, IBExternals, IBIntf;

procedure TMyForm.RegisterNewUser;
var
  status: ISC_STATUS;
  status_vector: array[0..19] of ISC_STATUS;
  user_sec_data: UserSecData;
  gds: IGDSLibrary; 
begin
  //setup the user info and then
  ...
  //call the function
  gds := GetGDSLibrary;
  gds.LoadLibrary;
  try
    status := gds.isc_add_user(@status_vector[0], @user_sec_data);
    //check the status and act accordingly
  finally
    gds.FreeLibrary;
  end;
end;
或者,您可能希望通过调用其AddUser方法来使用IBX的一部分TIBSecurityService,该库提供您正在使用的头文件


或者,在现代Interbase中,您可能只需要执行一个
CREATE USER
SQL语句来执行该操作。

下载统一Interbase库,并从中复制所有需要的API声明


TLama还建议您写这篇文章:

@TLama这是一个完全独立的答案,而不仅仅是一篇评论。您可以随意将其包含在您的答案中。我将在几分钟内删除我的。它不是那么独立,因为它只是一个链接;-)谢谢你,jachguate先生,这是与功能gds.LoadIBLibrary一起工作@欢迎光临。考虑到现在我修复了代码中的一个bug(我没有在应该传递向量的地方传递向量)。