今天第一次使用Delphi想请教在delphi中怎么使用dll
我用VB6做了一个sysreginf.dll组件 在VB6下调用代码
        Dim cd As New CDKEYS.CDKey
        If cd.CDKeyCheck = True Then
          MsgBox "Success"
        End If
现在我想在delphi下调用这个组件 不知道怎么写?????
在网上找些资料
procedure TloginForm.FormActivate(Sender: TObject);
var
   hd:thandle;
   form:tform;
   invokeform0:invokeform;
begin
    hd:=0;
    hd:=loadlibrary('sysreginf.dll');
    if hd=0 then
    begin
        application.MessageBox('sysreginf.dll没找到!','消息',MB_OK+MB_ICONSTOP);
        EXIT;
    end;
     @invokeform0:=getprocaddress(hd,'CDKeyCheck');
     if (@invokeform0=false) then
     begin
         exit;
     end
end;end.
但是编译时不行 请高手指点

解决方案 »

  1.   

    你刚玩,先不用动态的吧。。
    首先声明DLL的位置
    i m p l e m e n t a t i o n
    function PlusNum(X,Y:Integer):Integer;stdcall;external 'DLL1\Project1.dll';
    function MinusNum(X,Y:Integer):Integer;stdcall;external 'DLL1\Project1.dll';
    function MultiplyNum(X,Y:Integer):Integer;stdcall;external 'DLL2\Project2.dll';
    {$R *. D F M }
    .
    然后在程序中直接调用就DLL中的函数就可以了。
      

  2.   

    在DELPHI中找到i m p l e m e n t a t i o n,然后
    在i m p l e m e n t a t i o n下面声明你要用到的DLL是在那个地方,例如
    function PlusNum(X,Y:Integer):Integer;stdcall;external 'DLL1\Project1.dll';
    这个是来自DLL1\中project1.dll中的函数plusNum然后程序中,你就可以直接调用plusNum
      

  3.   

    wudi_1982说的是静态的方法
    function yourFunctionName(XXX:XXX):XXX;stdcall;external 'yourDllName'
      

  4.   

    你的那个应该这么声明
    【函数名】 ;external 'sysreginf.dll';
    【】这个不要写上去了啊
      

  5.   

    implementation
        function CDKeyCheck():bool;stdcall;external 'SysRegInf.dll';
    {$R *.dfm}procedure TloginForm.FormActivate(Sender: TObject);
    begin
        if CDKeyCheck=true then
        begin
           exit ;
        end
    end;end.
    它说CDKeyCheck在sysreginf.dll找到输入点
      

  6.   

    sysreginf.dll放到工程目录下试试