From: Zahid on
Can you please write the wrapper code here

thanks



Shawri wrote:

HiMy apologies i got totally wrong end of the stick.
21-Apr-08

Hi

My apologies i got totally wrong end of the stick. I hadnt doen the wrapper
correctly

thanks

"Chris Tacke, MVP" wrote:

Previous Posts In This Thread:

On Monday, April 21, 2008 7:29 AM
Shawri wrote:

GetAttachmentTable and DLLIMPORT
Hi

i wonder if someone can help me. Im trying to use the GetAttachmentTable
routine in MAPI.

[DllImport("MAPIlib.dll", EntryPoint = "IMessageGetAttachmentTable")]
private static extern HRESULT pIMessageGetAttachmentTable(IntPtr
msg, ref IntPtr AttachTable);

public IMAPITable GetAttachmentTable()
{
// Call the dll function
IntPtr tablePtr = IntPtr.Zero;
HRESULT hr = pIMessageGetAttachmentTable(this.ptr, ref
tablePtr);
if (hr != HRESULT.S_OK)
throw new Exception("GetAttachmentTable failed: " +
hr.ToString());
return new MAPITable(tablePtr);
}

When i try to run this i get
Can't find an Entry Point 'IMessageGetAttachmentTable' in a PInvoke DLL
'MAPIlib.dll'.

Can anyone help?


Thanks
Neil

On Monday, April 21, 2008 8:11 AM
Chris Tacke, MVP wrote:

Sure, I'd expect that from your code.
Sure, I'd expect that from your code. You are trying to use a function
entry point called "IMessageGetAttachmentTable" and there certainly isn't
such a thing. The method is GetAttachmentTable and it's exposed by the
IMessage interface
(http://msdn2.microsoft.com/en-us/library/ms530463(EXCHG.10).aspx). You
can't just slap the interface/class name together with a function name and
expect to call it.

That's not the only issue, though. You can't just change the name and have
it work either. GetAttachmentTable isn't a direct entry point in a DLL,
which is what P/Invoke requires. It's a method *on an interface*. That
means you need an IMessage instance, and you need to call
GetAttachementTable on that. This *cannot* be done in managed code. You'd
need a native C wrapper that could call the method as your proxy.

Where did you get this definition anyway? It looks suspiciously like it was
desined for that kind of a scenario (calling an already created native shim)
as the first parameter according to the docs is a ULONG flags variable, not
a pointer to itself.

-Chris


"Shawrie" <Shawrie(a)discussions.microsoft.com> wrote in message
news:2F8038E9-0B1A-44D1-BB7A-C2980C8BC61E(a)microsoft.com...

On Monday, April 21, 2008 8:28 AM
Shawri wrote:

Hii thought the call was a bit strange. It is within a c++ wrapper.
Hi

i thought the call was a bit strange. It is within a c++ wrapper. I have
basically based it on some examples i found on the web. I have tried settting
the entry point to GetAttachmentTable but still no luck. Do you know what i
should set the entry point for this method?

thanks for your help

"Chris Tacke, MVP" wrote:

On Monday, April 21, 2008 9:46 AM
Shawri wrote:

HiMy apologies i got totally wrong end of the stick.
Hi

My apologies i got totally wrong end of the stick. I hadnt doen the wrapper
correctly

thanks

"Chris Tacke, MVP" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
..NET Constructor Applied
http://www.eggheadcafe.com/tutorials/aspnet/be09e92f-5773-4cbf-92bd-2efad5224a3f/net-constructor-applied.aspx