PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
GetAttachmentTable and DLLIMPORT
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
GetAttachmentTable and DLLIMPORT
![]() |
GetAttachmentTable and DLLIMPORT |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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@discussions.microsoft.com> wrote in message news:2F8038E9-0B1A-44D1-BB7A-C2980C8BC61E@microsoft.com... > 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 > > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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: > 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@discussions.microsoft.com> wrote in message > news:2F8038E9-0B1A-44D1-BB7A-C2980C8BC61E@microsoft.com... > > 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 > > > > > > > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Hi
My apologies i got totally wrong end of the stick. I hadnt doen the wrapper correctly thanks "Chris Tacke, MVP" wrote: > 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@discussions.microsoft.com> wrote in message > news:2F8038E9-0B1A-44D1-BB7A-C2980C8BC61E@microsoft.com... > > 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 > > > > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

