感谢昨晚的几位的解答,小虾谢了分儿也给了.
http://expert.csdn.net/Expert/topic/1690/1690082.xml?temp=.7899897新问题如下: 
   用VC 写DLL在delphi 中用,原函数如下:   __declspec(dllexport) int _stdcall WriteA(struct cardinfo *cardinfo);
   
  __declspec(dllexport) int _stdcall WriteB(unsigned char *key);  __declspec(dllexport)  int _stdcall OpenCom(int com, long baud);
   
cardinfo 为结构体. 动态连接库为a.dll
   
 大虾们给俺再解答一下吧,分儿继续给!  
 主要是关于参数的如何引用!

解决方案 »

  1.   

    我的示例给你看看,不知道对你有什么帮助!!!!
        //声明动态调用的过程
        TGstr = function():Pchar;stdcall;                            //函数的声明
        TMYProc = procedure(var inhandle:HWND; instring:pchar);stdcall;  //是否使用stdcall要依DLL文件决定
                                                                        //注意静态调用时stdcall的位置
        //静态调用动态库
        procedure messageshow( var inhandle:HWND; instring:pchar);stdcall; external 'D:\MyProject\DELPHI\动态库的调用\动态库文件\dllformp.dll';
       function GetString():Pchar;stdcall;external 'D:\MyProject\DELPHI\动态库的调用\动态库文件\dllformp.dll';
       //方法二用name引出
       //procedure messagesho( var inhandle:HWND; instring:pchar);stdcall; external 'D:\MyProject\DELPHI\动态库的调用\动态库文件\dllformp.dll' name 'messageshow';
    var
      Form1: TForm1;
      MyLib:THandle;
      i:integer;
    implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var
        temp:Pchar;
        AHandle:HWND;
    begin
         temp:='呵呵,你好啊!';
          AHandle:=application.Handle;
          edit1.Text:=getstring();
          messageshow(AHandle,temp);
          edit1.Text:='';
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
       temp1:Pchar;
       UHandle:HWND;
       P:TMYproc;
       G:TGstr;
    begin
        temp1:='呵呵,你好啊!';
        UHandle:=application.Handle;
        if MyLib>0 then
        begin         @G:=getprocaddress(mylib,'GetString');      //调用入口
             if @G<>nil then
                begin
                     edit1.Text:=G();
                end
             else
                showmessage('没有找到函数的入口');         @p:=GetProcAddress(mylib,'messageshow');
             if @p<>nil then
                begin
                     p(UHandle,temp1);
                end
             else
                showmessage('没有找到函数的入口');         edit1.Text:='';  
        end
        else
             showmessage('函数加载失败!');
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
           messagebeep(0);
           TIMER1.Enabled:=TRUE;
    end;procedure TForm1.Timer1Timer(Sender: TObject); //加载动态资源,动态库在FORM CREATE 中加载
    var
       IconHand:THandle;
    begin
          if isiconic(application.Handle) then
             begin
                if i>9 then
                   i:=1;            iconhand:=loadicon(mylib,Pchar('ICON'+INTTOSTR(I)));
                if iconhand<> 0 then
                   application.Icon.Handle:=iconhand
                else
                    showmessage('can''t find icon!');
                inc(i);
             end;     
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
            MyLib:=LoadLibrary('D:\MyProject\DELPHI\动态库的调用\动态库文件\dllformp.dll');
          if mylib=0 then
          begin
             showmessage('Can''t Load The Dll!');
             application.Terminate;
          end;
          i:=1;
          
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
        freelibrary(mylib);
    end;end.
      

  2.   

    应该是这样:
    function WriteA(cardinfo:pointer):Integer; stdcall; external 'a.dll';
    function WriteB(key:string):Integer; stdcall; external 'a.dll';
    function OpenCom(com:Integer;baud:longint):Integer; stdcall; external 'a.dll';
    不一定对,试试看?
      

  3.   

    应该如下
     type 
       Pcardinfo=^cardinfo;
    function WriteA(cardinfo:Pcardinfo):Integer; stdcall; external 'a.dll';
    function WriteB(key:PChar):Integer; stdcall; external 'a.dll';
    function OpenCom(com:Integer;baud:longint):Integer; stdcall; external 'a.dll';
      

  4.   

    呵呵!看:
    http://expert.csdn.net/Expert/topic/1645/1645329.xml?temp=.5758631
      

  5.   

    如果结构体是:
    struct  cardinfo 
    {
      cardid[6];
      cardunit[10];
    };
    那么在dephi 中结构体如何定义?