Gunnar Blumert wrote: > type TCallFoo = Function(I: integer): integer; stdcall; // Prototype of > the > function in the DLL > > var HLib: THandle = 0; > Function Foo: TCallFoo; > begin > if HLib = 0 then HLib := LoadLibrary(...); > Result := GetProcAddress(HLib,...); > end; > > So far, so good. But in my application when I have the code > > var I: integer; > ... > I := Foo(5); > > I get two error messages. The first one says "Too many parameters", as Foo > doesn't require any parameters. The second one is "Type mismatch: integer > and TCallFoo", because the type of the result of Foo is TCallFoo and not > integer. Of course my intention is to call the result of Foo (which is the > address of the function in the DLL).
You could try changing it to this: I := Foo()(5); That might tell the compiler that you're calling Foo with zero parameters and then calling the return value with one parameter. I don't know, though; I don't have a Delphi compiler handy. Better yet, go look at the TlHelp32 unit to see how to solve your original problem the usual way. -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

