VC写的DLL,不仅vc可以引用,delphi\vb\...都可以引用啊
我想问题出在VC写的DLL的程序中
可能是引用的指针不正确,但是程序编译没有问题

解决方案 »

  1.   

    你的Delphi的声明有问题!!有二个地方!
    一个是d:mytype要加Var,而是调用规范你应该指名为cdecl!因为VC缺省的是这种方式!!
    Function  mytype_init(var d:mytype):integer;cdecl;  external  'D:\复件  testdll\test\Debug\test.dll'  ;
        Function  mytype_set(var mytype;e:char;f:string):integer;cdecl; external  'D:\复件  testdll\test\Debug\test.dll'
      

  2.   

    喔!抱歉,我没有看到你你已经定义WinAPi了!哈哈
      

  3.   

    这是由于类型不匹配造成的:
    在int  WINAPI  mytype_init(mytype  *my)中参数my是一个指针;
    而你的声明:
    Function  mytype_init(d:mytype):integer;stdcall;  external  'D:\复件  testdll\test\Debug\test.dll'  ;
    与之相对应的参数d却是一个纪录,造成引用错误
    可改为:
    type
       MYTYPE=RECORD 
        L:INTEGER;
        C:char;
        d:array[0..4]of  char;
        END;
       PMyType= ^MyType;//声明指针类型;const
      FirstDll= 'D:\Microsoft Visual Studio\MyProjects\FirstDll\Debug\FirstDll.Dll';  Function  mytype_init(d:PMyType):integer;stdcall;  external  FirstDll;
      Function  mytype_set(d:PMyType;e:char;f:string):integer;stdcall;  external  FirstDll;
    引用改为:
        mytype_init(@dd);//改为传指针
        mytype_set(@dd,'d','ddd');
      

  4.   

    不好意思,应声明常量:
    const 
        FirstDll= 'D:\复件  testdll\test\Debug\test.dll';先哪个是我测试的~!~