内容如下
我在每次做动态连接库的时候,每次都有如下的提示,即使我用的是一个原本是示例的例子
  提示如下:
  project D:\program files\boland\delphi6\projects \mytest.exe faulted with message:'access violation at 0x77f8f49b:write of 0x00030cb4.'process
stop.use step or run to continue.

解决方案 »

  1.   

    动态调用Dll:typedef DWORD (WINAPI Fun) (DWORD,DWORD);
      HINSTANCE hkDll=LoadLibrary("KERNEL32.DLL");
      Fun*RegisterServiceProcess=(Fun*)::GetProcAddress(hkDll,"RegisterServiceProcess");
      (*RegisterServiceProcess)(NULL,1);
      FreeLibrary(hkDll);
    ===============
    var
      H: HWnd;
      p: procedure(Handle: THandle; Path: PChar); stdcall;
    begin
            H := LoadLibrary(PChar('shdocvw.dll'));
            if H <> 0 then
              begin
                p := GetProcAddress(H, PChar('DoOrganizeFavDlg'));
                if Assigned(p) then p(Application.Handle, PChar(favpath));
              end;
          FreeLibrary(h); 
    end;
      

  2.   

    楼主可能是非法访问了内存,调用了一个不存在的对象才导致这样的问题的,看一看楼主的代码可以吗?
    还有,最坏的可能性是:你的DELPHI坏掉了
      

  3.   

    unit base;interface uses
       Sysutils,windows;
       function Doubl(N:integer):integer;Stdcall;
       function Tripl(N:integer):integer;stdcall;
       function StrWithPad(ps:string;len:integer):string;stdcall;
       function PCharWithPad(BufferIn,BufferOut:PChar;len:integer):LongBool;stdcall;implementationfunction Doubl(N:integer):Integer;Stdcall;
        begin
          MessageBox(0,'jiabei!','mydll',mb_ok);
          Result:=N*2;
        end;
    function Tripl(N:integer):Integer;Stdcall;
        begin
           messageBox(0,'sanbei!','Mydll',mb_OK);
        end;
    function StrWithPad(ps:string;len:integer):string;stdcall;
        begin
           while Length(ps)<len do
             ps:='0'+ps;
             result:=ps;
        end;
    function PCharWithPad(BufferIn,BufferOut:PChar;len:integer):LongBool;Stdcall;
       var
          i:integer;
          tmpInt:integer;
       begin
           Strcopy(BufferOut,'');
           if Length(BufferIn)<len then
               begin
                 TmpInt:=len-length(BufferIn);
                  i:=0;
                  while i<tmpInt do
                   begin
                   Strcat(BufferOut,'0');
                   inc(i);
                   end;
                   strcat(bufferOut,BufferIn);
                   result:=True;
                end
           else
             result:=false;
       end;
    end.
    这是连接库的部分unit mytest;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
      Dialogs,stdctrls,Spin;type
      TForm1 = class(TForm)
        SpinEdit1: TSpinEdit;
        SpinEdit2: TSpinEdit;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Label7: TLabel;
        procedure SpinEdit1Change(Sender: TObject);
        procedure SpinEdit2Change(Sender: TObject);
      
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    function Doubl(I:integer):integer;stdcall;external'mydll';
    function Tripl(N:integer):integer;stdcall;external'mydll';
    function StrWithPad(ps:string;len:integer):string;stdcall;external'mydll';
    function Pcharwithpad(bufferin,bufferOut:PChar;len:integer):longbool;stdcall;external'mydll';var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SpinEdit1Change(Sender: TObject);
    var
      tmpInt:integer;
      tmpStr:String;
      begin
       tmpInt:=doubl(spinedit1.Value);
       label1.Caption:=InttoStr(tmpInt);
       setlength(TmpStr,256);
       if PcharWithPad(PChar(label1.Caption),PChar(tmpStr),8) then
       Label3.Caption:=tmpStr;end;
    procedure TForm1.SpinEdit2Change(Sender: TObject);
     var
      tmpInt:integer;
      tmpStr:String;
      begin
       tmpInt:=doubl(spinedit2.Value);
       label2.Caption:=InttoStr(tmpInt);
       setlength(TmpStr,256);
       if PcharWithPad(PChar(label2.Caption),PChar(tmpStr),8) then
       Label4.Caption:=tmpStr;
      end;end.
     这是主窗体部分
    还有,连接库的项目文件定义如下:
    library mydll
    uses
         base in 'base'
     {$r *.res}
     exports
      doubl,tripl,strwithpad,pCharwithpad;
    begin
    end.
    这是我在示例里抄的一个例题,也是报错
      

  4.   

    我刚接触delphi 
    我现在对delphi还不是很了解。
      

  5.   

    uses
       ShareMem,
       Sysutils,windows;