using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Ole32
{
/// Browsable Shell Extention
public static readonly Guid CATID_BrowsableShellExt = new Guid(0x00021490, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
/// The catid browse in place
public static readonly Guid CATID_BrowseInPlace = new Guid(0x00021491, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
/// Desk Band
public static readonly Guid CATID_DeskBand = new Guid(0x00021492, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
/// Vertical Explorer Bar
public static readonly Guid CATID_InfoBand = new Guid(0x00021493, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
/// Horizontal Explorer Bar
public static readonly Guid CATID_CommBand = new Guid(0x00021494, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
///
/// Obtains information about the categories implemented or required by a certain class, as well as information about the categories
/// registered on the specified computer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nn-comcat-icatinformation
[PInvokeData("comcat.h", MSDNShortId = "NN:comcat.ICatInformation")]
[ComImport, Guid("0002E013-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(StdComponentCategoriesMgr))]
public interface ICatInformation
{
/// Retrieves an enumerator for the component categories registered on the system.
///
/// The requested locale for any return szDescription of the enumerated categories. Typically, the caller specifies the value
/// returned from the GetUserDefaultLCID function.
///
///
/// A pointer to a pointer to an IEnumCATEGORYINFO interface. This can be used to enumerate the CATIDs and localized description
/// strings of the component categories registered with the system.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-enumcategories HRESULT EnumCategories(
// LCID lcid, IEnumCATEGORYINFO **ppenumCategoryInfo );
IEnumCATEGORYINFO EnumCategories(LCID lcid);
/// Retrieves the localized description string for a specific category ID.
/// The category identifier.
/// The locale.
///
/// A pointer to the string pointer for the description. This string must be released by the caller using the CoTaskMemFree function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-getcategorydesc HRESULT GetCategoryDesc(
// REFCATID rcatid, LCID lcid, LPWSTR *pszDesc );
void GetCategoryDesc(in Guid rcatid, LCID lcid, [MarshalAs(UnmanagedType.LPWStr)] out string pszDesc);
/// Retrieves an enumerator for the classes that implement one or more specified category identifiers.
///
/// The number of category IDs in the rgcatidImpl array. This value cannot be zero. If this value is -1, classes are included in
/// the enumeration, regardless of the categories they implement.
///
///
/// An array of category identifiers.
/// If a class requires a category identifier that is not specified, it is not included in the enumeration.
///
///
/// The number of category IDs in the rgcatidReq array. This value can be zero. If this value is -1, classes are included in the
/// enumeration, regardless of the categories they require.
///
/// An array of category identifiers.
///
/// A pointer to an IEnumCLSID interface pointer that can be used to enumerate the CLSIDs of the classes that implement the
/// specified category.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-enumclassesofcategories HRESULT
// EnumClassesOfCategories( ULONG cImplemented, const CATID [] rgcatidImpl, ULONG cRequired, const CATID [] rgcatidReq,
// IEnumGUID **ppenumClsid );
IEnumGUID EnumClassesOfCategories(uint cImplemented, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] Guid[] rgcatidImpl, uint cRequired, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] rgcatidReq);
/// Determines whether a class implements one or more categories.
/// The class identifier.
///
/// The number of category IDs in the rgcatidImpl array. This value cannot be zero. If this value is -1, the implemented
/// categories are not tested.
///
///
/// An array of category identifiers.
/// If the class requires a category not listed in rgcatidReq, it is not included in the enumeration.
///
///
/// The number of category IDs in the rgcatidReq array. This value can be zero. If this value is -1, the required categories are
/// not tested.
///
/// An array of category identifiers.
/// If the class ID is of one of the specified categories, the return value is S_OK. Otherwise, is it S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-isclassofcategories HRESULT
// IsClassOfCategories( REFCLSID rclsid, ULONG cImplemented, const CATID [] rgcatidImpl, ULONG cRequired, const CATID []
// rgcatidReq );
[PreserveSig]
HRESULT IsClassOfCategories(in Guid rclsid, uint cImplemented, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] rgcatidImpl, uint cRequired, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] Guid[] rgcatidReq);
/// Retrieves an enumerator for the CATIDs implemented by the specified class.
/// The class ID.
///
/// A pointer to an IEnumCATID interface pointer. This can be used to enumerate the CATIDs that are implemented by rclsid.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-enumimplcategoriesofclass HRESULT
// EnumImplCategoriesOfClass( REFCLSID rclsid, IEnumGUID **ppenumCatid );
IEnumGUID EnumImplCategoriesOfClass(in Guid rclsid);
/// Retrieves an enumerator for the CATIDs required by the specified class.
/// The class identifier.
///
/// A pointer to an IEnumCATID interface pointer. This can be used to enumerate the CATIDs that are required by rclsid.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatinformation-enumreqcategoriesofclass HRESULT
// EnumReqCategoriesOfClass( REFCLSID rclsid, IEnumGUID **ppenumCatid );
IEnumGUID EnumReqCategoriesOfClass(in Guid rclsid);
}
///
/// Provides methods for registering and unregistering component category information in the registry. This includes both the
/// human-readable names of categories and the categories implemented/required by a given component or class.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nn-comcat-icatregister
[ComImport, Guid("0002E012-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(StdComponentCategoriesMgr))]
public interface ICatRegister
{
///
/// Registers one or more component categories. Each component category consists of a CATID and a list of locale-dependent
/// description strings.
///
/// The number of component categories to be registered.
///
/// An array of CATEGORYINFO structures, one for each category to be registered. By providing the same CATID for multiple
/// CATEGORYINFO structures, multiple locales can be registered for the same component category.
///
///
/// This method can only be called by the owner of a category, usually as part of the installation or de-installation of the
/// operating system or application.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-registercategories HRESULT
// RegisterCategories( ULONG cCategories, CATEGORYINFO [] rgCategoryInfo );
void RegisterCategories(uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] CATEGORYINFO[] rgCategoryInfo);
///
/// Removes the registration of one or more component categories. Each component category consists of a CATID and a list of
/// locale-dependent description strings.
///
/// The number of categories to be removed.
/// The CATIDs of the categories to be removed.
///
///
/// This method will be successful even if one or more of the category IDs specified are not registered. This method can only be
/// called by the owner of a category, usually as part of the installation or de-installation of the operating system or application.
///
///
/// This method does not remove the component category tags from individual classes. To do this, use the
/// ICatRegister::UnRegisterClassReqCategories method.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-unregistercategories HRESULT
// UnRegisterCategories( ULONG cCategories, CATID [] rgcatid );
void UnRegisterCategories(uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] Guid[] rgcatid);
/// Registers the class as implementing one or more component categories.
/// The class identifier.
/// The number of categories to be associated as category identifiers for the class.
/// An array of CATIDs to associate as category identifiers for the class.
///
/// In case of an error, this method does not ensure that the registry is restored to the state prior to the call. This method
/// can only be called by the owner of a class, usually as part of the installation of the component.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-registerclassimplcategories HRESULT
// RegisterClassImplCategories( REFCLSID rclsid, ULONG cCategories, CATID [] rgcatid );
void RegisterClassImplCategories(in Guid rclsid, uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] rgcatid);
/// Removes one or more implemented category identifiers from a class.
/// The class identifier.
/// The number of category CATIDs to be removed.
/// An array of CATIDs that are to be removed. Only the category IDs specified in this array are removed.
///
/// In case of an error, this method does not ensure that the registry is restored to the state prior to the call. This method
/// will be successful even if one or more of the category IDs specified are not registered for the class. This method can only
/// be called by the owner of a class, usually as part of the de-installation of the component.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-unregisterclassimplcategories HRESULT
// UnRegisterClassImplCategories( REFCLSID rclsid, ULONG cCategories, CATID [] rgcatid );
void UnRegisterClassImplCategories(in Guid rclsid, uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] rgcatid);
/// Registers the class as requiring one or more component categories.
/// The class identifier.
/// The number of category CATIDs to be associated as category identifiers for the class.
/// An array of CATIDs to be associated as category identifiers for the class.
///
/// In case of an error, this method does not ensure that the registry is restored to the state prior to the call. This method
/// can only be called by the owner of a class, usually as part of the installation of the component.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-registerclassreqcategories HRESULT
// RegisterClassReqCategories( REFCLSID rclsid, ULONG cCategories, CATID [] rgcatid );
void RegisterClassReqCategories(in Guid rclsid, uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] rgcatid);
/// Removes one or more required category identifiers from a class.
/// The class identifier.
/// The number of category CATIDs to be removed.
/// An array of CATIDs that are to be removed. Only the category IDs specified in this array are removed.
///
/// In case of an error, this method does not ensure that the registry is restored to the state prior to the call. This method
/// will be successful even if one or more of the category IDs specified are not registered for the class.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-icatregister-unregisterclassreqcategories HRESULT
// UnRegisterClassReqCategories( REFCLSID rclsid, ULONG cCategories, CATID [] rgcatid );
void UnRegisterClassReqCategories(in Guid rclsid, uint cCategories, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Guid[] rgcatid);
}
/// Enumerates component categories registered in the system.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nn-comcat-ienumcategoryinfo
[ComImport, Guid("0002E011-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumCATEGORYINFO : Vanara.Collections.ICOMEnum
{
/// Retrieves the specified number of items in the enumeration sequence.
///
/// The number of items to be retrieved. If there are fewer than the requested number of items left in the sequence, this method
/// retrieves the remaining elements.
///
///
/// An array of enumerated items.
///
/// The enumerator is responsible for allocating any memory, and the caller is responsible for freeing it. If celt is greater
/// than 1, the caller must also pass a non-NULL pointer passed to pceltFetched to know how many pointers to release.
///
///
///
/// The number of items that were retrieved. This parameter is always less than or equal to the number of items requested.
///
/// If the method retrieves the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumcategoryinfo-next HRESULT Next( ULONG celt,
// CATEGORYINFO *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] CATEGORYINFO[] rgelt, out uint pceltFetched);
/// Skips over the specified number of items in the enumeration sequence.
/// The number of items to be skipped.
/// If the method skips the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumcategoryinfo-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// Resets the enumeration sequence to the beginning.
///
/// There is no guarantee that the same set of objects will be enumerated after the reset operation has completed. A static
/// collection is reset to the beginning, but it can be too expensive for some collections, such as files in a directory, to
/// guarantee this condition.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumcategoryinfo-reset HRESULT Reset();
void Reset();
///
/// Creates a new enumerator that contains the same enumeration state as the current one.
///
/// This method makes it possible to record a point in the enumeration sequence in order to return to that point at a later
/// time. The caller must release this new enumerator separately from the first enumerator.
///
///
/// A pointer to the cloned enumerator object.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumcategoryinfo-clone HRESULT Clone( IEnumCATEGORYINFO
// **ppenum );
IEnumCATEGORYINFO Clone();
}
/// Enables clients to enumerate through a collection of class IDs for COM classes.
/// Alternate names for this interface are IEnumCLSID and IEnumCATID.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nn-comcat-ienumguid
[PInvokeData("comcat.h", MSDNShortId = "NN:comcat.IEnumGUID")]
[ComImport, Guid("0002E000-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumGUID : Vanara.Collections.ICOMEnum
{
/// Retrieves the specified number of items in the enumeration sequence.
///
/// The number of items to be retrieved. If there are fewer than the requested number of items left in the sequence, this method
/// retrieves the remaining elements.
///
///
/// An array of enumerated items.
///
/// The enumerator is responsible for allocating any memory, and the caller is responsible for freeing it. If celt is greater
/// than 1, the caller must also pass a non-NULL pointer passed to pceltFetched to know how many pointers to release.
///
///
///
/// The number of items that were retrieved. This parameter is always less than or equal to the number of items requested.
///
/// If the method retrieves the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumguid-next HRESULT Next( ULONG celt, GUID *rgelt,
// ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] Guid[] rgelt, out uint pceltFetched);
/// Skips over the specified number of items in the enumeration sequence.
/// The number of items to be skipped.
/// If the method skips the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumguid-skip HRESULT Skip( ULONG celt );
[PreserveSig]
HRESULT Skip(uint celt);
/// Resets the enumeration sequence to the beginning.
///
/// There is no guarantee that the same set of objects will be enumerated after the reset operation has completed. A static
/// collection is reset to the beginning, but it can be too expensive for some collections, such as files in a directory, to
/// guarantee this condition.
///
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumguid-reset HRESULT Reset();
void Reset();
///
/// Creates a new enumerator that contains the same enumeration state as the current one.
///
/// This method makes it possible to record a point in the enumeration sequence in order to return to that point at a later
/// time. The caller must release this new enumerator separately from the first enumerator.
///
///
/// A pointer to the cloned enumerator object.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumguid-clone HRESULT Clone( IEnumGUID **ppenum );
IEnumGUID Clone();
}
/// Describes a component category.
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/ns-comcat-categoryinfo typedef struct tagCATEGORYINFO { Guid catid;
// LCID lcid; OLECHAR szDescription[128]; } CATEGORYINFO, *LPCATEGORYINFO;
[PInvokeData("comcat.h", MSDNShortId = "NS:comcat.tagCATEGORYINFO")]
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
public struct CATEGORYINFO
{
/// The category identifier for the component.
public Guid catid;
/// The locale identifier. See Language Identifier Constants and Strings.
public LCID lcid;
/// The description of the category (cannot exceed 128 characters).
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szDescription;
}
/// Implements CLSID_StdComponentCategoriesMgr.
[ComImport, Guid("0002E005-0000-0000-C000-000000000046"), ClassInterface(ClassInterfaceType.None)]
public class StdComponentCategoriesMgr { }
}
}