Drag-Drop-Set-Property-Item
This commit is contained in:
@ -2,6 +2,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
@ -491,6 +492,30 @@ internal abstract class Property
|
||||
return new(dateTimeOriginal, dateTimes, id, message);
|
||||
}
|
||||
|
||||
internal static PropertyItem GetPropertyItem(ConstructorInfo constructorInfo, int id, short type, string value)
|
||||
{
|
||||
PropertyItem result = (PropertyItem)constructorInfo.Invoke(null);
|
||||
int length;
|
||||
byte[] bytes;
|
||||
if (type == 2)
|
||||
{
|
||||
bytes = GetBytes(value);
|
||||
length = value.Length + 1;
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
bytes = Encoding.Unicode.GetBytes($"{value}\0");
|
||||
length = bytes.Length;
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
result.Id = id;
|
||||
result.Len = length;
|
||||
result.Type = type;
|
||||
result.Value = bytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
internal static DateTime? GetDateTime(string dateTimeFormat, string? value)
|
||||
@ -508,4 +533,13 @@ internal abstract class Property
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static byte[] GetBytes(string value)
|
||||
{
|
||||
byte[] results = new byte[value.Length + 1];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
results[i] = (byte)value[i];
|
||||
results[value.Length] = 0x00;
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user