Tuesday, September 11, 2007

Interoperability Tips

Interoperability :

 [DllImport("MAPI32.DLL", CharSet = CharSet.Ansi)]
        public static extern UInt32 MAPISendMail(IntPtr lhSession, IntPtr ulUIParam,
         MapiMessage lpMessage, UInt32 flFlags, UInt32 ulReserved);

 

if we want to rename the MAPISendMail fn  as SendMail within C# , How can we do it ?

we can do the following.

 

    [DllImport("MAPI32.DLL", EntryPoint = "MAPISendMail", CharSet = CharSet.Ansi)]
        public static extern UInt32 SendMail(IntPtr lhSession, IntPtr ulUIParam,
         MapiMessage lpMessage, UInt32 flFlags, UInt32 ulReserved);

 

 EntryPoint = "MAPISendMail"  // specified function address is obtained from the DLL


So In our C# application we can simply call

 SendMail( ...)
 
 
Literally what will happen is the address of the MAPISendMail() fn is assigned to the SendMail() fn.
 
So if we call the SendMail() fn from C#, it will in turn calls the MAPISendMail() functionality from MAPI32.dll
 
 

0 Comments:

Post a Comment

<< Home