mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
First code analysis changes, this "should" make Greenshot more stable and implement things as is supposed.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2481 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
3f4d93f2b6
commit
a394904aa3
64 changed files with 514 additions and 343 deletions
|
@ -606,56 +606,6 @@ namespace Greenshot.Interop.Office {
|
|||
public long filler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use MAPI32.DLL "HrGetOneProp" from managed code
|
||||
/// </summary>
|
||||
/// <param name="attachment"></param>
|
||||
/// <param name="proptag"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetMAPIProperty(Attachment attachment, PropTags proptag) {
|
||||
object mapiObject = attachment.MAPIOBJECT;
|
||||
if (mapiObject == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
string sProperty = "";
|
||||
IntPtr pPropValue = IntPtr.Zero;
|
||||
|
||||
IntPtr IUnknown = IntPtr.Zero;
|
||||
IntPtr IMAPIProperty = IntPtr.Zero;
|
||||
|
||||
try {
|
||||
MAPIInitialize(IntPtr.Zero);
|
||||
IUnknown = Marshal.GetIUnknownForObject(mapiObject);
|
||||
Guid guidMAPIProp = new Guid(IID_IMAPIProp);
|
||||
if (Marshal.QueryInterface(IUnknown, ref guidMAPIProp, out IMAPIProperty) != 0) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
HrGetOneProp(IMAPIProperty, (uint)proptag, out pPropValue);
|
||||
if (pPropValue == IntPtr.Zero) {
|
||||
return "";
|
||||
}
|
||||
SPropValue propValue = (SPropValue)Marshal.PtrToStructure(pPropValue, typeof(SPropValue));
|
||||
sProperty = Marshal.PtrToStringUni(propValue.Value);
|
||||
} catch (System.Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
} finally {
|
||||
if (pPropValue != IntPtr.Zero) {
|
||||
MAPIFreeBuffer(pPropValue);
|
||||
}
|
||||
if (IMAPIProperty != IntPtr.Zero) {
|
||||
Marshal.Release(IMAPIProperty);
|
||||
}
|
||||
if (IUnknown != IntPtr.Zero) {
|
||||
Marshal.Release(IUnknown);
|
||||
}
|
||||
MAPIUninitialize();
|
||||
}
|
||||
return sProperty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to save the changes we just made
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue