[fpc-devel] How to call (access) to an external procedure!
Aavani at iust.ac.ir
Tue Jan 31 09:05:16 CET 2006
that works, but could you tell me what should i do for an external variable,
var environ: ppchar; cvar; external;
Geno Roupsky wrote:
>This particular function could be declared as this:
>TEnvironment = class
> class function GetEnvironment(const Name: PChar): PChar; cdecl;
>class function GetEnvironment(const Name: PChar): PChar; cdecl; external
>'c' name 'getenv';
function TEnvironment.GetEnvironment(const Name: PChar): PChar; cdecl;
'c' name 'getenv';
>Of course this is not very useful but the idea for methods is this. Just
>keep in mind that methods have a hidden parameter Self pointing to the
>object. When method is declared as cdecl it is the first parameter.
>В вт, 2006-01-31 в 10:05 +0330, Amir Aavani написа:
>>I know that if want to use an external variable/procedure in fpc, i
>>should use the following code:
>>function GetEnvironment (const Name: PChar): PChar; cdecl; external 'c'
>>but how could i add for example GetEnvironment function to a class
>>Is there any good (OO) way?
>>Is it a good idea to use a following method:
>>TGetEnvironmentFunction= function : PChar;
>>TEnvironment= class (TObject)
>> GetEnvironment: TGetEnvironment;
>> procedure SetGetEnvironmentFunction (AFunction: TGetEnvironmentFunction);
>>procedure TEnvironment.SetGetEnvironmentFunction (AFunction:
>> GetEnvironment:= AFunction;
>>fpc-devel maillist - fpc-devel at lists.freepascal.org
>fpc-devel maillist - fpc-devel at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel