delphi中:
   Function ShowZongPou():WordBool;export;var
  Form1: TForm1;implementation{$R *.dfm}Function Show():WordBool; begin
          try
                  Form1:=TForm1.Create(Application);
                  form1.ShowModal;
          finally
                  form1.free;
          end;
  end;vc6中:
typedef bool (__stdcall *MYPROC)(); 

HINSTANCE hinstLib; 
    MYPROC ProcAdd; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 
 
    // Get a handle to the DLL module.
 
    hinstLib = LoadLibrary("Project.dll"); 
 
    // If the handle is valid, try to get the function address.
 
    if (hinstLib != NULL) 
    { 
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, "Show"); 
 
        // If the function address is valid, call the function.
 
        if (fRunTimeLinkSuccess = (ProcAdd != NULL)) 
            (ProcAdd) (); 
 
        // Free the DLL module.
 
        fFreeResult = FreeLibrary(hinstLib); 
    } 
 
    // If unable to call the DLL function, use an alternative.
 
    if (! fRunTimeLinkSuccess) 
        printf("message via alternative method\n"); 运行时报错:
Access violation at address 00d8a1f1 in module 'project.dll'.Write of address 000001f8

解决方案 »

  1.   

    Function Show():WordBool; stdcall;
      

  2.   

    你的DLL写的有问题啊
     发表于:2007-09-17 00:37:03 楼主 
    delphi中: 
       Function ShowZongPou():WordBool;stdcall; var 
      Form1: TForm1; implementation {$R *.dfm} Function Show():WordBool;stdcall; begin 
              try 
                      Form1:=TForm1.Create(Application); 
                      form1.ShowModal; 
              finally 
                      form1.free; 
              end; 
      end; exports
      Show;
     
     
      

  3.   

    首先你检查一下在autocreate是否有你的那个窗体,还有你试着把Form1: TForm1定义到函数里,不要在接口中定义.你可以参考一下<delphi5开发人员指南>一书,里面第九章是讲DLL的,就说到了你说的dll 中包含窗体的问题
      

  4.   

    对了,还有问题,就是似乎在函数参数里传递一个应用程序的句柄给DLL的TApplication对象,Dll中的TApplication对象与调用他的应用程序是分离的,为使DLL窗体真正成为应用程序的模式窗体,必须讲应用程序的句柄付给DLL的TApplication.Handle属性,如果不这样做的话结果难以预料
    TApplication.Handle:=AHandle;
    AHandle为函数的参数