环境:Delphi2005 Archetect Edition (至少是Update1)我在程序中定义了:
type
  TFunction=function (input:Extended):Extended of object;stdcall;
  ....  TFunctions=class
  .......
  public
    layer1:TFunction;                      
    d_layer1:TFunction;                    
    middle_layer:TFunction;                
    d_middle_layer:TFunction;              
    last_layer:TFunction;                  
    d_last_layer:TFunction;                
    constructor Create(DLLFileName:string);
    destructor Destroy;override;
  end;然后用LoadLibrary和GetProcAddress成功装入layer1,d_layer1等等内容,然而……  procedure MapIO;
  var i,j:integer;
  begin
.......
        IO_map[i,j].O:=func.layer1(IO_map[i,j].I)  <-- 就在这里,func是TFunctions的实例,调用了func.layer1(他是从DLL中装入的)之后,j被改变了……   why???  在DLL中:
function layer1(input: Extended): Extended;stdcall;
begin
Result:=input;
end;错在哪里了???还有阿,我试过如果不是从dll读进来,而是使用另外一个类的方法的时候,则可以成功运行。我突然想到问题可能出在哪里了,不过还得试试看是不是。

解决方案 »

  1.   

    问题已解决,问题就出在“of object”……
      

  2.   

    of object 和没有,编译后的结果是不同的,会多个参数
      

  3.   

    加 of object,是指此方法是个对象的方法,必须依附于某个对象才能调用。
      

  4.   

    TNotifyEvent = procedure(Sender: TObject) of object;These types represent method pointers. A method pointer is really a pair of pointers; the first stores the address of a method, and the second stores a reference to the object the method belongs to. Given the declarationstype
      TNotifyEvent = procedure(Sender: TObject) of object;
      TMainForm = class(TForm)
        procedure ButtonClick(Sender: TObject);
        ...
      end;
    var
      MainForm: TMainForm;
      OnClick: TNotifyEventwe could make the following assignment.OnClick := MainForm.ButtonClick;
      

  5.   

    人有时也是会犯些低级错误的,特别是在这么就没用delphi之后