我用DLL打包了一个动态装入IMAGE的过程如下:
DLL:use
 Shermem,....;
 
Produre LoadIma(image :Timage;strFileName :string);
begin
try 
 if(FileIsExit(strFileName)then 
    image.Picture.LoadFormFile(strFileName)
  else
    Showmessage('文件不存在');
except
 Showmessage('错误!');
end;
end;并且Applicattion也初始化了。当我用DLL调时总到Except中去了,我在文件存在后加一句Showmessage(strFileName),能正确显示文件路。

解决方案 »

  1.   

    1、如果执行到了Except,则说明程序调用DLL是正确的,并且定位DLL内的函数也是正确的;
    2、在DLL内判别文件是否存在与一般程序中的处理没有区别,因此,我认为
       if(FileIsExit(strFileName) then ……语句本身没有错;
    3、但是,strFileName指定的文件本身也许有访问权限的问题,进入Except实际说明你的程序中出现了异常条件,而这个异常只能是前边的文件判别、文件读取中发生。既:
       FileIsExit(strFileName)
       image.Picture.LoadFormFile(strFileName)
      

  2.   

    uses Graphics, Jpegs;
    OK?
      

  3.   

    错误应该就出在DLL文件中的image.Picture.LoadFormFile(strFileName)、
    最好不要直接这样调用组件的方法、除非对象也是在DLL文件中创建的、
    具体你可以参考一下以前在大富翁上看到的一个帖子:
    http://www.delphibbs.com/delphibbs/dispq.asp?lid=1746656
      

  4.   

    image.Picture.LoadFormFile(strFileName)
    這句有問題, 但一時找不到解決方法
      

  5.   

    你可以这样呀:
    先把你的image放到一个资源文件中去,然后,再新建一个动态链库,引用一下你的资源文件,编译一下,就可以从DLL中读出你的Image了.
      

  6.   

    好像解決了我引用了一下jpep和Graphicss兩個單元,暫時不出錯可還有一個別的錯誤就是ADOQuery的代碼如下:
    {返回某個字段的值}
    function GetFieldValue(TableName,FieldName :string;var strValue :string):boolean;overload;stcatall
    var
       DataSet:TADOQuery;
    begin
      Result := false;
      try
         DataSet:=TADOQuery.Create(nil);
         with DataSet do
         begin
           Connection := Pubconn;
           Close;
           SQL.Clear;
           SQL.Text := 'select '+FieldName+' From '+ TableName;
           if not(Prepared) then
             Prepared := true;
           ExecSQL;
           Open;
           First;
           if(RecordCount>0)then
           begin
             //
             strValue := DataSet.Fields[0].AsString;
             //strValue := FieldByName(FieldName).AsString;
             if strValue='' then
               strValue := '1';//當有空表時,須加給值
             Result := true;
           end;
         end;
         DataSet.Close;
         DataSet.Free;
       except
          EpsDLG(CMSG_DBERROR,4);
       end;
    end;運行一兩次沒事,多几次就有問題了為什么?