porting shell from nuget to local

This commit is contained in:
NaBian 2020-12-06 11:18:36 +08:00
parent d971be8816
commit 035ef17569
164 changed files with 10363 additions and 11 deletions

View File

@ -23,11 +23,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HandyControlDemo_Net_40", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HandyControlDemo_Code", "Shared\HandyControlDemo_Code\HandyControlDemo_Code.csproj", "{D8A4748C-0500-4F63-BC47-3506658C68F7}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.Windows.Shell", "Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.shproj", "{BBE51380-8B21-49FF-9CFC-B29447A40999}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{9a7b52e6-94bb-4e7e-bb6a-7cf6761b79a7}*SharedItemsImports = 5
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{aac11083-faca-405d-9197-5c1212d65656}*SharedItemsImports = 13
Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{bbe51380-8b21-49ff-9cfc-b29447a40999}*SharedItemsImports = 13
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{c4694269-c9b8-45d5-87f8-d0088c532510}*SharedItemsImports = 13
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d8ae88f8-c36b-4d10-a7f9-22ffcfba5231}*SharedItemsImports = 5
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 5
@ -83,6 +87,7 @@ Global
{32204503-2EF0-4681-AE13-AA1FEB6C658A} = {35E3F9C0-8924-4536-BE09-F3761FDBF066}
{D8AE88F8-C36B-4D10-A7F9-22FFCFBA5231} = {35E3F9C0-8924-4536-BE09-F3761FDBF066}
{D8A4748C-0500-4F63-BC47-3506658C68F7} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
{BBE51380-8B21-49FF-9CFC-B29447A40999} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4636382-1A18-4079-A3E7-054DD970F179}

View File

@ -13,11 +13,6 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Net40|AnyCPU' ">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\HandyControl.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.Shell">
<Version>3.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\HandyControl_Shared\Properties\Langs\Lang.Designer.cs">
<Link>Properties\Langs\Lang.Designer.cs</Link>
@ -74,6 +69,7 @@
</Content>
</ItemGroup>
<Import Project="..\..\Shared\HandyControl_Shared\HandyControl_Shared.projitems" Label="Shared" />
<Import Project="..\..\Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems" Label="Shared" />
<ItemGroup>
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\dropper.cur">
<Link>Resources\dropper.cur</Link>

View File

@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
xmlns:themes="clr-namespace:HandyControl.Themes">
<ResourceDictionary.MergedDictionaries>
@ -104,4 +104,4 @@
</Setter>
</Style>
</ResourceDictionary>
</ResourceDictionary>

View File

@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
xmlns:themes="clr-namespace:HandyControl.Themes">
<ResourceDictionary.MergedDictionaries>
@ -241,4 +241,4 @@
</Style.Triggers>
</Style>
</ResourceDictionary>
</ResourceDictionary>

View File

@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:langs="clr-namespace:HandyControl.Properties.Langs" xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:converter="clr-namespace:HandyControl.Tools.Converter" xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:themes="clr-namespace:HandyControl.Themes" xmlns:interactivity="clr-namespace:HandyControl.Interactivity" xmlns:hc="clr-namespace:HandyControl.Controls" xmlns:tools="clr-namespace:HandyControl.Tools" xmlns:shapes="clr-namespace:HandyControl.Expression.Shapes" xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell" xmlns:ex="clr-namespace:HandyControl.Tools.Extension">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:langs="clr-namespace:HandyControl.Properties.Langs" xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:converter="clr-namespace:HandyControl.Tools.Converter" xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:themes="clr-namespace:HandyControl.Themes" xmlns:interactivity="clr-namespace:HandyControl.Interactivity" xmlns:hc="clr-namespace:HandyControl.Controls" xmlns:tools="clr-namespace:HandyControl.Tools" xmlns:shapes="clr-namespace:HandyControl.Expression.Shapes" xmlns:shell="clr-namespace:Microsoft.Windows.Shell" xmlns:ex="clr-namespace:HandyControl.Tools.Extension">
<langs:LangProvider x:Key="Langs" />
<converter:Boolean2BooleanReConverter x:Key="Boolean2BooleanReConverter" />
<converter:Boolean2VisibilityReConverter x:Key="Boolean2VisibilityReConverter" />

View File

@ -12,4 +12,5 @@
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "HandyControl.Data")]
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "HandyControl.Properties.Langs")]
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "HandyControl.Themes")]
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "Microsoft.Windows.Shell")]
[assembly: XmlnsPrefix("https://handyorg.github.io/handycontrol", "hc")]

View File

@ -0,0 +1,13 @@
using System;
namespace Microsoft.Windows.Shell
{
public abstract class JumpItem
{
internal JumpItem()
{
}
public string CustomCategory { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Microsoft.Windows.Shell
{
public enum JumpItemRejectionReason
{
None,
InvalidItem,
NoRegisteredHandler,
RemovedByUser
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace Microsoft.Windows.Shell
{
public sealed class JumpItemsRejectedEventArgs : EventArgs
{
public JumpItemsRejectedEventArgs() : this(null, null)
{
}
public JumpItemsRejectedEventArgs(IList<JumpItem> rejectedItems, IList<JumpItemRejectionReason> reasons)
{
if ((rejectedItems == null && reasons != null) || (reasons == null && rejectedItems != null) || (rejectedItems != null && reasons != null && rejectedItems.Count != reasons.Count))
{
throw new ArgumentException("The counts of rejected items doesn't match the count of reasons.");
}
if (rejectedItems != null)
{
this.RejectedItems = new List<JumpItem>(rejectedItems).AsReadOnly();
this.RejectionReasons = new List<JumpItemRejectionReason>(reasons).AsReadOnly();
return;
}
this.RejectedItems = new List<JumpItem>().AsReadOnly();
this.RejectionReasons = new List<JumpItemRejectionReason>().AsReadOnly();
}
public IList<JumpItem> RejectedItems { get; private set; }
public IList<JumpItemRejectionReason> RejectionReasons { get; private set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
namespace Microsoft.Windows.Shell
{
public sealed class JumpItemsRemovedEventArgs : EventArgs
{
public JumpItemsRemovedEventArgs() : this(null)
{
}
public JumpItemsRemovedEventArgs(IList<JumpItem> removedItems)
{
if (removedItems != null)
{
this.RemovedItems = new List<JumpItem>(removedItems).AsReadOnly();
return;
}
this.RemovedItems = new List<JumpItem>().AsReadOnly();
}
public IList<JumpItem> RemovedItems { get; private set; }
}
}

View File

@ -0,0 +1,750 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Markup;
using Standard;
namespace Microsoft.Windows.Shell
{
[ContentProperty("JumpItems")]
public sealed class JumpList : ISupportInitialize
{
public static void AddToRecentCategory(string itemPath)
{
Verify.FileExists(itemPath, "itemPath");
itemPath = Path.GetFullPath(itemPath);
NativeMethods.SHAddToRecentDocs(itemPath);
}
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public static void AddToRecentCategory(JumpPath jumpPath)
{
Verify.IsNotNull<JumpPath>(jumpPath, "jumpPath");
JumpList.AddToRecentCategory(jumpPath.Path);
}
public static void AddToRecentCategory(JumpTask jumpTask)
{
Verify.IsNotNull<JumpTask>(jumpTask, "jumpTask");
if (Utility.IsOSWindows7OrNewer)
{
IShellLinkW shellLinkW = JumpList.CreateLinkFromJumpTask(jumpTask, false);
try
{
if (shellLinkW != null)
{
NativeMethods.SHAddToRecentDocs(shellLinkW);
}
}
finally
{
Utility.SafeRelease<IShellLinkW>(ref shellLinkW);
}
}
}
public static void SetJumpList(Application application, JumpList value)
{
Verify.IsNotNull<Application>(application, "application");
lock (JumpList.s_lock)
{
JumpList jumpList;
if (JumpList.s_applicationMap.TryGetValue(application, out jumpList) && jumpList != null)
{
jumpList._application = null;
}
JumpList.s_applicationMap[application] = value;
if (value != null)
{
value._application = application;
}
}
if (value != null)
{
value.ApplyFromApplication();
}
}
public static JumpList GetJumpList(Application application)
{
Verify.IsNotNull<Application>(application, "application");
JumpList result;
JumpList.s_applicationMap.TryGetValue(application, out result);
return result;
}
public JumpList() : this(null, false, false)
{
this._initializing = null;
}
public JumpList(IEnumerable<JumpItem> items, bool showFrequent, bool showRecent)
{
if (items != null)
{
this._jumpItems = new List<JumpItem>(items);
}
else
{
this._jumpItems = new List<JumpItem>();
}
this.ShowFrequentCategory = showFrequent;
this.ShowRecentCategory = showRecent;
this._initializing = new bool?(false);
}
public bool ShowFrequentCategory { get; set; }
public bool ShowRecentCategory { get; set; }
[SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
public List<JumpItem> JumpItems
{
get
{
return this._jumpItems;
}
}
private bool _IsUnmodified
{
get
{
return this._initializing == null && this.JumpItems.Count == 0 && !this.ShowRecentCategory && !this.ShowFrequentCategory;
}
}
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "BeginInit")]
public void BeginInit()
{
if (!this._IsUnmodified)
{
throw new InvalidOperationException("Calls to BeginInit cannot be nested.");
}
this._initializing = new bool?(true);
}
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EndInit")]
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "BeginInit")]
public void EndInit()
{
if (this._initializing != true)
{
throw new NotSupportedException("Can't call EndInit without first calling BeginInit.");
}
this._initializing = new bool?(false);
this.ApplyFromApplication();
}
private static string _RuntimeId
{
get
{
string result;
HRESULT hrLeft = NativeMethods.GetCurrentProcessExplicitAppUserModelID(out result);
if (hrLeft == HRESULT.E_FAIL)
{
hrLeft = HRESULT.S_OK;
result = null;
}
hrLeft.ThrowIfFailed();
return result;
}
}
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "JumpList")]
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EndInit")]
public void Apply()
{
if (this._initializing == true)
{
throw new InvalidOperationException("The JumpList can't be applied until EndInit has been called.");
}
this._initializing = new bool?(false);
this._ApplyList();
}
private void ApplyFromApplication()
{
if (this._initializing != true && !this._IsUnmodified)
{
this._initializing = new bool?(false);
}
if (this._application == Application.Current && this._initializing == false)
{
this._ApplyList();
}
}
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.Verify.IsApartmentState(System.Threading.ApartmentState,System.String)")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "JumpLists")]
private void _ApplyList()
{
Verify.IsApartmentState(ApartmentState.STA, "JumpLists can only be effected on STA threads.");
if (!Utility.IsOSWindows7OrNewer)
{
this.RejectEverything();
return;
}
List<JumpItem> jumpItems;
List<JumpList._RejectedJumpItemPair> list;
List<JumpList._ShellObjectPair> list2;
try
{
this._BuildShellLists(out jumpItems, out list, out list2);
}
catch (Exception)
{
this.RejectEverything();
return;
}
this._jumpItems = jumpItems;
EventHandler<JumpItemsRejectedEventArgs> jumpItemsRejected = this.JumpItemsRejected;
EventHandler<JumpItemsRemovedEventArgs> jumpItemsRemovedByUser = this.JumpItemsRemovedByUser;
if (list.Count > 0 && jumpItemsRejected != null)
{
List<JumpItem> list3 = new List<JumpItem>(list.Count);
List<JumpItemRejectionReason> list4 = new List<JumpItemRejectionReason>(list.Count);
foreach (JumpList._RejectedJumpItemPair rejectedJumpItemPair in list)
{
list3.Add(rejectedJumpItemPair.JumpItem);
list4.Add(rejectedJumpItemPair.Reason);
}
jumpItemsRejected(this, new JumpItemsRejectedEventArgs(list3, list4));
}
if (list2.Count > 0 && jumpItemsRemovedByUser != null)
{
List<JumpItem> list5 = new List<JumpItem>(list2.Count);
foreach (JumpList._ShellObjectPair shellObjectPair in list2)
{
if (shellObjectPair.JumpItem != null)
{
list5.Add(shellObjectPair.JumpItem);
}
}
if (list5.Count > 0)
{
jumpItemsRemovedByUser(this, new JumpItemsRemovedEventArgs(list5));
}
}
}
private void _BuildShellLists(out List<JumpItem> successList, out List<JumpList._RejectedJumpItemPair> rejectedList, out List<JumpList._ShellObjectPair> removedList)
{
List<List<JumpList._ShellObjectPair>> list = null;
removedList = null;
ICustomDestinationList customDestinationList = CLSID.CoCreateInstance<ICustomDestinationList>("77f10cf0-3db5-4966-b520-b7c54fd35ed6");
try
{
string runtimeId = JumpList._RuntimeId;
if (!string.IsNullOrEmpty(runtimeId))
{
customDestinationList.SetAppID(runtimeId);
}
Guid guid = new Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9");
uint num;
IObjectArray shellObjects = (IObjectArray)customDestinationList.BeginList(out num, ref guid);
removedList = JumpList.GenerateJumpItems(shellObjects);
successList = new List<JumpItem>(this.JumpItems.Count);
rejectedList = new List<JumpList._RejectedJumpItemPair>(this.JumpItems.Count);
list = new List<List<JumpList._ShellObjectPair>>
{
new List<JumpList._ShellObjectPair>()
};
foreach (JumpItem jumpItem in this.JumpItems)
{
if (jumpItem == null)
{
rejectedList.Add(new JumpList._RejectedJumpItemPair
{
JumpItem = jumpItem,
Reason = JumpItemRejectionReason.InvalidItem
});
}
else
{
object obj = null;
try
{
obj = JumpList.GetShellObjectForJumpItem(jumpItem);
if (obj == null)
{
rejectedList.Add(new JumpList._RejectedJumpItemPair
{
Reason = JumpItemRejectionReason.InvalidItem,
JumpItem = jumpItem
});
}
else if (JumpList.ListContainsShellObject(removedList, obj))
{
rejectedList.Add(new JumpList._RejectedJumpItemPair
{
Reason = JumpItemRejectionReason.RemovedByUser,
JumpItem = jumpItem
});
}
else
{
JumpList._ShellObjectPair item = new JumpList._ShellObjectPair
{
JumpItem = jumpItem,
ShellObject = obj
};
if (string.IsNullOrEmpty(jumpItem.CustomCategory))
{
list[0].Add(item);
}
else
{
bool flag = false;
foreach (List<JumpList._ShellObjectPair> list2 in list)
{
if (list2.Count > 0 && list2[0].JumpItem.CustomCategory == jumpItem.CustomCategory)
{
list2.Add(item);
flag = true;
break;
}
}
if (!flag)
{
list.Add(new List<JumpList._ShellObjectPair>
{
item
});
}
}
obj = null;
}
}
finally
{
Utility.SafeRelease<object>(ref obj);
}
}
}
list.Reverse();
if (this.ShowFrequentCategory)
{
customDestinationList.AppendKnownCategory(KDC.FREQUENT);
}
if (this.ShowRecentCategory)
{
customDestinationList.AppendKnownCategory(KDC.RECENT);
}
foreach (List<JumpList._ShellObjectPair> list3 in list)
{
if (list3.Count > 0)
{
string customCategory = list3[0].JumpItem.CustomCategory;
JumpList.AddCategory(customDestinationList, customCategory, list3, successList, rejectedList);
}
}
customDestinationList.CommitList();
successList.Reverse();
}
finally
{
Utility.SafeRelease<ICustomDestinationList>(ref customDestinationList);
if (list != null)
{
foreach (List<JumpList._ShellObjectPair> list4 in list)
{
JumpList._ShellObjectPair.ReleaseShellObjects(list4);
}
}
JumpList._ShellObjectPair.ReleaseShellObjects(removedList);
}
}
private static bool ListContainsShellObject(List<JumpList._ShellObjectPair> removedList, object shellObject)
{
if (removedList.Count == 0)
{
return false;
}
IShellItem shellItem = shellObject as IShellItem;
if (shellItem != null)
{
foreach (JumpList._ShellObjectPair shellObjectPair in removedList)
{
IShellItem shellItem2 = shellObjectPair.ShellObject as IShellItem;
if (shellItem2 != null && shellItem.Compare(shellItem2, (SICHINT)805306368u) == 0)
{
return true;
}
}
return false;
}
IShellLinkW shellLinkW = shellObject as IShellLinkW;
if (shellLinkW != null)
{
foreach (JumpList._ShellObjectPair shellObjectPair2 in removedList)
{
IShellLinkW shellLinkW2 = shellObjectPair2.ShellObject as IShellLinkW;
if (shellLinkW2 != null)
{
string a = JumpList.ShellLinkToString(shellLinkW2);
string b = JumpList.ShellLinkToString(shellLinkW);
if (a == b)
{
return true;
}
}
}
return false;
}
return false;
}
private static object GetShellObjectForJumpItem(JumpItem jumpItem)
{
JumpPath jumpPath = jumpItem as JumpPath;
JumpTask jumpTask = jumpItem as JumpTask;
if (jumpPath != null)
{
return JumpList.CreateItemFromJumpPath(jumpPath);
}
if (jumpTask != null)
{
return JumpList.CreateLinkFromJumpTask(jumpTask, true);
}
return null;
}
private static List<JumpList._ShellObjectPair> GenerateJumpItems(IObjectArray shellObjects)
{
List<JumpList._ShellObjectPair> list = new List<JumpList._ShellObjectPair>();
Guid guid = new Guid("00000000-0000-0000-C000-000000000046");
uint count = shellObjects.GetCount();
for (uint num = 0u; num < count; num += 1u)
{
object at = shellObjects.GetAt(num, ref guid);
JumpItem jumpItem = null;
try
{
jumpItem = JumpList.GetJumpItemForShellObject(at);
}
catch (Exception ex)
{
if (ex is NullReferenceException || ex is SEHException)
{
throw;
}
}
list.Add(new JumpList._ShellObjectPair
{
ShellObject = at,
JumpItem = jumpItem
});
}
return list;
}
private static void AddCategory(ICustomDestinationList cdl, string category, List<JumpList._ShellObjectPair> jumpItems, List<JumpItem> successList, List<JumpList._RejectedJumpItemPair> rejectionList)
{
JumpList.AddCategory(cdl, category, jumpItems, successList, rejectionList, true);
}
private static void AddCategory(ICustomDestinationList cdl, string category, List<JumpList._ShellObjectPair> jumpItems, List<JumpItem> successList, List<JumpList._RejectedJumpItemPair> rejectionList, bool isHeterogenous)
{
IObjectCollection objectCollection = (IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("2d3468c1-36a7-43b6-ac24-d3f02fd9607a")));
foreach (JumpList._ShellObjectPair shellObjectPair in jumpItems)
{
objectCollection.AddObject(shellObjectPair.ShellObject);
}
HRESULT hrLeft;
if (string.IsNullOrEmpty(category))
{
hrLeft = cdl.AddUserTasks(objectCollection);
}
else
{
hrLeft = cdl.AppendCategory(category, objectCollection);
}
if (hrLeft.Succeeded)
{
int num = jumpItems.Count;
while (--num >= 0)
{
successList.Add(jumpItems[num].JumpItem);
}
return;
}
if (isHeterogenous && hrLeft == HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER)
{
Utility.SafeRelease<IObjectCollection>(ref objectCollection);
List<JumpList._ShellObjectPair> list = new List<JumpList._ShellObjectPair>();
foreach (JumpList._ShellObjectPair shellObjectPair2 in jumpItems)
{
if (shellObjectPair2.JumpItem is JumpPath)
{
rejectionList.Add(new JumpList._RejectedJumpItemPair
{
JumpItem = shellObjectPair2.JumpItem,
Reason = JumpItemRejectionReason.NoRegisteredHandler
});
}
else
{
list.Add(shellObjectPair2);
}
}
if (list.Count > 0)
{
JumpList.AddCategory(cdl, category, list, successList, rejectionList, false);
return;
}
}
else
{
foreach (JumpList._ShellObjectPair shellObjectPair3 in jumpItems)
{
rejectionList.Add(new JumpList._RejectedJumpItemPair
{
JumpItem = shellObjectPair3.JumpItem,
Reason = JumpItemRejectionReason.InvalidItem
});
}
}
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowSeparators)
{
if (string.IsNullOrEmpty(jumpTask.Title) && (!allowSeparators || !string.IsNullOrEmpty(jumpTask.CustomCategory)))
{
return null;
}
IShellLinkW shellLinkW = (IShellLinkW)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("00021401-0000-0000-C000-000000000046")));
IShellLinkW result;
try
{
string path = JumpList._FullName;
if (!string.IsNullOrEmpty(jumpTask.ApplicationPath))
{
path = jumpTask.ApplicationPath;
}
shellLinkW.SetPath(path);
if (!string.IsNullOrEmpty(jumpTask.WorkingDirectory))
{
shellLinkW.SetWorkingDirectory(jumpTask.WorkingDirectory);
}
if (!string.IsNullOrEmpty(jumpTask.Arguments))
{
shellLinkW.SetArguments(jumpTask.Arguments);
}
if (jumpTask.IconResourceIndex != -1)
{
string pszIconPath = JumpList._FullName;
if (!string.IsNullOrEmpty(jumpTask.IconResourcePath))
{
if ((long)jumpTask.IconResourcePath.Length >= 260L)
{
return null;
}
pszIconPath = jumpTask.IconResourcePath;
}
shellLinkW.SetIconLocation(pszIconPath, jumpTask.IconResourceIndex);
}
if (!string.IsNullOrEmpty(jumpTask.Description))
{
shellLinkW.SetDescription(jumpTask.Description);
}
IPropertyStore propertyStore = (IPropertyStore)shellLinkW;
using (PROPVARIANT propvariant = new PROPVARIANT())
{
PKEY pkey = default(PKEY);
if (!string.IsNullOrEmpty(jumpTask.Title))
{
propvariant.SetValue(jumpTask.Title);
pkey = PKEY.Title;
}
else
{
propvariant.SetValue(true);
pkey = PKEY.AppUserModel_IsDestListSeparator;
}
propertyStore.SetValue(ref pkey, propvariant);
}
propertyStore.Commit();
IShellLinkW shellLinkW2 = shellLinkW;
shellLinkW = null;
result = shellLinkW2;
}
catch (Exception)
{
result = null;
}
finally
{
Utility.SafeRelease<IShellLinkW>(ref shellLinkW);
}
return result;
}
private static IShellItem2 GetShellItemForPath(string path)
{
if (string.IsNullOrEmpty(path))
{
return null;
}
Guid guid = new Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93");
object obj;
HRESULT hrLeft = NativeMethods.SHCreateItemFromParsingName(path, null, ref guid, out obj);
if (hrLeft == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || hrLeft == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND)
{
hrLeft = HRESULT.S_OK;
obj = null;
}
hrLeft.ThrowIfFailed();
return (IShellItem2)obj;
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
private static IShellItem2 CreateItemFromJumpPath(JumpPath jumpPath)
{
try
{
return JumpList.GetShellItemForPath(Path.GetFullPath(jumpPath.Path));
}
catch (Exception)
{
}
return null;
}
private static JumpItem GetJumpItemForShellObject(object shellObject)
{
IShellItem2 shellItem = shellObject as IShellItem2;
IShellLinkW shellLinkW = shellObject as IShellLinkW;
if (shellItem != null)
{
return new JumpPath
{
Path = shellItem.GetDisplayName((SIGDN)2147647488u)
};
}
if (shellLinkW != null)
{
StringBuilder stringBuilder = new StringBuilder(260);
shellLinkW.GetPath(stringBuilder, stringBuilder.Capacity, null, SLGP.RAWPATH);
StringBuilder stringBuilder2 = new StringBuilder(1024);
shellLinkW.GetArguments(stringBuilder2, stringBuilder2.Capacity);
StringBuilder stringBuilder3 = new StringBuilder(1024);
shellLinkW.GetDescription(stringBuilder3, stringBuilder3.Capacity);
StringBuilder stringBuilder4 = new StringBuilder(260);
int iconResourceIndex;
shellLinkW.GetIconLocation(stringBuilder4, stringBuilder4.Capacity, out iconResourceIndex);
StringBuilder stringBuilder5 = new StringBuilder(260);
shellLinkW.GetWorkingDirectory(stringBuilder5, stringBuilder5.Capacity);
JumpTask jumpTask = new JumpTask
{
ApplicationPath = stringBuilder.ToString(),
Arguments = stringBuilder2.ToString(),
Description = stringBuilder3.ToString(),
IconResourceIndex = iconResourceIndex,
IconResourcePath = stringBuilder4.ToString(),
WorkingDirectory = stringBuilder5.ToString()
};
using (PROPVARIANT propvariant = new PROPVARIANT())
{
IPropertyStore propertyStore = (IPropertyStore)shellLinkW;
PKEY title = PKEY.Title;
propertyStore.GetValue(ref title, propvariant);
jumpTask.Title = (propvariant.GetValue() ?? "");
}
return jumpTask;
}
return null;
}
private static string ShellLinkToString(IShellLinkW shellLink)
{
StringBuilder stringBuilder = new StringBuilder(260);
shellLink.GetPath(stringBuilder, stringBuilder.Capacity, null, SLGP.RAWPATH);
string text = null;
using (PROPVARIANT propvariant = new PROPVARIANT())
{
IPropertyStore propertyStore = (IPropertyStore)shellLink;
PKEY title = PKEY.Title;
propertyStore.GetValue(ref title, propvariant);
text = (propvariant.GetValue() ?? "");
}
StringBuilder stringBuilder2 = new StringBuilder(1024);
shellLink.GetArguments(stringBuilder2, stringBuilder2.Capacity);
return stringBuilder.ToString().ToUpperInvariant() + text.ToUpperInvariant() + stringBuilder2.ToString();
}
private void RejectEverything()
{
EventHandler<JumpItemsRejectedEventArgs> jumpItemsRejected = this.JumpItemsRejected;
if (jumpItemsRejected == null)
{
this._jumpItems.Clear();
return;
}
if (this._jumpItems.Count > 0)
{
List<JumpItemRejectionReason> list = new List<JumpItemRejectionReason>(this.JumpItems.Count);
for (int i = 0; i < this.JumpItems.Count; i++)
{
list.Add(JumpItemRejectionReason.InvalidItem);
}
JumpItemsRejectedEventArgs e = new JumpItemsRejectedEventArgs(this.JumpItems, list);
this._jumpItems.Clear();
jumpItemsRejected(this, e);
}
}
public event EventHandler<JumpItemsRejectedEventArgs> JumpItemsRejected;
public event EventHandler<JumpItemsRemovedEventArgs> JumpItemsRemovedByUser;
private static readonly object s_lock = new object();
private static readonly Dictionary<Application, JumpList> s_applicationMap = new Dictionary<Application, JumpList>();
private Application _application;
private bool? _initializing;
private List<JumpItem> _jumpItems;
private static readonly string _FullName = NativeMethods.GetModuleFileName(IntPtr.Zero);
private class _RejectedJumpItemPair
{
public JumpItem JumpItem { get; set; }
public JumpItemRejectionReason Reason { get; set; }
}
private class _ShellObjectPair
{
public JumpItem JumpItem { get; set; }
public object ShellObject { get; set; }
public static void ReleaseShellObjects(List<JumpList._ShellObjectPair> list)
{
if (list != null)
{
foreach (JumpList._ShellObjectPair shellObjectPair in list)
{
object shellObject = shellObjectPair.ShellObject;
shellObjectPair.ShellObject = null;
Utility.SafeRelease<object>(ref shellObject);
}
}
}
}
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace Microsoft.Windows.Shell
{
public class JumpPath : JumpItem
{
public string Path { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
namespace Microsoft.Windows.Shell
{
public class JumpTask : JumpItem
{
public string Title { get; set; }
public string Description { get; set; }
public string ApplicationPath { get; set; }
public string Arguments { get; set; }
public string WorkingDirectory { get; set; }
public string IconResourcePath { get; set; }
public int IconResourceIndex { get; set; }
}
}

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>bbe51380-8b21-49ff-9cfc-b29447a40999</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>SharedProject1</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)JumpItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpItemRejectionReason.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpItemsRejectedEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpItemsRemovedEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpPath.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpTask.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\AC.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\APPDOCLISTTYPE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Assert.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\BI.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\BITMAPINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\BITMAPINFOHEADER.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\BLENDFUNCTION.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\CHANGEFILTERSTRUCT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\CLSID.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\CombineRgnResult.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\CREATESTRUCT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\CS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DeviceCap.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DOGIF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DoubleUtilities.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DpiHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DWMFLIP3D.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DWMNCRP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DWMWA.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DWM_SIT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\DWM_TIMING_INFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ErrorModes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Facility.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\FO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\FOF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\GCLP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\GPS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\GWL.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\HCF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\HIGHCONTRAST.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\HRESULT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\HT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IApplicationDestinations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IApplicationDocumentLists.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ICustomDestinationList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IEnumIDList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IEnumObjects.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IID.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\INPUT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\INPUT_TYPE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IObjectArray.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IObjectCollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IObjectWithAppUserModelId.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IObjectWithProgId.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IPropertyStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IShellFolder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IShellItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IShellItem2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IShellItemArray.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\IShellLinkW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ITaskbarList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ITaskbarList2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ITaskbarList3.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ITaskbarList4.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\KDC.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\LOGFONT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ManagedIStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MARGINS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MessageHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MessageWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MINMAXINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MONITORINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MOUSEEVENTF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MOUSEINPUT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MSGFLT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\MSGFLTINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NativeMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NIF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NIIF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NIM.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NONCLIENTMETRICS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\NOTIFYICONDATA.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\OLECMDEXECOPT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\OLECMDF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\OLECMDID.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\PKEY.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\POINT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\PROPVARIANT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\READYSTATE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\RECT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\RefPOINT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\RefRECT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\RGBQUAD.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\RGN.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SafeConnectionPointCookie.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SafeDC.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SafeFindHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SafeGdiplusStartupToken.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SafeHBITMAP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SC.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SFGAO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHARD.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHARDAPPIDINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHARDAPPIDINFOIDLIST.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHARDAPPIDINFOLINK.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHCONTF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHFILEOPSTRUCT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SHGDN.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SIATTRIBFLAGS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SICHINT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SIGDN.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SIZE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SLGP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SM.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SPI.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SPIF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\StartupInput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\StartupOutput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\STATE_SYSTEM.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Status.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\StockObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\STPF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\STR_GPS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\SWP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\TBPF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\THB.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\THBF.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\THUMBBUTTON.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\TITLEBARINFO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\TITLEBARINFOEX.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\ULW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\UNSIGNED_RATIO.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Utility.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Verify.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Win32Error.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\Win32Value.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WIN32_FIND_DATAW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WINDOWPLACEMENT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WINDOWPOS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WINDOWTHEMEATTRIBUTETYPE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WM.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WNDCLASSEX.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WndProc.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WndProcHook.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WS_EX.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WTA_OPTIONS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WTNCA.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Standard\WVR.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SystemCommands.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SystemParameters2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TaskbarItemInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TaskbarItemProgressState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ThumbButtonInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ThumbButtonInfoCollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WindowChrome.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WindowChromeWorker.cs" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>bbe51380-8b21-49ff-9cfc-b29447a40999</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Microsoft.Windows.Shell.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@ -0,0 +1,10 @@
using System;
namespace Standard
{
internal enum AC : byte
{
SRC_OVER,
SRC_ALPHA
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Standard
{
internal enum APPDOCLISTTYPE
{
ADLT_RECENT,
ADLT_FREQUENT
}
}

View File

@ -0,0 +1,233 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows;
namespace Standard
{
internal static class Assert
{
private static void _Break()
{
Debugger.Break();
}
[Conditional("DEBUG")]
public static void Evaluate(Assert.EvaluateFunction argument)
{
argument();
}
[Obsolete("Use Assert.AreEqual instead of Assert.Equals", false)]
[Conditional("DEBUG")]
public static void Equals<T>(T expected, T actual)
{
}
[Conditional("DEBUG")]
public static void AreEqual<T>(T expected, T actual)
{
if (expected == null)
{
if (actual != null && !actual.Equals(expected))
{
Assert._Break();
return;
}
}
else if (!expected.Equals(actual))
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void AreNotEqual<T>(T notExpected, T actual)
{
if (notExpected == null)
{
if (actual == null || actual.Equals(notExpected))
{
Assert._Break();
return;
}
}
else if (notExpected.Equals(actual))
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void Implies(bool condition, bool result)
{
if (condition && !result)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void Implies(bool condition, Assert.ImplicationFunction result)
{
if (condition && !result())
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsNeitherNullNorEmpty(string value)
{
}
[Conditional("DEBUG")]
public static void IsNeitherNullNorWhitespace(string value)
{
if (string.IsNullOrEmpty(value))
{
Assert._Break();
}
if (value.Trim().Length == 0)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsNotNull<T>(T value) where T : class
{
if (value == null)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsDefault<T>(T value) where T : struct
{
value.Equals(default(T));
}
[Conditional("DEBUG")]
public static void IsNotDefault<T>(T value) where T : struct
{
value.Equals(default(T));
}
[Conditional("DEBUG")]
public static void IsFalse(bool condition)
{
if (condition)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsFalse(bool condition, string message)
{
if (condition)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition)
{
if (!condition)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsTrue(bool condition, string message)
{
if (!condition)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void Fail()
{
Assert._Break();
}
[Conditional("DEBUG")]
public static void Fail(string message)
{
Assert._Break();
}
[Conditional("DEBUG")]
public static void IsNull<T>(T item) where T : class
{
if (item != null)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void BoundedDoubleInc(double lowerBoundInclusive, double value, double upperBoundInclusive)
{
if (value < lowerBoundInclusive || value > upperBoundInclusive)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void BoundedInteger(int lowerBoundInclusive, int value, int upperBoundExclusive)
{
if (value < lowerBoundInclusive || value >= upperBoundExclusive)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsApartmentState(ApartmentState expectedState)
{
if (Thread.CurrentThread.GetApartmentState() != expectedState)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void NullableIsNotNull<T>(T? value) where T : struct
{
if (value == null)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void NullableIsNull<T>(T? value) where T : struct
{
if (value != null)
{
Assert._Break();
}
}
[Conditional("DEBUG")]
public static void IsNotOnMainThread()
{
if (Application.Current.Dispatcher.CheckAccess())
{
Assert._Break();
}
}
public delegate void EvaluateFunction();
public delegate bool ImplicationFunction();
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace Standard
{
internal enum BI
{
RGB
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal struct BITMAPINFO
{
public BITMAPINFOHEADER bmiHeader;
public RGBQUAD bmiColors;
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential, Pack = 2)]
internal struct BITMAPINFOHEADER
{
public int biSize;
public int biWidth;
public int biHeight;
public short biPlanes;
public short biBitCount;
public BI biCompression;
public int biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public int biClrUsed;
public int biClrImportant;
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Standard
{
internal struct BLENDFUNCTION
{
public AC BlendOp;
public byte BlendFlags;
public byte SourceConstantAlpha;
public AC AlphaFormat;
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal struct CHANGEFILTERSTRUCT
{
public uint cbSize;
public MSGFLTINFO ExtStatus;
}
}

View File

@ -0,0 +1,24 @@
using System;
namespace Standard
{
internal static class CLSID
{
public static T CoCreateInstance<T>(string clsid)
{
return (T)((object)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(clsid))));
}
public const string TaskbarList = "56FDF344-FD6D-11d0-958A-006097C9A090";
public const string EnumerableObjectCollection = "2d3468c1-36a7-43b6-ac24-d3f02fd9607a";
public const string ShellLink = "00021401-0000-0000-C000-000000000046";
public const string DestinationList = "77f10cf0-3db5-4966-b520-b7c54fd35ed6";
public const string ApplicationDestinations = "86c14003-4d6b-4ef3-a7b4-0506663b2e68";
public const string ApplicationDocumentLists = "86bec222-30f2-47e0-9f25-60d11cd75c28";
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct CREATESTRUCT
{
public IntPtr lpCreateParams;
public IntPtr hInstance;
public IntPtr hMenu;
public IntPtr hwndParent;
public int cy;
public int cx;
public int y;
public int x;
public WS style;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszName;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszClass;
public WS_EX dwExStyle;
}
}

View File

@ -0,0 +1,22 @@
using System;
namespace Standard
{
[Flags]
internal enum CS : uint
{
VREDRAW = 1u,
HREDRAW = 2u,
DBLCLKS = 8u,
OWNDC = 32u,
CLASSDC = 64u,
PARENTDC = 128u,
NOCLOSE = 512u,
SAVEBITS = 2048u,
BYTEALIGNCLIENT = 4096u,
BYTEALIGNWINDOW = 8192u,
GLOBALCLASS = 16384u,
IME = 65536u,
DROPSHADOW = 131072u
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Standard
{
internal enum CombineRgnResult
{
ERROR,
NULLREGION,
SIMPLEREGION,
COMPLEXREGION
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Standard
{
internal enum DOGIF
{
DEFAULT,
TRAVERSE_LINK,
NO_HDROP,
NO_URL = 4,
ONLY_IF_ONE = 8
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal enum DWMFLIP3D
{
DEFAULT,
EXCLUDEBELOW,
EXCLUDEABOVE
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal enum DWMNCRP
{
USEWINDOWSTYLE,
DISABLED,
ENABLED
}
}

View File

@ -0,0 +1,20 @@
using System;
namespace Standard
{
internal enum DWMWA
{
NCRENDERING_ENABLED = 1,
NCRENDERING_POLICY,
TRANSITIONS_FORCEDISABLED,
ALLOW_NCPAINT,
CAPTION_BUTTON_BOUNDS,
NONCLIENT_RTL_LAYOUT,
FORCE_ICONIC_REPRESENTATION,
FLIP3D_POLICY,
EXTENDED_FRAME_BOUNDS,
HAS_ICONIC_BITMAP,
DISALLOW_PEEK,
EXCLUDED_FROM_PEEK
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Standard
{
internal enum DWM_SIT
{
None,
DISPLAYFRAME
}
}

View File

@ -0,0 +1,89 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct DWM_TIMING_INFO
{
public int cbSize;
public UNSIGNED_RATIO rateRefresh;
public ulong qpcRefreshPeriod;
public UNSIGNED_RATIO rateCompose;
public ulong qpcVBlank;
public ulong cRefresh;
public uint cDXRefresh;
public ulong qpcCompose;
public ulong cFrame;
public uint cDXPresent;
public ulong cRefreshFrame;
public ulong cFrameSubmitted;
public uint cDXPresentSubmitted;
public ulong cFrameConfirmed;
public uint cDXPresentConfirmed;
public ulong cRefreshConfirmed;
public uint cDXRefreshConfirmed;
public ulong cFramesLate;
public uint cFramesOutstanding;
public ulong cFrameDisplayed;
public ulong qpcFrameDisplayed;
public ulong cRefreshFrameDisplayed;
public ulong cFrameComplete;
public ulong qpcFrameComplete;
public ulong cFramePending;
public ulong qpcFramePending;
public ulong cFramesDisplayed;
public ulong cFramesComplete;
public ulong cFramesPending;
public ulong cFramesAvailable;
public ulong cFramesDropped;
public ulong cFramesMissed;
public ulong cRefreshNextDisplayed;
public ulong cRefreshNextPresented;
public ulong cRefreshesDisplayed;
public ulong cRefreshesPresented;
public ulong cRefreshStarted;
public ulong cPixelsReceived;
public ulong cPixelsDrawn;
public ulong cBuffersEmpty;
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Standard
{
internal enum DeviceCap
{
BITSPIXEL = 12,
PLANES = 14,
LOGPIXELSX = 88,
LOGPIXELSY = 90
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Standard
{
internal static class DoubleUtilities
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool AreClose(double value1, double value2)
{
if (value1 == value2)
{
return true;
}
double num = value1 - value2;
return num < 1.53E-06 && num > -1.53E-06;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool LessThan(double value1, double value2)
{
return value1 < value2 && !DoubleUtilities.AreClose(value1, value2);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool GreaterThan(double value1, double value2)
{
return value1 > value2 && !DoubleUtilities.AreClose(value1, value2);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool LessThanOrClose(double value1, double value2)
{
return value1 < value2 || DoubleUtilities.AreClose(value1, value2);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool GreaterThanOrClose(double value1, double value2)
{
return value1 > value2 || DoubleUtilities.AreClose(value1, value2);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool IsFinite(double value)
{
return !double.IsNaN(value) && !double.IsInfinity(value);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool IsValidSize(double value)
{
return DoubleUtilities.IsFinite(value) && DoubleUtilities.GreaterThanOrClose(value, 0.0);
}
private const double Epsilon = 1.53E-06;
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Media;
namespace Standard
{
internal static class DpiHelper
{
[SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static DpiHelper()
{
using (SafeDC desktop = SafeDC.GetDesktop())
{
int deviceCaps = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX);
int deviceCaps2 = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY);
DpiHelper._transformToDip = Matrix.Identity;
DpiHelper._transformToDip.Scale(96.0 / (double)deviceCaps, 96.0 / (double)deviceCaps2);
DpiHelper._transformToDevice = Matrix.Identity;
DpiHelper._transformToDevice.Scale((double)deviceCaps / 96.0, (double)deviceCaps2 / 96.0);
}
}
public static Point LogicalPixelsToDevice(Point logicalPoint)
{
return DpiHelper._transformToDevice.Transform(logicalPoint);
}
public static Point DevicePixelsToLogical(Point devicePoint)
{
return DpiHelper._transformToDip.Transform(devicePoint);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static Rect LogicalRectToDevice(Rect logicalRectangle)
{
Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalRectangle.Left, logicalRectangle.Top));
Point point2 = DpiHelper.LogicalPixelsToDevice(new Point(logicalRectangle.Right, logicalRectangle.Bottom));
return new Rect(point, point2);
}
public static Rect DeviceRectToLogical(Rect deviceRectangle)
{
Point point = DpiHelper.DevicePixelsToLogical(new Point(deviceRectangle.Left, deviceRectangle.Top));
Point point2 = DpiHelper.DevicePixelsToLogical(new Point(deviceRectangle.Right, deviceRectangle.Bottom));
return new Rect(point, point2);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static Size LogicalSizeToDevice(Size logicalSize)
{
Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalSize.Width, logicalSize.Height));
return new Size
{
Width = point.X,
Height = point.Y
};
}
public static Size DeviceSizeToLogical(Size deviceSize)
{
Point point = DpiHelper.DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height));
return new Size(point.X, point.Y);
}
private static Matrix _transformToDevice;
private static Matrix _transformToDip;
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace Standard
{
[Flags]
internal enum ErrorModes
{
Default = 0,
FailCriticalErrors = 1,
NoGpFaultErrorBox = 2,
NoAlignmentFaultExcept = 4,
NoOpenFileErrorBox = 32768
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Standard
{
internal enum FO
{
MOVE = 1,
COPY,
DELETE,
RENAME
}
}

View File

@ -0,0 +1,24 @@
using System;
namespace Standard
{
internal enum FOF : ushort
{
MULTIDESTFILES = 1,
CONFIRMMOUSE,
SILENT = 4,
RENAMEONCOLLISION = 8,
NOCONFIRMATION = 16,
WANTMAPPINGHANDLE = 32,
ALLOWUNDO = 64,
FILESONLY = 128,
SIMPLEPROGRESS = 256,
NOCONFIRMMKDIR = 512,
NOERRORUI = 1024,
NOCOPYSECURITYATTRIBS = 2048,
NORECURSION = 4096,
NO_CONNECTED_ELEMENTS = 8192,
WANTNUKEWARNING = 16384,
NORECURSEREPARSE = 32768
}
}

View File

@ -0,0 +1,19 @@
using System;
namespace Standard
{
[Flags]
internal enum Facility
{
Null,
Rpc,
Dispatch,
Storage,
Itf,
Win32 = 7,
Windows,
Control = 10,
Ese = 3678,
WinCodec = 2200
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace Standard
{
internal enum GCLP
{
HBRBACKGROUND = -10
}
}

View File

@ -0,0 +1,18 @@
using System;
namespace Standard
{
internal enum GPS
{
DEFAULT,
HANDLERPROPERTIESONLY,
READWRITE,
TEMPORARY = 4,
FASTPROPERTIESONLY = 8,
OPENSLOWITEM = 16,
DELAYCREATION = 32,
BESTEFFORT = 64,
NO_OPLOCK = 128,
MASK_VALID = 255
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Standard
{
internal enum GWL
{
WNDPROC = -4,
HINSTANCE = -6,
HWNDPARENT = -8,
STYLE = -16,
EXSTYLE = -20,
USERDATA = -21,
ID = -12
}
}

View File

@ -0,0 +1,16 @@
using System;
namespace Standard
{
[Flags]
internal enum HCF
{
HIGHCONTRASTON = 1,
AVAILABLE = 2,
HOTKEYACTIVE = 4,
CONFIRMHOTKEY = 8,
HOTKEYSOUND = 16,
INDICATOR = 32,
HOTKEYAVAILABLE = 64
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Standard
{
internal struct HIGHCONTRAST
{
public int cbSize;
public HCF dwFlags;
public IntPtr lpszDefaultScheme;
}
}

View File

@ -0,0 +1,244 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Explicit)]
internal struct HRESULT
{
public HRESULT(uint i)
{
this._value = i;
}
public static HRESULT Make(bool severe, Facility facility, int code)
{
return new HRESULT((uint)((severe ? (Facility)(-2147483648) : Facility.Null) | (Facility) ((int)facility << 16) | (Facility)code));
}
public Facility Facility
{
get
{
return HRESULT.GetFacility((int)this._value);
}
}
public static Facility GetFacility(int errorCode)
{
return (Facility)(errorCode >> 16 & 8191);
}
public int Code
{
get
{
return HRESULT.GetCode((int)this._value);
}
}
public static int GetCode(int error)
{
return error & 65535;
}
public override string ToString()
{
foreach (FieldInfo fieldInfo in typeof(HRESULT).GetFields(BindingFlags.Static | BindingFlags.Public))
{
if (fieldInfo.FieldType == typeof(HRESULT))
{
HRESULT hrLeft = (HRESULT)fieldInfo.GetValue(null);
if (hrLeft == this)
{
return fieldInfo.Name;
}
}
}
if (this.Facility == Facility.Win32)
{
foreach (FieldInfo fieldInfo2 in typeof(Win32Error).GetFields(BindingFlags.Static | BindingFlags.Public))
{
if (fieldInfo2.FieldType == typeof(Win32Error))
{
Win32Error error = (Win32Error)fieldInfo2.GetValue(null);
if ((HRESULT)error == this)
{
return "HRESULT_FROM_WIN32(" + fieldInfo2.Name + ")";
}
}
}
}
return string.Format(CultureInfo.InvariantCulture, "0x{0:X8}", new object[]
{
this._value
});
}
public override bool Equals(object obj)
{
bool result;
try
{
result = (((HRESULT)obj)._value == this._value);
}
catch (InvalidCastException)
{
result = false;
}
return result;
}
public override int GetHashCode()
{
return this._value.GetHashCode();
}
public static bool operator ==(HRESULT hrLeft, HRESULT hrRight)
{
return hrLeft._value == hrRight._value;
}
public static bool operator !=(HRESULT hrLeft, HRESULT hrRight)
{
return !(hrLeft == hrRight);
}
public bool Succeeded
{
get
{
return this._value >= 0u;
}
}
public bool Failed
{
get
{
return this._value < 0u;
}
}
public void ThrowIfFailed()
{
this.ThrowIfFailed(null);
}
[SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Justification = "Only recreating Exceptions that were already raised.")]
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public void ThrowIfFailed(string message)
{
if (this.Failed)
{
if (string.IsNullOrEmpty(message))
{
message = this.ToString();
}
Exception ex = Marshal.GetExceptionForHR((int)this._value, new IntPtr(-1));
if (ex.GetType() == typeof(COMException))
{
Facility facility = this.Facility;
if (facility == Facility.Win32)
{
ex = new Win32Exception(this.Code, message);
}
else
{
ex = new COMException(message, (int)this._value);
}
}
else
{
ConstructorInfo constructor = ex.GetType().GetConstructor(new Type[]
{
typeof(string)
});
if (null != constructor)
{
ex = (constructor.Invoke(new object[]
{
message
}) as Exception);
}
}
throw ex;
}
}
public static void ThrowLastError()
{
((HRESULT)Win32Error.GetLastError()).ThrowIfFailed();
}
[FieldOffset(0)]
private readonly uint _value;
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT S_OK = new HRESULT(0u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT S_FALSE = new HRESULT(1u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_PENDING = new HRESULT(2147483658u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_NOTIMPL = new HRESULT(2147500033u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_NOINTERFACE = new HRESULT(2147500034u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_POINTER = new HRESULT(2147500035u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_ABORT = new HRESULT(2147500036u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_FAIL = new HRESULT(2147500037u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_UNEXPECTED = new HRESULT(2147549183u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT STG_E_INVALIDFUNCTION = new HRESULT(2147680257u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT REGDB_E_CLASSNOTREG = new HRESULT(2147746132u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT DESTS_E_NO_MATCHING_ASSOC_HANDLER = new HRESULT(2147749635u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT DESTS_E_NORECDOCS = new HRESULT(2147749636u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT DESTS_E_NOTALLCLEARED = new HRESULT(2147749637u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_ACCESSDENIED = new HRESULT(2147942405u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_OUTOFMEMORY = new HRESULT(2147942414u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT E_INVALIDARG = new HRESULT(2147942487u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT INTSAFE_E_ARITHMETIC_OVERFLOW = new HRESULT(2147942934u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT COR_E_OBJECTDISPOSED = new HRESULT(2148734498u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT WC_E_GREATERTHAN = new HRESULT(3222072867u);
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public static readonly HRESULT WC_E_SYNTAX = new HRESULT(3222072877u);
}
}

View File

@ -0,0 +1,37 @@
using System;
namespace Standard
{
internal enum HT
{
ERROR = -2,
TRANSPARENT,
NOWHERE,
CLIENT,
CAPTION,
SYSMENU,
GROWBOX,
SIZE = 4,
MENU,
HSCROLL,
VSCROLL,
MINBUTTON,
MAXBUTTON,
LEFT,
RIGHT,
TOP,
TOPLEFT,
TOPRIGHT,
BOTTOM,
BOTTOMLEFT,
BOTTOMRIGHT,
BORDER,
REDUCE = 8,
ZOOM,
SIZEFIRST,
SIZELAST = 17,
OBJECT = 19,
CLOSE,
HELP
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("12337d35-94c6-48a0-bce7-6a9c69d4d600")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IApplicationDestinations
{
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] [In] string pszAppID);
void RemoveDestination([MarshalAs(UnmanagedType.IUnknown)] object punk);
void RemoveAllDestinations();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("3c594f9f-9f30-47a1-979a-c9e83d3d0a06")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IApplicationDocumentLists
{
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
[return: MarshalAs(UnmanagedType.IUnknown)]
object GetList([In] APPDOCLISTTYPE listtype, [In] uint cItemsDesired, [In] ref Guid riid);
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("6332debf-87b5-4670-90c0-5e57b408a49e")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ICustomDestinationList
{
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] [In] string pszAppID);
[return: MarshalAs(UnmanagedType.Interface)]
object BeginList(out uint pcMaxSlots, [In] ref Guid riid);
[PreserveSig]
HRESULT AppendCategory([MarshalAs(UnmanagedType.LPWStr)] string pszCategory, IObjectArray poa);
void AppendKnownCategory(KDC category);
[PreserveSig]
HRESULT AddUserTasks(IObjectArray poa);
void CommitList();
[return: MarshalAs(UnmanagedType.Interface)]
object GetRemovedDestinations([In] ref Guid riid);
void DeleteList([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
void AbortList();
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("000214F2-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IEnumIDList
{
[PreserveSig]
HRESULT Next(uint celt, out IntPtr rgelt, out int pceltFetched);
[PreserveSig]
HRESULT Skip(uint celt);
void Reset();
void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumIDList ppenum);
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("2c1c7e2e-2d0e-4059-831e-1e6f82335c2e")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IEnumObjects
{
void Next(uint celt, [In] ref Guid riid, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, SizeParamIndex = 0)] [Out] object[] rgelt, out uint pceltFetched);
void Skip(uint celt);
void Reset();
IEnumObjects Clone();
}
}

View File

@ -0,0 +1,55 @@
using System;
namespace Standard
{
internal static class IID
{
public const string EnumIdList = "000214F2-0000-0000-C000-000000000046";
public const string EnumObjects = "2c1c7e2e-2d0e-4059-831e-1e6f82335c2e";
public const string HtmlDocument2 = "332C4425-26CB-11D0-B483-00C04FD90119";
public const string ModalWindow = "b4db1657-70d7-485e-8e3e-6fcb5a5c1802";
public const string ObjectArray = "92CA9DCD-5622-4bba-A805-5E9F541BD8C9";
public const string ObjectCollection = "5632b1a4-e38a-400a-928a-d4cd63230295";
public const string PropertyNotifySink = "9BFBBC02-EFF1-101A-84ED-00AA00341D07";
public const string PropertyStore = "886d8eeb-8cf2-4446-8d02-cdba1dbdcf99";
public const string ServiceProvider = "6d5140c1-7436-11ce-8034-00aa006009fa";
public const string ShellFolder = "000214E6-0000-0000-C000-000000000046";
public const string ShellLink = "000214F9-0000-0000-C000-000000000046";
public const string ShellItem = "43826d1e-e718-42ee-bc55-a1e261c37bfe";
public const string ShellItem2 = "7e9fb0d3-919f-4307-ab2e-9b1860310c93";
public const string ShellItemArray = "B63EA76D-1F85-456F-A19C-48159EFA858B";
public const string TaskbarList = "56FDF342-FD6D-11d0-958A-006097C9A090";
public const string TaskbarList2 = "602D4995-B13A-429b-A66E-1935E44F4317";
public const string Unknown = "00000000-0000-0000-C000-000000000046";
public const string ApplicationDestinations = "12337d35-94c6-48a0-bce7-6a9c69d4d600";
public const string ApplicationDocumentLists = "3c594f9f-9f30-47a1-979a-c9e83d3d0a06";
public const string CustomDestinationList = "6332debf-87b5-4670-90c0-5e57b408a49e";
public const string ObjectWithAppUserModelId = "36db0196-9665-46d1-9ba7-d3709eecf9ed";
public const string ObjectWithProgId = "71e806fb-8dee-46fc-bf8c-7748a8a1ae13";
public const string TaskbarList3 = "ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf";
public const string TaskbarList4 = "c43dc798-95d1-4bea-9030-bb99e2983a1a";
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal struct INPUT
{
public uint type;
public MOUSEINPUT mi;
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace Standard
{
internal enum INPUT_TYPE : uint
{
MOUSE
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")]
[ComImport]
internal interface IObjectArray
{
uint GetCount();
[return: MarshalAs(UnmanagedType.IUnknown)]
object GetAt([In] uint uiIndex, [In] ref Guid riid);
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")]
[ComImport]
internal interface IObjectCollection : IObjectArray
{
uint GetCount();
[return: MarshalAs(UnmanagedType.IUnknown)]
object GetAt([In] uint uiIndex, [In] ref Guid riid);
void AddObject([MarshalAs(UnmanagedType.IUnknown)] object punk);
void AddFromArray(IObjectArray poaSource);
void RemoveObjectAt(uint uiIndex);
void Clear();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("36db0196-9665-46d1-9ba7-d3709eecf9ed")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IObjectWithAppUserModelId
{
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
[return: MarshalAs(UnmanagedType.LPWStr)]
string GetAppID();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("71e806fb-8dee-46fc-bf8c-7748a8a1ae13")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IObjectWithProgId
{
void SetProgID([MarshalAs(UnmanagedType.LPWStr)] string pszProgID);
[return: MarshalAs(UnmanagedType.LPWStr)]
string GetProgID();
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IPropertyStore
{
uint GetCount();
PKEY GetAt(uint iProp);
void GetValue([In] ref PKEY pkey, [In] [Out] PROPVARIANT pv);
void SetValue([In] ref PKEY pkey, PROPVARIANT pv);
void Commit();
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214E6-0000-0000-C000-000000000046")]
[ComImport]
internal interface IShellFolder
{
void ParseDisplayName([In] IntPtr hwnd, [In] IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] [In] string pszDisplayName, [In] [Out] ref int pchEaten, out IntPtr ppidl, [In] [Out] ref uint pdwAttributes);
IEnumIDList EnumObjects([In] IntPtr hwnd, [In] SHCONTF grfFlags);
[return: MarshalAs(UnmanagedType.Interface)]
object BindToObject([In] IntPtr pidl, [In] IBindCtx pbc, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object BindToStorage([In] IntPtr pidl, [In] IBindCtx pbc, [In] ref Guid riid);
[PreserveSig]
HRESULT CompareIDs([In] IntPtr lParam, [In] IntPtr pidl1, [In] IntPtr pidl2);
[return: MarshalAs(UnmanagedType.Interface)]
object CreateViewObject([In] IntPtr hwndOwner, [In] ref Guid riid);
void GetAttributesOf([In] uint cidl, [In] IntPtr apidl, [In] [Out] ref SFGAO rgfInOut);
[return: MarshalAs(UnmanagedType.Interface)]
object GetUIObjectOf([In] IntPtr hwndOwner, [In] uint cidl, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysInt, SizeParamIndex = 2)] [In] IntPtr apidl, [In] ref Guid riid, [In] [Out] ref uint rgfReserved);
void GetDisplayNameOf([In] IntPtr pidl, [In] SHGDN uFlags, out IntPtr pName);
void SetNameOf([In] IntPtr hwnd, [In] IntPtr pidl, [MarshalAs(UnmanagedType.LPWStr)] [In] string pszName, [In] SHGDN uFlags, out IntPtr ppidlOut);
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Standard
{
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IShellItem
{
[return: MarshalAs(UnmanagedType.Interface)]
object BindToHandler(IBindCtx pbc, [In] ref Guid bhid, [In] ref Guid riid);
IShellItem GetParent();
[return: MarshalAs(UnmanagedType.LPWStr)]
string GetDisplayName(SIGDN sigdnName);
SFGAO GetAttributes(SFGAO sfgaoMask);
int Compare(IShellItem psi, SICHINT hint);
}
}

View File

@ -0,0 +1,56 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93")]
[ComImport]
internal interface IShellItem2 : IShellItem
{
[return: MarshalAs(UnmanagedType.Interface)]
object BindToHandler([In] IBindCtx pbc, [In] ref Guid bhid, [In] ref Guid riid);
IShellItem GetParent();
[return: MarshalAs(UnmanagedType.LPWStr)]
string GetDisplayName(SIGDN sigdnName);
SFGAO GetAttributes(SFGAO sfgaoMask);
int Compare(IShellItem psi, SICHINT hint);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyStore(GPS flags, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyStoreWithCreateObject(GPS flags, [MarshalAs(UnmanagedType.IUnknown)] object punkCreateObject, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyStoreForKeys(IntPtr rgKeys, uint cKeys, GPS flags, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyDescriptionList(IntPtr keyType, [In] ref Guid riid);
void Update(IBindCtx pbc);
PROPVARIANT GetProperty(IntPtr key);
Guid GetCLSID(IntPtr key);
System.Runtime.InteropServices.ComTypes.FILETIME GetFileTime(IntPtr key);
int GetInt32(IntPtr key);
[return: MarshalAs(UnmanagedType.LPWStr)]
string GetString(IntPtr key);
uint GetUInt32(IntPtr key);
ulong GetUInt64(IntPtr key);
[return: MarshalAs(UnmanagedType.Bool)]
void GetBool(IntPtr key);
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("B63EA76D-1F85-456F-A19C-48159EFA858B")]
[ComImport]
internal interface IShellItemArray
{
[return: MarshalAs(UnmanagedType.Interface)]
object BindToHandler(IBindCtx pbc, [In] ref Guid rbhid, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyStore(int flags, [In] ref Guid riid);
[return: MarshalAs(UnmanagedType.Interface)]
object GetPropertyDescriptionList([In] ref PKEY keyType, [In] ref Guid riid);
uint GetAttributes(SIATTRIBFLAGS dwAttribFlags, uint sfgaoMask);
uint GetCount();
IShellItem GetItemAt(uint dwIndex);
[return: MarshalAs(UnmanagedType.Interface)]
object EnumItems();
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Standard
{
[Guid("000214F9-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface IShellLinkW
{
void GetPath([MarshalAs(UnmanagedType.LPWStr)] [Out] StringBuilder pszFile, int cchMaxPath, [In] [Out] WIN32_FIND_DATAW pfd, SLGP fFlags);
void GetIDList(out IntPtr ppidl);
void SetIDList(IntPtr pidl);
void GetDescription([MarshalAs(UnmanagedType.LPWStr)] [Out] StringBuilder pszFile, int cchMaxName);
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
void GetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] [Out] StringBuilder pszDir, int cchMaxPath);
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
void GetArguments([MarshalAs(UnmanagedType.LPWStr)] [Out] StringBuilder pszArgs, int cchMaxPath);
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
short GetHotKey();
void SetHotKey(short wHotKey);
uint GetShowCmd();
void SetShowCmd(uint iShowCmd);
void GetIconLocation([MarshalAs(UnmanagedType.LPWStr)] [Out] StringBuilder pszIconPath, int cchIconPath, out int piIcon);
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved);
void Resolve(IntPtr hwnd, uint fFlags);
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("56FDF342-FD6D-11d0-958A-006097C9A090")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ITaskbarList
{
void HrInit();
void AddTab(IntPtr hwnd);
void DeleteTab(IntPtr hwnd);
void ActivateTab(IntPtr hwnd);
void SetActiveAlt(IntPtr hwnd);
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("602D4995-B13A-429b-A66E-1935E44F4317")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ITaskbarList2 : ITaskbarList
{
void HrInit();
void AddTab(IntPtr hwnd);
void DeleteTab(IntPtr hwnd);
void ActivateTab(IntPtr hwnd);
void SetActiveAlt(IntPtr hwnd);
void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ITaskbarList3 : ITaskbarList2, ITaskbarList
{
void HrInit();
void AddTab(IntPtr hwnd);
void DeleteTab(IntPtr hwnd);
void ActivateTab(IntPtr hwnd);
void SetActiveAlt(IntPtr hwnd);
void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
[PreserveSig]
HRESULT SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
[PreserveSig]
HRESULT SetProgressState(IntPtr hwnd, TBPF tbpFlags);
[PreserveSig]
HRESULT RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
[PreserveSig]
HRESULT UnregisterTab(IntPtr hwndTab);
[PreserveSig]
HRESULT SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
[PreserveSig]
HRESULT SetTabActive(IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved);
[PreserveSig]
HRESULT ThumbBarAddButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
[PreserveSig]
HRESULT ThumbBarUpdateButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
[PreserveSig]
HRESULT ThumbBarSetImageList(IntPtr hwnd, [MarshalAs(UnmanagedType.IUnknown)] object himl);
[PreserveSig]
HRESULT SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
[PreserveSig]
HRESULT SetThumbnailTooltip(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
[PreserveSig]
HRESULT SetThumbnailClip(IntPtr hwnd, RefRECT prcClip);
}
}

View File

@ -0,0 +1,61 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
[ComImport]
internal interface ITaskbarList4 : ITaskbarList3, ITaskbarList2, ITaskbarList
{
void HrInit();
void AddTab(IntPtr hwnd);
void DeleteTab(IntPtr hwnd);
void ActivateTab(IntPtr hwnd);
void SetActiveAlt(IntPtr hwnd);
void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
[PreserveSig]
HRESULT SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
[PreserveSig]
HRESULT SetProgressState(IntPtr hwnd, TBPF tbpFlags);
[PreserveSig]
HRESULT RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
[PreserveSig]
HRESULT UnregisterTab(IntPtr hwndTab);
[PreserveSig]
HRESULT SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
[PreserveSig]
HRESULT SetTabActive(IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved);
[PreserveSig]
HRESULT ThumbBarAddButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
[PreserveSig]
HRESULT ThumbBarUpdateButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
[PreserveSig]
HRESULT ThumbBarSetImageList(IntPtr hwnd, [MarshalAs(UnmanagedType.IUnknown)] object himl);
[PreserveSig]
HRESULT SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
[PreserveSig]
HRESULT SetThumbnailTooltip(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
[PreserveSig]
HRESULT SetThumbnailClip(IntPtr hwnd, RefRECT prcClip);
void SetTabProperties(IntPtr hwndTab, STPF stpFlags);
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Standard
{
internal enum KDC
{
FREQUENT = 1,
RECENT
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct LOGFONT
{
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string lfFaceName;
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Standard
{
internal struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace Standard
{
[Flags]
internal enum MF : uint
{
DOES_NOT_EXIST = 4294967295u,
ENABLED = 0u,
BYCOMMAND = 0u,
GRAYED = 1u,
DISABLED = 2u
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace Standard
{
internal struct MINMAXINFO
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential)]
internal class MONITORINFO
{
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
public RECT rcMonitor;
public RECT rcWork;
public int dwFlags;
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Standard
{
internal enum MOUSEEVENTF
{
LEFTDOWN = 2,
LEFTUP = 4
}
}

View File

@ -0,0 +1,19 @@
using System;
namespace Standard
{
internal struct MOUSEINPUT
{
public int dx;
public int dy;
public int mouseData;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal enum MSGFLT
{
RESET,
ALLOW,
DISALLOW
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Standard
{
internal enum MSGFLTINFO
{
NONE,
ALREADYALLOWED_FORWND,
ALREADYDISALLOWED_FORWND,
ALLOWED_HIGHER
}
}

View File

@ -0,0 +1,150 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Standard
{
internal sealed class ManagedIStream : IStream, IDisposable
{
public ManagedIStream(Stream source)
{
Verify.IsNotNull<Stream>(source, "source");
this._source = source;
}
private void _Validate()
{
if (this._source == null)
{
throw new ObjectDisposedException("this");
}
}
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)")]
[Obsolete("The method is not implemented", true)]
public void Clone(out IStream ppstm)
{
ppstm = null;
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed("The method is not implemented.");
}
public void Commit(int grfCommitFlags)
{
this._Validate();
this._source.Flush();
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
{
Verify.IsNotNull<IStream>(pstm, "pstm");
this._Validate();
byte[] array = new byte[4096];
long num;
int num2;
for (num = 0L; num < cb; num += (long)num2)
{
num2 = this._source.Read(array, 0, array.Length);
if (num2 == 0)
{
break;
}
pstm.Write(array, num2, IntPtr.Zero);
}
if (IntPtr.Zero != pcbRead)
{
Marshal.WriteInt64(pcbRead, num);
}
if (IntPtr.Zero != pcbWritten)
{
Marshal.WriteInt64(pcbWritten, num);
}
}
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)")]
[Obsolete("The method is not implemented", true)]
public void LockRegion(long libOffset, long cb, int dwLockType)
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed("The method is not implemented.");
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public void Read(byte[] pv, int cb, IntPtr pcbRead)
{
this._Validate();
int val = this._source.Read(pv, 0, cb);
if (IntPtr.Zero != pcbRead)
{
Marshal.WriteInt32(pcbRead, val);
}
}
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)")]
[Obsolete("The method is not implemented", true)]
public void Revert()
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed("The method is not implemented.");
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition)
{
this._Validate();
long val = this._source.Seek(dlibMove, (SeekOrigin)dwOrigin);
if (IntPtr.Zero != plibNewPosition)
{
Marshal.WriteInt64(plibNewPosition, val);
}
}
public void SetSize(long libNewSize)
{
this._Validate();
this._source.SetLength(libNewSize);
}
public void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg, int grfStatFlag)
{
pstatstg = default(System.Runtime.InteropServices.ComTypes.STATSTG);
this._Validate();
pstatstg.type = 2;
pstatstg.cbSize = this._source.Length;
pstatstg.grfMode = 2;
pstatstg.grfLocksSupported = 2;
}
[Obsolete("The method is not implemented", true)]
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)")]
public void UnlockRegion(long libOffset, long cb, int dwLockType)
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed("The method is not implemented.");
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public void Write(byte[] pv, int cb, IntPtr pcbWritten)
{
this._Validate();
this._source.Write(pv, 0, cb);
if (IntPtr.Zero != pcbWritten)
{
Marshal.WriteInt32(pcbWritten, cb);
}
}
public void Dispose()
{
this._source = null;
}
private const int STGTY_STREAM = 2;
private const int STGM_READWRITE = 2;
private const int LOCK_EXCLUSIVE = 2;
private Stream _source;
}
}

View File

@ -0,0 +1,6 @@
using System;
namespace Standard
{
internal delegate IntPtr MessageHandler(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled);
}

View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Threading;
namespace Standard
{
internal sealed class MessageWindow : DispatcherObject, IDisposable
{
public IntPtr Handle { get; private set; }
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public MessageWindow(CS classStyle, WS style, WS_EX exStyle, Rect location, string name, WndProc callback)
{
this._wndProcCallback = callback;
this._className = "MessageWindowClass+" + Guid.NewGuid().ToString();
WNDCLASSEX wndclassex = new WNDCLASSEX
{
cbSize = Marshal.SizeOf(typeof(WNDCLASSEX)),
style = classStyle,
lpfnWndProc = MessageWindow.s_WndProc,
hInstance = NativeMethods.GetModuleHandle(null),
hbrBackground = NativeMethods.GetStockObject(StockObject.NULL_BRUSH),
lpszMenuName = "",
lpszClassName = this._className
};
NativeMethods.RegisterClassEx(ref wndclassex);
GCHandle value = default(GCHandle);
try
{
value = GCHandle.Alloc(this);
IntPtr lpParam = (IntPtr)value;
this.Handle = NativeMethods.CreateWindowEx(exStyle, this._className, name, style, (int)location.X, (int)location.Y, (int)location.Width, (int)location.Height, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, lpParam);
}
finally
{
value.Free();
}
}
~MessageWindow()
{
this._Dispose(false, false);
}
public void Dispose()
{
this._Dispose(true, false);
GC.SuppressFinalize(this);
}
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "disposing")]
private void _Dispose(bool disposing, bool isHwndBeingDestroyed)
{
if (this._isDisposed)
{
return;
}
this._isDisposed = true;
IntPtr hwnd = this.Handle;
string className = this._className;
if (isHwndBeingDestroyed)
{
base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback((object arg) => MessageWindow._DestroyWindow(IntPtr.Zero, className)));
}
else if (this.Handle != IntPtr.Zero)
{
if (base.CheckAccess())
{
MessageWindow._DestroyWindow(hwnd, className);
}
else
{
base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback((object arg) => MessageWindow._DestroyWindow(hwnd, className)));
}
}
MessageWindow.s_windowLookup.Remove(hwnd);
this._className = null;
this.Handle = IntPtr.Zero;
}
[SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly")]
private static IntPtr _WndProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam)
{
IntPtr result = IntPtr.Zero;
MessageWindow messageWindow = null;
if (msg == WM.CREATE)
{
messageWindow = (MessageWindow)GCHandle.FromIntPtr(((CREATESTRUCT)Marshal.PtrToStructure(lParam, typeof(CREATESTRUCT))).lpCreateParams).Target;
MessageWindow.s_windowLookup.Add(hwnd, messageWindow);
}
else if (!MessageWindow.s_windowLookup.TryGetValue(hwnd, out messageWindow))
{
return NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam);
}
WndProc wndProcCallback = messageWindow._wndProcCallback;
if (wndProcCallback != null)
{
result = wndProcCallback(hwnd, msg, wParam, lParam);
}
else
{
result = NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam);
}
if (msg == WM.NCDESTROY)
{
messageWindow._Dispose(true, true);
GC.SuppressFinalize(messageWindow);
}
return result;
}
private static object _DestroyWindow(IntPtr hwnd, string className)
{
Utility.SafeDestroyWindow(ref hwnd);
NativeMethods.UnregisterClass(className, NativeMethods.GetModuleHandle(null));
return null;
}
private static readonly WndProc s_WndProc = new WndProc(MessageWindow._WndProc);
private static readonly Dictionary<IntPtr, MessageWindow> s_windowLookup = new Dictionary<IntPtr, MessageWindow>();
private WndProc _wndProcCallback;
private string _className;
private bool _isDisposed;
}
}

View File

@ -0,0 +1,19 @@
using System;
namespace Standard
{
[Flags]
internal enum NIF : uint
{
MESSAGE = 1u,
ICON = 2u,
TIP = 4u,
STATE = 8u,
INFO = 16u,
GUID = 32u,
REALTIME = 64u,
SHOWTIP = 128u,
XP_MASK = 59u,
VISTA_MASK = 251u
}
}

View File

@ -0,0 +1,17 @@
using System;
namespace Standard
{
internal enum NIIF
{
NONE,
INFO,
WARNING,
ERROR,
USER,
NOSOUND = 16,
LARGE_ICON = 32,
NIIF_RESPECT_QUIET_TIME = 128,
XP_ICON_MASK = 15
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Standard
{
internal enum NIM : uint
{
ADD,
MODIFY,
DELETE,
SETFOCUS,
SETVERSION
}
}

View File

@ -0,0 +1,65 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Standard
{
internal struct NONCLIENTMETRICS
{
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public static NONCLIENTMETRICS VistaMetricsStruct
{
get
{
return new NONCLIENTMETRICS
{
cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS))
};
}
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public static NONCLIENTMETRICS XPMetricsStruct
{
get
{
return new NONCLIENTMETRICS
{
cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)) - 4
};
}
}
public int cbSize;
public int iBorderWidth;
public int iScrollWidth;
public int iScrollHeight;
public int iCaptionWidth;
public int iCaptionHeight;
public LOGFONT lfCaptionFont;
public int iSmCaptionWidth;
public int iSmCaptionHeight;
public LOGFONT lfSmCaptionFont;
public int iMenuWidth;
public int iMenuHeight;
public LOGFONT lfMenuFont;
public LOGFONT lfStatusFont;
public LOGFONT lfMessageFont;
public int iPaddedBorderWidth;
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Standard
{
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
[StructLayout(LayoutKind.Sequential)]
internal class NOTIFYICONDATA
{
public int cbSize;
public IntPtr hWnd;
public int uID;
public NIF uFlags;
public int uCallbackMessage;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public char[] szTip = new char[128];
public uint dwState;
public uint dwStateMask;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public char[] szInfo = new char[256];
public uint uVersion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
public char[] szInfoTitle = new char[64];
public uint dwInfoFlags;
public Guid guidItem;
private IntPtr hBalloonIcon;
}
}

View File

@ -0,0 +1,908 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Standard
{
internal static class NativeMethods
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "AdjustWindowRectEx", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _AdjustWindowRectEx(ref RECT lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle);
public static RECT AdjustWindowRectEx(RECT lpRect, WS dwStyle, bool bMenu, WS_EX dwExStyle)
{
if (!NativeMethods._AdjustWindowRectEx(ref lpRect, dwStyle, bMenu, dwExStyle))
{
HRESULT.ThrowLastError();
}
return lpRect;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "ChangeWindowMessageFilter", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _ChangeWindowMessageFilter(WM message, MSGFLT dwFlag);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "ChangeWindowMessageFilterEx", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFLT action, [In] [Out] ref CHANGEFILTERSTRUCT pChangeFilterStruct);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFLT action, out MSGFLTINFO filterInfo)
{
filterInfo = MSGFLTINFO.NONE;
if (!Utility.IsOSVistaOrNewer)
{
return HRESULT.S_FALSE;
}
if (!Utility.IsOSWindows7OrNewer)
{
if (!NativeMethods._ChangeWindowMessageFilter(message, action))
{
return (HRESULT)Win32Error.GetLastError();
}
return HRESULT.S_OK;
}
else
{
CHANGEFILTERSTRUCT changefilterstruct = new CHANGEFILTERSTRUCT
{
cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT))
};
if (!NativeMethods._ChangeWindowMessageFilterEx(hwnd, message, action, ref changefilterstruct))
{
return (HRESULT)Win32Error.GetLastError();
}
filterInfo = changefilterstruct.ExtStatus;
return HRESULT.S_OK;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll")]
public static extern CombineRgnResult CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, RGN fnCombineMode);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll", CharSet = CharSet.Unicode, EntryPoint = "CommandLineToArgvW")]
private static extern IntPtr _CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string cmdLine, out int numArgs);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static string[] CommandLineToArgvW(string cmdLine)
{
IntPtr intPtr = IntPtr.Zero;
string[] result;
try
{
int num = 0;
intPtr = NativeMethods._CommandLineToArgvW(cmdLine, out num);
if (intPtr == IntPtr.Zero)
{
throw new Win32Exception();
}
string[] array = new string[num];
for (int i = 0; i < num; i++)
{
IntPtr ptr = Marshal.ReadIntPtr(intPtr, i * Marshal.SizeOf(typeof(IntPtr)));
array[i] = Marshal.PtrToStringUni(ptr);
}
result = array;
}
finally
{
NativeMethods._LocalFree(intPtr);
}
return result;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "CreateDIBSection", SetLastError = true)]
private static extern SafeHBITMAP _CreateDIBSection(SafeDC hdc, [In] ref BITMAPINFO bitmapInfo, int iUsage, out IntPtr ppvBits, IntPtr hSection, int dwOffset);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "CreateDIBSection", SetLastError = true)]
private static extern SafeHBITMAP _CreateDIBSectionIntPtr(IntPtr hdc, [In] ref BITMAPINFO bitmapInfo, int iUsage, out IntPtr ppvBits, IntPtr hSection, int dwOffset);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static SafeHBITMAP CreateDIBSection(SafeDC hdc, ref BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset)
{
SafeHBITMAP safeHBITMAP;
if (hdc == null)
{
safeHBITMAP = NativeMethods._CreateDIBSectionIntPtr(IntPtr.Zero, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset);
}
else
{
safeHBITMAP = NativeMethods._CreateDIBSection(hdc, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset);
}
if (safeHBITMAP.IsInvalid)
{
HRESULT.ThrowLastError();
}
return safeHBITMAP;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "CreateRoundRectRgn", SetLastError = true)]
private static extern IntPtr _CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse)
{
IntPtr intPtr = NativeMethods._CreateRoundRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse);
if (IntPtr.Zero == intPtr)
{
throw new Win32Exception();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "CreateRectRgn", SetLastError = true)]
private static extern IntPtr _CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
{
IntPtr intPtr = NativeMethods._CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect);
if (IntPtr.Zero == intPtr)
{
throw new Win32Exception();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "CreateRectRgnIndirect", SetLastError = true)]
private static extern IntPtr _CreateRectRgnIndirect([In] ref RECT lprc);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr CreateRectRgnIndirect(RECT lprc)
{
IntPtr intPtr = NativeMethods._CreateRectRgnIndirect(ref lprc);
if (IntPtr.Zero == intPtr)
{
throw new Win32Exception();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll")]
public static extern IntPtr CreateSolidBrush(int crColor);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW", SetLastError = true)]
private static extern IntPtr _CreateWindowEx(WS_EX dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr CreateWindowEx(WS_EX dwExStyle, string lpClassName, string lpWindowName, WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam)
{
IntPtr intPtr = NativeMethods._CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
if (IntPtr.Zero == intPtr)
{
HRESULT.ThrowLastError();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "DefWindowProcW")]
public static extern IntPtr DefWindowProc(IntPtr hWnd, WM Msg, IntPtr wParam, IntPtr lParam);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject(IntPtr hObject);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DestroyIcon(IntPtr handle);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DestroyWindow(IntPtr hwnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindow(IntPtr hwnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS pMarInset);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", EntryPoint = "DwmIsCompositionEnabled", PreserveSig = false)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _DwmIsCompositionEnabled();
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", EntryPoint = "DwmGetColorizationColor")]
private static extern HRESULT _DwmGetColorizationColor(out uint pcrColorization, [MarshalAs(UnmanagedType.Bool)] out bool pfOpaqueBlend);
public static bool DwmGetColorizationColor(out uint pcrColorization, out bool pfOpaqueBlend)
{
if (Utility.IsOSVistaOrNewer && NativeMethods.IsThemeActive() && NativeMethods._DwmGetColorizationColor(out pcrColorization, out pfOpaqueBlend).Succeeded)
{
return true;
}
pcrColorization = 4278190080u;
pfOpaqueBlend = true;
return false;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool DwmIsCompositionEnabled()
{
return Utility.IsOSVistaOrNewer && NativeMethods._DwmIsCompositionEnabled();
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DwmDefWindowProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam, out IntPtr plResult);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", EntryPoint = "DwmSetWindowAttribute")]
private static extern void _DwmSetWindowAttribute(IntPtr hwnd, DWMWA dwAttribute, ref int pvAttribute, int cbAttribute);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void DwmSetWindowAttributeFlip3DPolicy(IntPtr hwnd, DWMFLIP3D flip3dPolicy)
{
int num = (int)flip3dPolicy;
NativeMethods._DwmSetWindowAttribute(hwnd, DWMWA.FLIP3D_POLICY, ref num, 4);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void DwmSetWindowAttributeDisallowPeek(IntPtr hwnd, bool disallowPeek)
{
int num = disallowPeek ? 1 : 0;
NativeMethods._DwmSetWindowAttribute(hwnd, DWMWA.DISALLOW_PEEK, ref num, 4);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "EnableMenuItem")]
private static extern int _EnableMenuItem(IntPtr hMenu, SC uIDEnableItem, MF uEnable);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static MF EnableMenuItem(IntPtr hMenu, SC uIDEnableItem, MF uEnable)
{
return (MF)NativeMethods._EnableMenuItem(hMenu, uIDEnableItem, uEnable);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "RemoveMenu", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void RemoveMenu(IntPtr hMenu, SC uPosition, MF uFlags)
{
if (!NativeMethods._RemoveMenu(hMenu, (uint)uPosition, (uint)uFlags))
{
throw new Win32Exception();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "DrawMenuBar", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _DrawMenuBar(IntPtr hWnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void DrawMenuBar(IntPtr hWnd)
{
if (!NativeMethods._DrawMenuBar(hWnd))
{
throw new Win32Exception();
}
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FindClose(IntPtr handle);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFindHandle FindFirstFileW(string lpFileName, [MarshalAs(UnmanagedType.LPStruct)] [In] [Out] WIN32_FIND_DATAW lpFindFileData);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FindNextFileW(SafeFindHandle hndFindFile, [MarshalAs(UnmanagedType.LPStruct)] [In] [Out] WIN32_FIND_DATAW lpFindFileData);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetClientRect", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _GetClientRect(IntPtr hwnd, out RECT lpRect);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static RECT GetClientRect(IntPtr hwnd)
{
RECT result;
if (!NativeMethods._GetClientRect(hwnd, out result))
{
HRESULT.ThrowLastError();
}
return result;
}
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode, EntryPoint = "GetCurrentThemeName")]
private static extern HRESULT _GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int cchMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars);
public static void GetCurrentThemeName(out string themeFileName, out string color, out string size)
{
StringBuilder stringBuilder = new StringBuilder(260);
StringBuilder stringBuilder2 = new StringBuilder(260);
StringBuilder stringBuilder3 = new StringBuilder(260);
NativeMethods._GetCurrentThemeName(stringBuilder, stringBuilder.Capacity, stringBuilder2, stringBuilder2.Capacity, stringBuilder3, stringBuilder3.Capacity).ThrowIfFailed();
themeFileName = stringBuilder.ToString();
color = stringBuilder2.ToString();
size = stringBuilder3.ToString();
}
[DllImport("uxtheme.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsThemeActive();
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[Obsolete("Use SafeDC.GetDC instead.", true)]
public static void GetDC()
{
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll")]
public static extern int GetDeviceCaps(SafeDC hdc, DeviceCap nIndex);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetModuleFileName", SetLastError = true)]
private static extern int _GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static string GetModuleFileName(IntPtr hModule)
{
StringBuilder stringBuilder = new StringBuilder(260);
for (;;)
{
int num = NativeMethods._GetModuleFileName(hModule, stringBuilder, stringBuilder.Capacity);
if (num == 0)
{
HRESULT.ThrowLastError();
}
if (num != stringBuilder.Capacity)
{
break;
}
stringBuilder.EnsureCapacity(stringBuilder.Capacity * 2);
}
return stringBuilder.ToString();
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetModuleHandleW", SetLastError = true)]
private static extern IntPtr _GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName);
public static IntPtr GetModuleHandle(string lpModuleName)
{
IntPtr intPtr = NativeMethods._GetModuleHandle(lpModuleName);
if (intPtr == IntPtr.Zero)
{
HRESULT.ThrowLastError();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetMonitorInfo", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _GetMonitorInfo(IntPtr hMonitor, [In] [Out] MONITORINFO lpmi);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static MONITORINFO GetMonitorInfo(IntPtr hMonitor)
{
MONITORINFO monitorinfo = new MONITORINFO();
if (!NativeMethods._GetMonitorInfo(hMonitor, monitorinfo))
{
throw new Win32Exception();
}
return monitorinfo;
}
[DllImport("gdi32.dll", EntryPoint = "GetStockObject", SetLastError = true)]
private static extern IntPtr _GetStockObject(StockObject fnObject);
public static IntPtr GetStockObject(StockObject fnObject)
{
return NativeMethods._GetStockObject(fnObject);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
public static extern IntPtr GetSystemMenu(IntPtr hWnd, [MarshalAs(UnmanagedType.Bool)] bool bRevert);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(SM nIndex);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr GetWindowLongPtr(IntPtr hwnd, GWL nIndex)
{
IntPtr intPtr = IntPtr.Zero;
if (8 == IntPtr.Size)
{
intPtr = NativeMethods.GetWindowLongPtr64(hwnd, nIndex);
}
else
{
intPtr = new IntPtr(NativeMethods.GetWindowLongPtr32(hwnd, nIndex));
}
if (IntPtr.Zero == intPtr)
{
throw new Win32Exception();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("uxtheme.dll", PreserveSig = false)]
public static extern void SetWindowThemeAttribute([In] IntPtr hwnd, [In] WINDOWTHEMEATTRIBUTETYPE eAttribute, [In] ref WTA_OPTIONS pvAttribute, [In] uint cbAttribute);
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetWindowLong", SetLastError = true)]
private static extern int GetWindowLongPtr32(IntPtr hWnd, GWL nIndex);
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", SetLastError = true)]
private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, GWL nIndex);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowPlacement(IntPtr hwnd, WINDOWPLACEMENT lpwndpl);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
{
WINDOWPLACEMENT windowplacement = new WINDOWPLACEMENT();
if (NativeMethods.GetWindowPlacement(hwnd, windowplacement))
{
return windowplacement;
}
throw new Win32Exception();
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetWindowRect", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _GetWindowRect(IntPtr hWnd, out RECT lpRect);
public static RECT GetWindowRect(IntPtr hwnd)
{
RECT result;
if (!NativeMethods._GetWindowRect(hwnd, out result))
{
HRESULT.ThrowLastError();
}
return result;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdipCreateBitmapFromStream(IStream stream, out IntPtr bitmap);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdipCreateHBITMAPFromBitmap(IntPtr bitmap, out IntPtr hbmReturn, int background);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdipCreateHICONFromBitmap(IntPtr bitmap, out IntPtr hbmReturn);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdipDisposeImage(IntPtr image);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdipImageForceValidation(IntPtr image);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdiplusStartup(out IntPtr token, StartupInput input, out StartupOutput output);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdiplus.dll")]
public static extern Status GdiplusShutdown(IntPtr token);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowVisible(IntPtr hwnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", EntryPoint = "LocalFree", SetLastError = true)]
private static extern IntPtr _LocalFree(IntPtr hMem);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _PostMessage(IntPtr hWnd, WM Msg, IntPtr wParam, IntPtr lParam);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void PostMessage(IntPtr hWnd, WM Msg, IntPtr wParam, IntPtr lParam)
{
if (!NativeMethods._PostMessage(hWnd, Msg, wParam, lParam))
{
throw new Win32Exception();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "RegisterClassExW", SetLastError = true)]
private static extern short _RegisterClassEx([In] ref WNDCLASSEX lpwcx);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static short RegisterClassEx(ref WNDCLASSEX lpwcx)
{
short num = NativeMethods._RegisterClassEx(ref lpwcx);
if (num == 0)
{
HRESULT.ThrowLastError();
}
return num;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "RegisterWindowMessage", SetLastError = true)]
private static extern uint _RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static WM RegisterWindowMessage(string lpString)
{
uint num = NativeMethods._RegisterWindowMessage(lpString);
if (num == 0u)
{
HRESULT.ThrowLastError();
}
return (WM)num;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetActiveWindow", SetLastError = true)]
private static extern IntPtr _SetActiveWindow(IntPtr hWnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr SetActiveWindow(IntPtr hwnd)
{
Verify.IsNotDefault<IntPtr>(hwnd, "hwnd");
IntPtr intPtr = NativeMethods._SetActiveWindow(hwnd);
if (intPtr == IntPtr.Zero)
{
HRESULT.ThrowLastError();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr SetClassLongPtr(IntPtr hwnd, GCLP nIndex, IntPtr dwNewLong)
{
if (8 == IntPtr.Size)
{
return NativeMethods.SetClassLongPtr64(hwnd, nIndex, dwNewLong);
}
return new IntPtr(NativeMethods.SetClassLongPtr32(hwnd, nIndex, dwNewLong.ToInt32()));
}
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetClassLong", SetLastError = true)]
private static extern int SetClassLongPtr32(IntPtr hWnd, GCLP nIndex, int dwNewLong);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[DllImport("user32.dll", EntryPoint = "SetClassLongPtr", SetLastError = true)]
private static extern IntPtr SetClassLongPtr64(IntPtr hWnd, GCLP nIndex, IntPtr dwNewLong);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", SetLastError = true)]
public static extern ErrorModes SetErrorMode(ErrorModes newMode);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _SetProcessWorkingSetSize(IntPtr hProcess, IntPtr dwMinimiumWorkingSetSize, IntPtr dwMaximumWorkingSetSize);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void SetProcessWorkingSetSize(IntPtr hProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize)
{
if (!NativeMethods._SetProcessWorkingSetSize(hProcess, new IntPtr(dwMinimumWorkingSetSize), new IntPtr(dwMaximumWorkingSetSize)))
{
throw new Win32Exception();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr SetWindowLongPtr(IntPtr hwnd, GWL nIndex, IntPtr dwNewLong)
{
if (8 == IntPtr.Size)
{
return NativeMethods.SetWindowLongPtr64(hwnd, nIndex, dwNewLong);
}
return new IntPtr(NativeMethods.SetWindowLongPtr32(hwnd, nIndex, dwNewLong.ToInt32()));
}
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)]
private static extern int SetWindowLongPtr32(IntPtr hWnd, GWL nIndex, int dwNewLong);
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)]
private static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, GWL nIndex, IntPtr dwNewLong);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetWindowRgn", SetLastError = true)]
private static extern int _SetWindowRgn(IntPtr hWnd, IntPtr hRgn, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw)
{
if (NativeMethods._SetWindowRgn(hWnd, hRgn, bRedraw) == 0)
{
throw new Win32Exception();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags)
{
return NativeMethods._SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlags);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll")]
public static extern Win32Error SHFileOperation(ref SHFILEOPSTRUCT lpFileOp);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowWindow(IntPtr hwnd, SW nCmdShow);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "SystemParametersInfoW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _SystemParametersInfo_String(SPI uiAction, int uiParam, [MarshalAs(UnmanagedType.LPWStr)] string pvParam, SPIF fWinIni);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SystemParametersInfoW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _SystemParametersInfo_NONCLIENTMETRICS(SPI uiAction, int uiParam, [In] [Out] ref NONCLIENTMETRICS pvParam, SPIF fWinIni);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SystemParametersInfoW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _SystemParametersInfo_HIGHCONTRAST(SPI uiAction, int uiParam, [In] [Out] ref HIGHCONTRAST pvParam, SPIF fWinIni);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void SystemParametersInfo(SPI uiAction, int uiParam, string pvParam, SPIF fWinIni)
{
if (!NativeMethods._SystemParametersInfo_String(uiAction, uiParam, pvParam, fWinIni))
{
HRESULT.ThrowLastError();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static NONCLIENTMETRICS SystemParameterInfo_GetNONCLIENTMETRICS()
{
NONCLIENTMETRICS result = Utility.IsOSVistaOrNewer ? NONCLIENTMETRICS.VistaMetricsStruct : NONCLIENTMETRICS.XPMetricsStruct;
if (!NativeMethods._SystemParametersInfo_NONCLIENTMETRICS(SPI.GETNONCLIENTMETRICS, result.cbSize, ref result, SPIF.None))
{
HRESULT.ThrowLastError();
}
return result;
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public static HIGHCONTRAST SystemParameterInfo_GetHIGHCONTRAST()
{
HIGHCONTRAST result = new HIGHCONTRAST
{
cbSize = Marshal.SizeOf(typeof(HIGHCONTRAST))
};
if (!NativeMethods._SystemParametersInfo_HIGHCONTRAST(SPI.GETHIGHCONTRAST, result.cbSize, ref result, SPIF.None))
{
HRESULT.ThrowLastError();
}
return result;
}
[DllImport("user32.dll")]
public static extern uint TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "SelectObject", SetLastError = true)]
private static extern IntPtr _SelectObject(SafeDC hdc, IntPtr hgdiobj);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr SelectObject(SafeDC hdc, IntPtr hgdiobj)
{
IntPtr intPtr = NativeMethods._SelectObject(hdc, hgdiobj);
if (intPtr == IntPtr.Zero)
{
HRESULT.ThrowLastError();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("gdi32.dll", EntryPoint = "SelectObject", SetLastError = true)]
private static extern IntPtr _SelectObjectSafeHBITMAP(SafeDC hdc, SafeHBITMAP hgdiobj);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static IntPtr SelectObject(SafeDC hdc, SafeHBITMAP hgdiobj)
{
IntPtr intPtr = NativeMethods._SelectObjectSafeHBITMAP(hdc, hgdiobj);
if (intPtr == IntPtr.Zero)
{
HRESULT.ThrowLastError();
}
return intPtr;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", SetLastError = true)]
public static extern int SendInput(int nInputs, ref INPUT pInputs, int cbSize);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, WM Msg, IntPtr wParam, IntPtr lParam);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "UnregisterClass", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _UnregisterClassAtom(IntPtr lpClassName, IntPtr hInstance);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "UnregisterClass", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _UnregisterClassName(string lpClassName, IntPtr hInstance);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void UnregisterClass(short atom, IntPtr hinstance)
{
if (!NativeMethods._UnregisterClassAtom(new IntPtr((int)atom), hinstance))
{
HRESULT.ThrowLastError();
}
}
public static void UnregisterClass(string lpClassName, IntPtr hInstance)
{
if (!NativeMethods._UnregisterClassName(lpClassName, hInstance))
{
HRESULT.ThrowLastError();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "UpdateLayeredWindow", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _UpdateLayeredWindow(IntPtr hwnd, SafeDC hdcDst, [In] ref POINT pptDst, [In] ref SIZE psize, SafeDC hdcSrc, [In] ref POINT pptSrc, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "UpdateLayeredWindow", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _UpdateLayeredWindowIntPtr(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, IntPtr psize, IntPtr hdcSrc, IntPtr pptSrc, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void UpdateLayeredWindow(IntPtr hwnd, SafeDC hdcDst, ref POINT pptDst, ref SIZE psize, SafeDC hdcSrc, ref POINT pptSrc, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags)
{
if (!NativeMethods._UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags))
{
HRESULT.ThrowLastError();
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void UpdateLayeredWindow(IntPtr hwnd, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags)
{
if (!NativeMethods._UpdateLayeredWindowIntPtr(hwnd, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, crKey, ref pblend, dwFlags))
{
HRESULT.ThrowLastError();
}
}
[DllImport("shell32.dll", EntryPoint = "SHAddToRecentDocs")]
private static extern void _SHAddToRecentDocs_String(SHARD uFlags, [MarshalAs(UnmanagedType.LPWStr)] string pv);
[DllImport("shell32.dll", EntryPoint = "SHAddToRecentDocs")]
private static extern void _SHAddToRecentDocs_ShellLink(SHARD uFlags, IShellLinkW pv);
public static void SHAddToRecentDocs(string path)
{
NativeMethods._SHAddToRecentDocs_String(SHARD.PATHW, path);
}
public static void SHAddToRecentDocs(IShellLinkW shellLink)
{
NativeMethods._SHAddToRecentDocs_ShellLink(SHARD.LINK, shellLink);
}
[DllImport("dwmapi.dll", EntryPoint = "DwmGetCompositionTimingInfo")]
private static extern HRESULT _DwmGetCompositionTimingInfo(IntPtr hwnd, ref DWM_TIMING_INFO pTimingInfo);
public static DWM_TIMING_INFO? DwmGetCompositionTimingInfo(IntPtr hwnd)
{
if (!Utility.IsOSVistaOrNewer)
{
return null;
}
DWM_TIMING_INFO value = new DWM_TIMING_INFO
{
cbSize = Marshal.SizeOf(typeof(DWM_TIMING_INFO))
};
HRESULT hrLeft = NativeMethods._DwmGetCompositionTimingInfo(hwnd, ref value);
if (hrLeft == HRESULT.E_PENDING)
{
return null;
}
hrLeft.ThrowIfFailed();
return new DWM_TIMING_INFO?(value);
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmInvalidateIconicBitmaps(IntPtr hwnd);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmSetIconicThumbnail(IntPtr hwnd, IntPtr hbmp, DWM_SIT dwSITFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmSetIconicLivePreviewBitmap(IntPtr hwnd, IntPtr hbmp, RefPOINT pptClient, DWM_SIT dwSITFlags);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll", PreserveSig = false)]
public static extern void SHGetItemFromDataObject(IDataObject pdtobj, DOGIF dwFlags, [In] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll", PreserveSig = false)]
public static extern HRESULT SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IBindCtx pbc, [In] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Shell_NotifyIcon(NIM dwMessage, [In] NOTIFYICONDATA lpdata);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll", PreserveSig = false)]
public static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("shell32.dll")]
public static extern HRESULT GetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] out string AppID);
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace Standard
{
internal enum OLECMDEXECOPT
{
DODEFAULT,
PROMPTUSER,
DONTPROMPTUSER,
SHOWHELP
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace Standard
{
internal enum OLECMDF
{
SUPPORTED = 1,
ENABLED,
LATCHED = 4,
NINCHED = 8,
INVISIBLE = 16,
DEFHIDEONCTXTMENU = 32
}
}

View File

@ -0,0 +1,65 @@
using System;
namespace Standard
{
internal enum OLECMDID
{
OPEN = 1,
NEW,
SAVE,
SAVEAS,
SAVECOPYAS,
PRINT,
PRINTPREVIEW,
PAGESETUP,
SPELL,
PROPERTIES,
CUT,
COPY,
PASTE,
PASTESPECIAL,
UNDO,
REDO,
SELECTALL,
CLEARSELECTION,
ZOOM,
GETZOOMRANGE,
UPDATECOMMANDS,
REFRESH,
STOP,
HIDETOOLBARS,
SETPROGRESSMAX,
SETPROGRESSPOS,
SETPROGRESSTEXT,
SETTITLE,
SETDOWNLOADSTATE,
STOPDOWNLOAD,
ONTOOLBARACTIVATED,
FIND,
DELETE,
HTTPEQUIV,
HTTPEQUIV_DONE,
ENABLE_INTERACTION,
ONUNLOAD,
PROPERTYBAG2,
PREREFRESH,
SHOWSCRIPTERROR,
SHOWMESSAGE,
SHOWFIND,
SHOWPAGESETUP,
SHOWPRINT,
CLOSE,
ALLOWUILESSSAVEAS,
DONTDOWNLOADCSS,
UPDATEPAGESTATUS,
PRINT2,
PRINTPREVIEW2,
SETPRINTTEMPLATE,
GETPRINTTEMPLATE,
PAGEACTIONBLOCKED = 55,
PAGEACTIONUIQUERY,
FOCUSVIEWCONTROLS,
FOCUSVIEWCONTROLSQUERY,
SHOWPAGEACTIONMENU
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Runtime.InteropServices;
namespace Standard
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct PKEY
{
public PKEY(Guid fmtid, uint pid)
{
this._fmtid = fmtid;
this._pid = pid;
}
private readonly Guid _fmtid;
private readonly uint _pid;
public static readonly PKEY Title = new PKEY(new Guid("F29F85E0-4FF9-1068-AB91-08002B27B3D9"), 2u);
public static readonly PKEY AppUserModel_ID = new PKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 5u);
public static readonly PKEY AppUserModel_IsDestListSeparator = new PKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 6u);
public static readonly PKEY AppUserModel_RelaunchCommand = new PKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 2u);
public static readonly PKEY AppUserModel_RelaunchDisplayNameResource = new PKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 4u);
public static readonly PKEY AppUserModel_RelaunchIconResource = new PKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 3u);
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Standard
{
internal struct POINT
{
public int x;
public int y;
}
}

View File

@ -0,0 +1,94 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Standard
{
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
[StructLayout(LayoutKind.Explicit)]
internal class PROPVARIANT : IDisposable
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public VarEnum VarType
{
get
{
return (VarEnum)this.vt;
}
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public string GetValue()
{
if (this.vt == 31)
{
return Marshal.PtrToStringUni(this.pointerVal);
}
return null;
}
public void SetValue(bool f)
{
this.Clear();
this.vt = 11;
this.boolVal = (short)(f ? -1 : 0);
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
public void SetValue(string val)
{
this.Clear();
this.vt = 31;
this.pointerVal = Marshal.StringToCoTaskMemUni(val);
}
public void Clear()
{
PROPVARIANT.NativeMethods.PropVariantClear(this);
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
~PROPVARIANT()
{
this.Dispose(false);
}
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "disposing")]
private void Dispose(bool disposing)
{
this.Clear();
}
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[FieldOffset(0)]
private ushort vt;
[SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[FieldOffset(8)]
private IntPtr pointerVal;
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[FieldOffset(8)]
private byte byteVal;
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[FieldOffset(8)]
private long longVal;
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[FieldOffset(8)]
private short boolVal;
private static class NativeMethods
{
[DllImport("ole32.dll")]
internal static extern HRESULT PropVariantClear(PROPVARIANT pvar);
}
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Standard
{
internal enum READYSTATE
{
UNINITIALIZED,
LOADING,
LOADED,
INTERACTIVE,
COMPLETE
}
}

View File

@ -0,0 +1,152 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Standard
{
internal struct RECT
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public void Offset(int dx, int dy)
{
this._left += dx;
this._top += dy;
this._right += dx;
this._bottom += dy;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Left
{
get
{
return this._left;
}
set
{
this._left = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Right
{
get
{
return this._right;
}
set
{
this._right = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Top
{
get
{
return this._top;
}
set
{
this._top = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Bottom
{
get
{
return this._bottom;
}
set
{
this._bottom = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Width
{
get
{
return this._right - this._left;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Height
{
get
{
return this._bottom - this._top;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public POINT Position
{
get
{
return new POINT
{
x = this._left,
y = this._top
};
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public SIZE Size
{
get
{
return new SIZE
{
cx = this.Width,
cy = this.Height
};
}
}
public static RECT Union(RECT rect1, RECT rect2)
{
return new RECT
{
Left = Math.Min(rect1.Left, rect2.Left),
Top = Math.Min(rect1.Top, rect2.Top),
Right = Math.Max(rect1.Right, rect2.Right),
Bottom = Math.Max(rect1.Bottom, rect2.Bottom)
};
}
public override bool Equals(object obj)
{
bool result;
try
{
RECT rect = (RECT)obj;
result = (rect._bottom == this._bottom && rect._left == this._left && rect._right == this._right && rect._top == this._top);
}
catch (InvalidCastException)
{
result = false;
}
return result;
}
public override int GetHashCode()
{
return (this._left << 16 | Utility.LOWORD(this._right)) ^ (this._top << 16 | Utility.LOWORD(this._bottom));
}
private int _left;
private int _top;
private int _right;
private int _bottom;
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Standard
{
internal struct RGBQUAD
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved;
}
}

View File

@ -0,0 +1,13 @@
using System;
namespace Standard
{
internal enum RGN
{
AND = 1,
OR,
XOR,
DIFF,
COPY
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Standard
{
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
[StructLayout(LayoutKind.Sequential)]
internal class RefPOINT
{
public int x;
public int y;
}
}

View File

@ -0,0 +1,107 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Standard
{
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
[StructLayout(LayoutKind.Sequential)]
internal class RefRECT
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public RefRECT(int left, int top, int right, int bottom)
{
this._left = left;
this._top = top;
this._right = right;
this._bottom = bottom;
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Width
{
get
{
return this._right - this._left;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Height
{
get
{
return this._bottom - this._top;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Left
{
get
{
return this._left;
}
set
{
this._left = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Right
{
get
{
return this._right;
}
set
{
this._right = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Top
{
get
{
return this._top;
}
set
{
this._top = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public int Bottom
{
get
{
return this._bottom;
}
set
{
this._bottom = value;
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public void Offset(int dx, int dy)
{
this._left += dx;
this._top += dy;
this._right += dx;
this._bottom += dy;
}
private int _left;
private int _top;
private int _right;
private int _bottom;
}
}

Some files were not shown because too many files have changed in this diff Show More