Converting from VO app to X# and have some MAPI email functions that I got from Phil McGuinnes around 2006. I'm not sure whether to rewrite this section using the MS.Outlook.Interop or just fix up the MAPI as it is only used in a couple of methods and Interop for the rest.
Anyway - here's my question, maybe someone has already solved it?
X# error XS9035 The first argument to PCALL must be a "typed function pointer".
Does that mean typing sMAPI.pLogon, or is there a new parameter required?
If typing pLogon, it is declared as a PTR elsewhere - so what is the syntax to type it in PCALL please?
PCALL function is below, and the MAPILogon function below that.
nResult := DWORD( _CAST , PCALL( sMAPI.pLogon , ;
ulUIParam , ;
PSZ( _CAST , lpszName ) , ;
PSZ( _CAST , lpszPassword ) , ;
flFlags , ;
0 , ;
@lphSession ) )
FUNCTION MAPILogon( ulUIParam AS DWORD , ;
lpszName AS PSZ , ;
lpszPassword AS PSZ , ;
flFlags AS DWORD , ;
ulReserved AS DWORD , ;
lphSession REF DWORD ) AS DWORD PASCAL
LOCAL nResult AS DWORD
IF _MAPIInit()
nResult := DWORD( _CAST , PCALL( sMAPI.pLogon , ;
ulUIParam , ;
PSZ( _CAST , lpszName ) , ;
PSZ( _CAST , lpszPassword ) , ;
flFlags , ;
0 , ;
@lphSession ) )
ENDIF
RETURN nResult
While I'm here, Argument 6 may not be passed with the '@' prefix?
IF _MAPIInit()
nResult := DWORD( _CAST , PCALL( sMAPI.pLogon , ;
ulUIParam , ;
PSZ( _CAST , lpszName ) , ;
PSZ( _CAST , lpszPassword ) , ;
flFlags , ;
0 , ;
@lphSession ) )
ENDIF
I have attached all the MAPI function Phil provided as an attachment.
Thank you!
Jonathan
Converting MAPI function from VO to X# - PCALL typed function pointer
Converting MAPI function from VO to X# - PCALL typed function pointer
- Attachments
-
- MAPIFunctions.txt
- (3.62 KiB) Downloaded 86 times
Converting MAPI function from VO to X# - PCALL typed function pointer
Hi John,
I don't know if newer releases of the X# runtime support PCall, older versions needed PCallNative.
This is my (cleaned) version of MapiLogon:
I have added my version of all the MAPI calls here:
Please beware that this is code that I'm sharing between X# and VO, so I'm using #ifdef statements to keep the compiler happy.
Wolfgang
P.S. MAPI is not supported on 64 bit applications. Microsoft tried to implement it, but failed because it was too badly written in 32 bit. So no MAPI on 64 bit Outlook, you have to use COM/OLE.
I don't know if newer releases of the X# runtime support PCall, older versions needed PCallNative.
This is my (cleaned) version of MapiLogon:
Code: Select all
function MAPILogon( ulUIParam as dword , ;
lpszName as psz , ;
lpszPassword as psz , ;
flFlags as dword , ;
ulReserved as dword , ;
lphSession ref dword ) as dword pascal
local nResult := 0 as dword
if _MAPIInit()
nResult := PCallNative<dword>( sMAPI.pLogon , ;
ulUIParam , ;
lpszName , ;
lpszPassword , ;
flFlags , ;
0 , ;
@lphSession )
endif
return nResult
Wolfgang
P.S. MAPI is not supported on 64 bit applications. Microsoft tried to implement it, but failed because it was too badly written in 32 bit. So no MAPI on 64 bit Outlook, you have to use COM/OLE.
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Converting MAPI function from VO to X# - PCALL typed function pointer
Thank you Wolfgang!
OK, you confirmed my suspicion that it is better to rewrite it now using the Outlook Interop.
Thanks for sharing your cleaned MAPI code - I'll look at that first .
Best regards,
Jonathan
OK, you confirmed my suspicion that it is better to rewrite it now using the Outlook Interop.
Thanks for sharing your cleaned MAPI code - I'll look at that first .
Best regards,
Jonathan
Converting MAPI function from VO to X# - PCALL typed function pointer
John, Wolfgang,
First of all, I totally agree it's better to use PCallNative() instead of PCALL(), and even better totally replace the code with Interop, as this will make it more modern and make it easier to modify/add more features in the future.
But having said that, PCALL() is still supported in X# (for VO compatibility), it's just that the compiler needs to know the signature of the function to call. This can be done by using an intermediate typed LOCAL like this:
First of all, I totally agree it's better to use PCallNative() instead of PCALL(), and even better totally replace the code with Interop, as this will make it more modern and make it easier to modify/add more features in the future.
But having said that, PCALL() is still supported in X# (for VO compatibility), it's just that the compiler needs to know the signature of the function to call. This can be done by using an intermediate typed LOCAL like this:
Code: Select all
LOCAL hFuncTyped AS MAPILogon PTR
hFuncTyped := sMAPI.pLogon
nResult := DWORD( _CAST , PCALL( hFuncTyped, ... // the rest remains the same
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
- ArneOrtlinghaus
- Posts: 414
- Joined: Tue Nov 10, 2015 7:48 am
- Location: Italy
Converting MAPI function from VO to X# - PCALL typed function pointer
Here is our MAPI-Version converted to X#. There is still a small number of users who use this API.
If you need any functions used in this class then you have to ask me.
Arne
If you need any functions used in this class then you have to ask me.
Arne
- Attachments
-
- mapi.txt
- (19.46 KiB) Downloaded 81 times