请教各位大侠:
我调用一VC写的DLL出现如下错误:
Project Project14.exe raised exception class EAccessViolation with message 'Access violation at address 00383371 in module 'phoneDriver.dll'. Write of address 004281BC'. Process stopped. Use Step or Run to continue.说明:
phoneDriver.dll为一连接硬件的DLL,出厂的时候附带的。封装是非标准形式,用的是类的形式。为了使该DLL能给其他语言掉用,我将其用标准形式封装成VC_UPhone.dll。封装后已试验过其中有2个函数可以给C++Builder和Delphi调用。但是在调用startPlayFile函数时出现以上问题。源代码如下:
unit Unit14;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}{function callOut(callId: string; stateSign: boolean):integer;stdcall;}
function startPlayFile(filePath: pchar; openPlay: boolean; volume: longint; replay: boolean): boolean;stdcall;
external 'VC_UPhone.dll';procedure TForm1.Button1Click(Sender: TObject);
begin
startPlayFile('E:\123.WAV',true,100,false);
end;end.求教各位大侠问题所在,十分感谢!

解决方案 »

  1.   

    另外补充:该函数用C++Builder调用也出现类似错误:Project Project15.exe raised exception class EAccessViolation with message 'Access violation at address 01123371 in module 'phoneDriver.dll'. Write of address 010F2B72'. Process stopped. Use Step or Run to continue.是不是我封装出来的"VC_UPhone.dll"有些函数用到,但某些函数是用不到呢?有兼容性问题?
      

  2.   

    delphi里面没有用BOOL的吧。Delphi 字长/值域 C++ShortInt 8位有符号整型 signed char
    SmallInt 16位有符号整型 short
    LongInt 32位有符号整型 int
    Byte 8位无符号整型 unsigned char
    Word 16位无符号整型 unsigned short
    Integer 32位有符号整型 int
    Cardinal 32位无符号整型 unsigned int
    Boolean 真/假 bool
    ByteBool 真/假 或 8位无符号整型 unsigned char
    WordBool 真/假 或 16位无符号整型 unsigned short
    LongBool 真/假 或 32位无符号整型 BOOL (WinAPI)
    AnsiChar 8位无符号字符 char
    WideChar 宽字编码字符 wchar_t
    Char 8位无符号字符 char
    AnsiString Delphi的字符串类 AnsiString 类
    String[n] 老式的Delphi字符串, n = 1..255字节 SmallString<n> 模板类ShortString 老式的Delphi字符串, 255字节 SmallString<255>
    String Delphi的AnsiString类 AnsiString
    Single 32位浮点数 float
    Double 64位浮点数 double
    Extended 80位浮点数 long double
    Real 32位浮点数 double
    Pointer 32无类型指针 void *
    PChar 32位字符型指针 unsigned char *
    PAnsiChar 32位ANSI型字符指针 unsigned char *
    Comp 64位浮点数 Comp 类
    OleVariant OLE可变类型值 OleVariant 类