Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Converting MAPI function from VO to X# - PCALL typed function pointer 28 Sep 2022 22:43 #24060

  • jonhn
  • jonhn's Avatar
  • Topic Author


  • Posts: 84
  • 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

    Please Log in or Create an account to join the conversation.

    Last edit: by jonhn.

    Converting MAPI function from VO to X# - PCALL typed function pointer 29 Sep 2022 05:17 #24061

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • 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:
    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
    I have added my version of all the MAPI calls here:

    File Attachment:

    File Name: MAPI.Functions.zip
    File Size:2 KB

    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.
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it
    Attachments:

    Please Log in or Create an account to join the conversation.

    Converting MAPI function from VO to X# - PCALL typed function pointer 29 Sep 2022 05:26 #24062

    • jonhn
    • jonhn's Avatar
    • Topic Author


  • Posts: 84
  • 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

    Please Log in or Create an account to join the conversation.

    Converting MAPI function from VO to X# - PCALL typed function pointer 29 Sep 2022 10:25 #24066

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • 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:

    LOCAL hFuncTyped AS MAPILogon PTR
    hFuncTyped := sMAPI.pLogon
    	
    nResult := DWORD( _CAST , PCALL( hFuncTyped, ... // the rest remains the same
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    Converting MAPI function from VO to X# - PCALL typed function pointer 30 Sep 2022 14:50 #24077

    • ArneOrtlinghaus
    • ArneOrtlinghaus's Avatar


  • Posts: 348
  • 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
    Attachments:

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1