vo_to_net:pcall
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
vo_to_net:pcall [2018/07/11 08:35] – wolfgangriedmann | vo_to_net:pcall [2018/07/29 05:22] (current) – wolfgangriedmann | ||
---|---|---|---|
Line 4: | Line 4: | ||
The X# compiler needs a typed function pointer for '' | The X# compiler needs a typed function pointer for '' | ||
- | < | + | < |
RETURN 0 | RETURN 0 | ||
.... | .... | ||
Line 10: | Line 10: | ||
dword( _cast , PCALL( hFunc ,@struOS) )</ | dword( _cast , PCALL( hFunc ,@struOS) )</ | ||
The alternative (to not define such a function) is to use '' | The alternative (to not define such a function) is to use '' | ||
- | < | + | < |
PCALLNative< | PCALLNative< | ||
The .NET way would be the definition of a delegate (i.e. a typed function pointer). Please see [[: | The .NET way would be the definition of a delegate (i.e. a typed function pointer). Please see [[: | ||
A sample for the delegate version is the following: | A sample for the delegate version is the following: | ||
- | < | + | < |
local oFunc as RtlGetVersionDelegate | local oFunc as RtlGetVersionDelegate | ||
oFunc := ( RtlGetVersionDelegate ) Marshal.GetDelegateForFunctionPointer( hFunc, TypeOf( RtlGetVersionDelegate ) ) | oFunc := ( RtlGetVersionDelegate ) Marshal.GetDelegateForFunctionPointer( hFunc, TypeOf( RtlGetVersionDelegate ) ) | ||
oFunc: | oFunc: | ||
+ | |||
+ | To simplify the code, a static method could help: | ||
+ | <code visualfoxpro> | ||
+ | |||
+ | static method CreateDelegate< | ||
+ | local oFunc as T | ||
+ | local oDelegate as object | ||
+ | |||
+ | oDelegate := Marshal.GetDelegateForFunctionPointer( hFunc, TypeOf( T ) ) | ||
+ | |||
+ | oFunc := ( T ) oDelegate | ||
+ | |||
+ | return oFunc | ||
+ | |||
+ | end class</ | ||
+ | and to be used: | ||
+ | <code visualfoxpro> | ||
+ | (Code courtesy of Chris Pyrgas) | ||
The X# development team recommends the use of '' | The X# development team recommends the use of '' |
vo_to_net/pcall.1531298143.txt.gz · Last modified: 2018/07/11 08:35 by wolfgangriedmann