using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using static Vanara.PInvoke.Ole32; namespace Vanara.PInvoke { public static partial class SearchApi { /// /// Provides a set of flags to be used with following methods to indicate the operation in ICondition::GetComparisonInfo, /// ICondition2::GetLeafConditionInfo, IConditionFactory::MakeLeaf, IConditionFactory2::CreateBooleanLeaf, /// IConditionFactory2::CreateIntegerLeaf, IConditionFactory2::MakeLeaf, IConditionFactory2::CreateStringLeaf, and IConditionGenerator::GenerateForLeaf. /// /// /// /// Provides a set of flags to be used with following methods to indicate the operation in ICondition::GetComparisonInfo, /// ICondition2::GetLeafConditionInfo, IConditionFactory::MakeLeaf, IConditionFactory2::CreateBooleanLeaf, /// IConditionFactory2::CreateIntegerLeaf, IConditionFactory2::MakeLeaf, IConditionFactory2::CreateStringLeaf, and IConditionGenerator::GenerateForLeaf. /// /// /// In Windows 7, this enumeration is defined in structuredquerycondition.idl and structuredquerycondition.h. Prior to Windows 7 this /// enumeration was declared in structuredquery.h and structuredquery.idl. /// /// [PInvokeData("structuredquerycondition.h")] public enum CONDITION_OPERATION { /// /// An implicit comparison between the value of the property and the value of the constant. For an unresolved condition, /// COP_IMPLICIT means that a user did not type an operation. In contrast, a resolved condition will always have a condition /// other than the COP_IMPLICIT operation. /// COP_IMPLICIT, /// The value of the property and the value of the constant must be equal. COP_EQUAL, /// The value of the property and the value of the constant must not be equal. COP_NOTEQUAL, /// The value of the property must be less than the value of the constant. COP_LESSTHAN, /// The value of the property must be greater than the value of the constant. COP_GREATERTHAN, /// The value of the property must be less than or equal to the value of the constant. COP_LESSTHANOREQUAL, /// The value of the property must be greater than or equal to the value of the constant. COP_GREATERTHANOREQUAL, /// The value of the property must begin with the value of the constant. COP_VALUE_STARTSWITH, /// The value of the property must end with the value of the constant. COP_VALUE_ENDSWITH, /// The value of the property must contain the value of the constant. COP_VALUE_CONTAINS, /// The value of the property must not contain the value of the constant. COP_VALUE_NOTCONTAINS, /// /// The value of the property must match the value of the constant, where '?' matches any single character and '*' matches any /// sequence of characters. /// COP_DOSWILDCARDS, /// The value of the property must contain a word that is the value of the constant. COP_WORD_EQUAL, /// The value of the property must contain a word that begins with the value of the constant. COP_WORD_STARTSWITH, /// The application is free to interpret this in any suitable way. COP_APPLICATION_SPECIFIC, } /// /// Provides a set of flags to be used with the following methods to indicate the type of condition tree node: /// ICondition::GetConditionType, IConditionFactory::MakeAndOr, IConditionFactory2::CreateCompoundFromArray, and IConditionFactory2::CreateCompoundFromObjectArray. /// /// /// /// In Windows 7, this enumeration is defined in structuredquerycondition.idl and structuredquerycondition.h. Prior to Windows 7 this /// enumeration was declared in structuredquery.h and structuredquery.idl. /// /// /// The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from the /// console, parse them using the system schema, and display the resulting condition trees. /// /// [PInvokeData("structuredquerycondition.h")] public enum CONDITION_TYPE { /// Indicates that the values of the subterms are combined by "AND". CT_AND_CONDITION, /// Indicates that the values of the subterms are combined by "OR". CT_OR_CONDITION, /// Indicates a "NOT" comparison of subterms. CT_NOT_CONDITION, /// Indicates that the node is a comparison between a property and a constant value using a CONDITION_OPERATION. CT_LEAF_CONDITION, } /// /// Provides methods for retrieving information about a search condition. An ICondition object represents the result of /// parsing an input string (using methods such as IQueryParser::Parse or IQuerySolution::GetQuery) into a tree of search condition /// nodes. A node can be a logical AND, OR, or NOT for comparing subnodes, or it can be a leaf node comparing a property and a /// constant value. /// /// /// /// Prior to Windows 7, this interface was only declared in structuredquery.h and structuredquery.idl. In Windows 7, this interface /// is also defined in structuredquerycondition.idl and structuredquerycondition.h. /// /// /// The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from the /// console, parse them using the system schema, and display the resulting condition trees. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nn-structuredquerycondition-icondition [PInvokeData("structuredquerycondition.h")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0FC988D4-C935-4b97-A973-46282EA175C8")] public interface ICondition : IPersistStream { /// Retrieves the class identifier (CLSID) of the object. /// /// /// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely /// represents an object class that defines the code that can manipulate the object's data. /// /// If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL. /// /// /// /// The GetClassID method retrieves the class identifier (CLSID) for an object, used in later operations to load /// object-specific code into the caller's context. /// /// Notes to Callers /// /// A container application might call this method to retrieve the original CLSID of an object that it is treating as a different /// class. Such a call would be necessary if a user performed an editing operation that required the object to be saved. If the /// container were to save it using the treat-as CLSID, the original application would no longer be able to edit the object. /// Typically, in this case, the container calls the OleSave helper function, which performs all the necessary steps. For this /// reason, most container applications have no need to call this method directly. /// /// /// The exception would be a container that provides an object handler for certain objects. In particular, a container /// application should not get an object's CLSID and then use it to retrieve class specific information from the registry. /// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly /// from the object. /// /// Notes to Implementers /// /// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's /// TreatAs registry key has been set by an application that supports emulation (and so is treating the object as one of a /// different class), a call to GetClassID must supply the CLSID specified in the TreatAs key. For more information /// on emulation, see CoTreatAsClass. /// /// /// When an object is in the running state, the default handler calls an implementation of GetClassID that delegates the /// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg /// function to read the CLSID that is saved in the object's storage. /// /// /// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default /// handler implementation (see OleCreateDefaultHandler). /// /// URL Moniker Notes /// This method returns CLSID_StdURLMoniker. /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID ); new Guid GetClassID(); /// Determines whether an object has changed since it was last saved to its stream. /// This method returns S_OK to indicate that the object has changed. Otherwise, it returns S_FALSE. /// /// /// Use this method to determine whether an object should be saved before closing it. The dirty flag for an object is /// conditionally cleared in the IPersistStream::Save method. /// /// Notes to Callers /// /// You should treat any error return codes as an indication that the object has changed. Unless this method explicitly returns /// S_FALSE, assume that the object must be saved. /// /// /// Note that the OLE-provided implementations of the IPersistStream::IsDirty method in the OLE-provided moniker /// interfaces always return S_FALSE because their internal state never changes. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-isdirty HRESULT IsDirty( ); [PreserveSig] new HRESULT IsDirty(); /// Initializes an object from the stream where it was saved previously. /// The PSTM. /// /// /// This method loads an object from its associated stream. The seek pointer is set as it was in the most recent /// IPersistStream::Save method. This method can seek and read from the stream, but cannot write to it. /// /// Notes to Callers /// /// Rather than calling IPersistStream::Load directly, you typically call the OleLoadFromStream function does the following: /// /// /// /// Calls the ReadClassStm function to get the class identifier from the stream. /// /// /// Calls the CoCreateInstance function to create an instance of the object. /// /// /// Queries the instance for IPersistStream. /// /// /// Calls IPersistStream::Load. /// /// /// /// The OleLoadFromStream function assumes that objects are stored in the stream with a class identifier followed by the object /// data. This storage pattern is used by the generic, composite-moniker implementation provided by OLE. /// /// If the objects are not stored using this pattern, you must call the methods separately yourself. /// URL Moniker Notes /// /// Initializes an URL moniker from data within a stream, usually stored there previously using its IPersistStream::Save (using /// OleSaveToStream). The binary format of the URL moniker is its URL string in Unicode (may be a full or partial URL string, see /// CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that many Unicode characters. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-load HRESULT Load( IStream *pStm ); new void Load([In, MarshalAs(UnmanagedType.Interface)] IStream pstm); /// Saves an object to the specified stream. /// The PSTM. /// /// Indicates whether to clear the dirty flag after the save is complete. If TRUE, the flag should be cleared. If /// FALSE, the flag should be left unchanged. /// /// /// /// IPersistStream::Save saves an object into the specified stream and indicates whether the object should reset its dirty flag. /// /// /// The seek pointer is positioned at the location in the stream at which the object should begin writing its data. The object /// calls the ISequentialStream::Write method to write its data. /// /// /// On exit, the seek pointer must be positioned immediately past the object data. The position of the seek pointer is undefined /// if an error returns. /// /// Notes to Callers /// /// Rather than calling IPersistStream::Save directly, you typically call the OleSaveToStream helper function which does /// the following: /// /// /// /// Calls GetClassID to get the object's CLSID. /// /// /// Calls the WriteClassStm function to write the object's CLSID to the stream. /// /// /// Calls IPersistStream::Save. /// /// /// If you call these methods directly, you can write other data into the stream after the CLSID before calling IPersistStream::Save. /// The OLE-provided implementation of IPersistStream follows this same pattern. /// Notes to Implementers /// /// The IPersistStream::Save method does not write the CLSID to the stream. The caller is responsible for writing the CLSID. /// /// /// The IPersistStream::Save method can read from, write to, and seek in the stream; but it must not seek to a location in /// the stream before that of the seek pointer on entry. /// /// URL Moniker Notes /// /// Saves an URL moniker to a stream. The binary format of URL moniker is its URL string in Unicode (may be a full or partial URL /// string, see CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that many /// Unicode characters. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-save HRESULT Save( IStream *pStm, BOOL // fClearDirty ); new void Save([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.Bool)] bool fClearDirty); /// Retrieves the size of the stream needed to save the object. /// The size in bytes of the stream needed to save this object, in bytes. /// /// /// This method returns the size needed to save an object. You can call this method to determine the size and set the necessary /// buffers before calling the IPersistStream::Save method. /// /// Notes to Implementers /// /// The GetSizeMax implementation should return a conservative estimate of the necessary size because the caller might /// call the IPersistStream::Save method with a non-growable stream. /// /// URL Moniker Notes /// /// This method retrieves the maximum number of bytes in the stream that will be required by a subsequent call to /// IPersistStream::Save. This value is sizeof(ULONG)==4 plus sizeof(WCHAR)*n where n is the length of the full or partial URL /// string, including the NULL terminator. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-getsizemax HRESULT GetSizeMax( // ULARGE_INTEGER *pcbSize ); new ulong GetSizeMax(); /// /// Retrieves the condition type for this search condition node, identifying it as a logical AND, OR, or NOT, or as a leaf node. /// /// /// Type: CONDITION_TYPE* /// Receives the CONDITION_TYPE enumeration for this node. /// /// /// The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from /// the console, parse them using the system schema, and display the resulting condition trees. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getconditiontype // HRESULT GetConditionType( CONDITION_TYPE *pNodeType ); CONDITION_TYPE GetConditionType(); /// /// Retrieves a collection of the subconditions of the search condition node and the IID of the interface for enumerating the collection. /// /// /// Type: REFIID /// /// The desired IID of the enumerating interface: either IID_IEnumUnknown, IID_IEnumVARIANT or (for a negation condition) IID_ICondition. /// /// /// /// Receives a collection of zero or more ICondition objects. Each object is a subcondition of this condition node. If was IID_ICondition and this is a negation condition, this parameter receives the single subcondition. /// /// /// /// The parameter must be the GUID of an IEnumUnknown or IEnumVARIANT interface or in the case of /// a negation node, IID_ICondition. /// /// If the subcondition is a negation node, the return value is set to an enumeration of one element. /// If the node is a conjunction or disjunction node, the return value is set to an enumeration of the subconditions. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getsubconditions // HRESULT GetSubConditions( REFIID riid, void **ppv ); [return: MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] object GetSubConditions(in Guid riid); /// Retrieves the property name, operation, and value from a leaf search condition node. /// /// Type: LPWSTR* /// Receives the name of the property of the leaf condition as a Unicode string. /// /// /// Type: CONDITION_OPERATION* /// Receives the operation of the leaf condition as a CONDITION_OPERATION enumeration. /// /// /// Type: PROPVARIANT* /// Receives the value of the leaf condition as a PROPVARIANT. /// /// Any or all of the three parameters can be NULL. // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getcomparisoninfo // HRESULT GetComparisonInfo( LPWSTR *ppszPropertyName, CONDITION_OPERATION *pcop, PROPVARIANT *ppropvar ); void GetComparisonInfo([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszPropertyName, out CONDITION_OPERATION pcop, [In, Out] PROPVARIANT ppropvar); /// Retrieves the semantic type of the value of the search condition node. /// /// Type: LPWSTR* /// Receives either a pointer to the semantic type of the value as a Unicode string or NULL. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getvaluetype // HRESULT GetValueType( LPWSTR *ppszValueTypeName ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetValueType(); /// Retrieves the character-normalized value of the search condition node. /// /// Type: LPWSTR* /// Receives a pointer to a Unicode string representation of the value. /// /// /// In Windows 7 and later, if the value of the leaf node is VT_EMPTY, ppwszNormalization points to an empty /// string. If the value is a string, such as VT_LPWSTR, VT_BSTR or VT_LPSTR, then ppwszNormalization is set to a /// character-normalized form of the value. In other cases, ppwszNormalization is set to some other character-normalized string /// representation of the value. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getvaluenormalization // HRESULT GetValueNormalization( LPWSTR *ppszNormalization ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetValueNormalization(); /// /// For a leaf node, ICondition::GetInputTerms retrieves information about what parts (or ranges) of the input string /// produced the property, the operation, and the value for the search condition node. /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// property of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// operation of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// value of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Any or all of the parameters ppPropertyTerm, ppOperationTerm and ppValueTerm can be NULL. /// /// Each IRichChunk object retrieved by this method represents a range of tokens from the input string. The range tokens /// identifies the substring that produced the property, operation, or value of the input string. The IRichChunk's /// PROPVARIANT out parameter is not used. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getinputterms // HRESULT GetInputTerms( IRichChunk **ppPropertyTerm, IRichChunk **ppOperationTerm, IRichChunk **ppValueTerm ); void GetInputTerms(out IRichChunk ppPropertyTerm, out IRichChunk ppOperationTerm, out IRichChunk ppValueTerm); /// Creates a deep copy of this ICondition object. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Because there are no methods for modifying an ICondition, there are few occasions when this method is necessary. In many /// cases it is adequate to call the IUnknown::QueryInterface method on the ICondition to obtain an additional reference /// to the same object. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-clone // HRESULT Clone( ICondition **ppc ); ICondition Clone(); } /// /// Extends the functionality of the ICondition interface. ICondition2 provides methods for retrieving information about a search condition. /// /// /// /// The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from the console, parse them using the system schema, and display the resulting condition trees. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nn-structuredquerycondition-icondition2 [PInvokeData("structuredquerycondition.h", MSDNShortId = "")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0DB8851D-2E5B-47eb-9208-D28C325A01D7")] public interface ICondition2 : ICondition { /// Retrieves the class identifier (CLSID) of the object. /// /// /// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely /// represents an object class that defines the code that can manipulate the object's data. /// /// If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL. /// /// /// /// The GetClassID method retrieves the class identifier (CLSID) for an object, used in later operations to load /// object-specific code into the caller's context. /// /// Notes to Callers /// /// A container application might call this method to retrieve the original CLSID of an object that it is treating as a different /// class. Such a call would be necessary if a user performed an editing operation that required the object to be saved. If the /// container were to save it using the treat-as CLSID, the original application would no longer be able to edit the object. /// Typically, in this case, the container calls the OleSave helper function, which performs all the necessary steps. For this /// reason, most container applications have no need to call this method directly. /// /// /// The exception would be a container that provides an object handler for certain objects. In particular, a container /// application should not get an object's CLSID and then use it to retrieve class specific information from the registry. /// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly /// from the object. /// /// Notes to Implementers /// /// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's /// TreatAs registry key has been set by an application that supports emulation (and so is treating the object as one of a /// different class), a call to GetClassID must supply the CLSID specified in the TreatAs key. For more information /// on emulation, see CoTreatAsClass. /// /// /// When an object is in the running state, the default handler calls an implementation of GetClassID that delegates the /// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg /// function to read the CLSID that is saved in the object's storage. /// /// /// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default /// handler implementation (see OleCreateDefaultHandler). /// /// URL Moniker Notes /// This method returns CLSID_StdURLMoniker. /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID ); new Guid GetClassID(); /// Determines whether an object has changed since it was last saved to its stream. /// This method returns S_OK to indicate that the object has changed. Otherwise, it returns S_FALSE. /// /// /// Use this method to determine whether an object should be saved before closing it. The dirty flag for an object is /// conditionally cleared in the IPersistStream::Save method. /// /// Notes to Callers /// /// You should treat any error return codes as an indication that the object has changed. Unless this method explicitly returns /// S_FALSE, assume that the object must be saved. /// /// /// Note that the OLE-provided implementations of the IPersistStream::IsDirty method in the OLE-provided moniker /// interfaces always return S_FALSE because their internal state never changes. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-isdirty HRESULT IsDirty( ); [PreserveSig] new HRESULT IsDirty(); /// Initializes an object from the stream where it was saved previously. /// The PSTM. /// /// /// This method loads an object from its associated stream. The seek pointer is set as it was in the most recent /// IPersistStream::Save method. This method can seek and read from the stream, but cannot write to it. /// /// Notes to Callers /// /// Rather than calling IPersistStream::Load directly, you typically call the OleLoadFromStream function does the following: /// /// /// /// Calls the ReadClassStm function to get the class identifier from the stream. /// /// /// Calls the CoCreateInstance function to create an instance of the object. /// /// /// Queries the instance for IPersistStream. /// /// /// Calls IPersistStream::Load. /// /// /// /// The OleLoadFromStream function assumes that objects are stored in the stream with a class identifier followed by the object /// data. This storage pattern is used by the generic, composite-moniker implementation provided by OLE. /// /// If the objects are not stored using this pattern, you must call the methods separately yourself. /// URL Moniker Notes /// /// Initializes an URL moniker from data within a stream, usually stored there previously using its IPersistStream::Save (using /// OleSaveToStream). The binary format of the URL moniker is its URL string in Unicode (may be a full or partial URL string, see /// CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that many Unicode characters. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-load HRESULT Load( IStream *pStm ); new void Load([In, MarshalAs(UnmanagedType.Interface)] IStream pstm); /// Saves an object to the specified stream. /// The PSTM. /// /// Indicates whether to clear the dirty flag after the save is complete. If TRUE, the flag should be cleared. If /// FALSE, the flag should be left unchanged. /// /// /// /// IPersistStream::Save saves an object into the specified stream and indicates whether the object should reset its dirty flag. /// /// /// The seek pointer is positioned at the location in the stream at which the object should begin writing its data. The object /// calls the ISequentialStream::Write method to write its data. /// /// /// On exit, the seek pointer must be positioned immediately past the object data. The position of the seek pointer is undefined /// if an error returns. /// /// Notes to Callers /// /// Rather than calling IPersistStream::Save directly, you typically call the OleSaveToStream helper function which does /// the following: /// /// /// /// Calls GetClassID to get the object's CLSID. /// /// /// Calls the WriteClassStm function to write the object's CLSID to the stream. /// /// /// Calls IPersistStream::Save. /// /// /// If you call these methods directly, you can write other data into the stream after the CLSID before calling IPersistStream::Save. /// The OLE-provided implementation of IPersistStream follows this same pattern. /// Notes to Implementers /// /// The IPersistStream::Save method does not write the CLSID to the stream. The caller is responsible for writing the CLSID. /// /// /// The IPersistStream::Save method can read from, write to, and seek in the stream; but it must not seek to a location in /// the stream before that of the seek pointer on entry. /// /// URL Moniker Notes /// /// Saves an URL moniker to a stream. The binary format of URL moniker is its URL string in Unicode (may be a full or partial URL /// string, see CreateURLMonikerEx for details). This is represented as a ULONG count of characters followed by that many /// Unicode characters. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-save HRESULT Save( IStream *pStm, BOOL // fClearDirty ); new void Save([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.Bool)] bool fClearDirty); /// Retrieves the size of the stream needed to save the object. /// The size in bytes of the stream needed to save this object, in bytes. /// /// /// This method returns the size needed to save an object. You can call this method to determine the size and set the necessary /// buffers before calling the IPersistStream::Save method. /// /// Notes to Implementers /// /// The GetSizeMax implementation should return a conservative estimate of the necessary size because the caller might /// call the IPersistStream::Save method with a non-growable stream. /// /// URL Moniker Notes /// /// This method retrieves the maximum number of bytes in the stream that will be required by a subsequent call to /// IPersistStream::Save. This value is sizeof(ULONG)==4 plus sizeof(WCHAR)*n where n is the length of the full or partial URL /// string, including the NULL terminator. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersiststream-getsizemax HRESULT GetSizeMax( // ULARGE_INTEGER *pcbSize ); new ulong GetSizeMax(); /// /// Retrieves the condition type for this search condition node, identifying it as a logical AND, OR, or NOT, or as a leaf node. /// /// /// Type: CONDITION_TYPE* /// Receives the CONDITION_TYPE enumeration for this node. /// /// /// The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from /// the console, parse them using the system schema, and display the resulting condition trees. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getconditiontype // HRESULT GetConditionType( CONDITION_TYPE *pNodeType ); new CONDITION_TYPE GetConditionType(); /// /// Retrieves a collection of the subconditions of the search condition node and the IID of the interface for enumerating the collection. /// /// /// Type: REFIID /// /// The desired IID of the enumerating interface: either IID_IEnumUnknown, IID_IEnumVARIANT or (for a negation condition) IID_ICondition. /// /// /// /// Receives a collection of zero or more ICondition objects. Each object is a subcondition of this condition node. If was IID_ICondition and this is a negation condition, this parameter receives the single subcondition. /// /// /// /// The parameter must be the GUID of an IEnumUnknown or IEnumVARIANT interface or in the case of /// a negation node, IID_ICondition. /// /// If the subcondition is a negation node, the return value is set to an enumeration of one element. /// If the node is a conjunction or disjunction node, the return value is set to an enumeration of the subconditions. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getsubconditions // HRESULT GetSubConditions( REFIID riid, void **ppv ); [return: MarshalAs(UnmanagedType.IUnknown)] new object GetSubConditions(in Guid riid); /// Retrieves the property name, operation, and value from a leaf search condition node. /// /// Type: LPWSTR* /// Receives the name of the property of the leaf condition as a Unicode string. /// /// /// Type: CONDITION_OPERATION* /// Receives the operation of the leaf condition as a CONDITION_OPERATION enumeration. /// /// /// Type: PROPVARIANT* /// Receives the value of the leaf condition as a PROPVARIANT. /// /// Any or all of the three parameters can be NULL. // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getcomparisoninfo // HRESULT GetComparisonInfo( LPWSTR *ppszPropertyName, CONDITION_OPERATION *pcop, PROPVARIANT *ppropvar ); new void GetComparisonInfo([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszPropertyName, out CONDITION_OPERATION pcop, [In, Out] PROPVARIANT ppropvar); /// Retrieves the semantic type of the value of the search condition node. /// /// Type: LPWSTR* /// Receives either a pointer to the semantic type of the value as a Unicode string or NULL. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getvaluetype // HRESULT GetValueType( LPWSTR *ppszValueTypeName ); [return: MarshalAs(UnmanagedType.LPWStr)] new string GetValueType(); /// Retrieves the character-normalized value of the search condition node. /// /// Type: LPWSTR* /// Receives a pointer to a Unicode string representation of the value. /// /// /// In Windows 7 and later, if the value of the leaf node is VT_EMPTY, ppwszNormalization points to an empty /// string. If the value is a string, such as VT_LPWSTR, VT_BSTR or VT_LPSTR, then ppwszNormalization is set to a /// character-normalized form of the value. In other cases, ppwszNormalization is set to some other character-normalized string /// representation of the value. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getvaluenormalization // HRESULT GetValueNormalization( LPWSTR *ppszNormalization ); [return: MarshalAs(UnmanagedType.LPWStr)] new string GetValueNormalization(); /// /// For a leaf node, ICondition::GetInputTerms retrieves information about what parts (or ranges) of the input string /// produced the property, the operation, and the value for the search condition node. /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// property of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// operation of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Type: IRichChunk** /// /// Receives a pointer to an IRichChunk interface that provides information about what part of the input string produced the /// value of the leaf node, if that can be determined; otherwise, this parameter is set to NULL. /// /// /// /// Any or all of the parameters ppPropertyTerm, ppOperationTerm and ppValueTerm can be NULL. /// /// Each IRichChunk object retrieved by this method represents a range of tokens from the input string. The range tokens /// identifies the substring that produced the property, operation, or value of the input string. The IRichChunk's /// PROPVARIANT out parameter is not used. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getinputterms // HRESULT GetInputTerms( IRichChunk **ppPropertyTerm, IRichChunk **ppOperationTerm, IRichChunk **ppValueTerm ); new void GetInputTerms(out IRichChunk ppPropertyTerm, out IRichChunk ppOperationTerm, out IRichChunk ppValueTerm); /// Creates a deep copy of this ICondition object. /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Because there are no methods for modifying an ICondition, there are few occasions when this method is necessary. In many /// cases it is adequate to call the IUnknown::QueryInterface method on the ICondition to obtain an additional reference /// to the same object. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-clone // HRESULT Clone( ICondition **ppc ); new ICondition Clone(); /// /// Retrieves the property name, operation, and value from a leaf search condition node. /// /// /// Type: LPWSTR* /// Receives the name of the locale of the leaf condition as a Unicode string. This parameter can be NULL. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition2-getlocale // HRESULT GetLocale( LPWSTR *ppszLocaleName ); [PInvokeData("structuredquerycondition.h", MSDNShortId = "")] string GetLocale(); /// /// Retrieves the property name, operation, and value from a leaf search condition node. /// /// Type: PROPERTYKEY*Receives the name of the property of the leaf condition as a PROPERTYKEY. /// Type: CONDITION_OPERATION*Receives the operation of the leaf condition as a CONDITION_OPERATION enumeration. /// Type: PROPVARIANT*Receives the property value of the leaf condition as a PROPVARIANT. /// /// Any or all of the three parameters can be NULL.The StructuredQuerySample code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to read lines from the console, parse them using the system schema, and display the resulting condition trees. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition2-getleafconditioninfo // HRESULT GetLeafConditionInfo( PROPERTYKEY *ppropkey, CONDITION_OPERATION *pcop, PROPVARIANT *ppropvar ); [PInvokeData("structuredquerycondition.h", MSDNShortId = "")] void GetLeafConditionInfo(out PROPERTYKEY ppropkey, out CONDITION_OPERATION pcop, [Out] PROPVARIANT ppropvar); } /// Represents a chunk of data as a string and a PROPVARIANT value. /// /// In Windows 7, this interface is defined in structuredquerycondition.idl and structuredquerycondition.h. Prior to Windows 7 this /// interface was declared in structuredquery.h and structuredquery.idl. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nn-structuredquerycondition-irichchunk [PInvokeData("structuredquerycondition.h")] [ComImport, Guid("4FDEF69C-DBC9-454e-9910-B34F3C64B510"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IRichChunk { /// /// Retrieves the PROPVARIANT and input string that represents a chunk of data. /// /// /// Type: ULONG* /// Receives the zero-based starting position of the range. This parameter can be NULL. /// /// /// Type: ULONG* /// Receives the length of the range. This parameter can be NULL. /// /// /// Type: LPWSTR* /// Receives the associated Unicode string value, or NULL if not available. /// /// /// Type: PROPVARIANT* /// Receives the associated PROPVARIANT value, or VT_EMPTY if not available. This parameter can be NULL. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Prior to Windows 7, this was declared in structuredquery.idl and structuredquery.h. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-irichchunk-getdata // HRESULT GetData( ULONG *pFirstPos, ULONG *pLength, LPWSTR *ppsz, PROPVARIANT *pValue ); void GetData(out uint pFirstPos, out uint pLength, [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppsz, [In, Out] PROPVARIANT pValue); } /// /// Retrieves a collection of the subconditions of the search condition node and the IID of the interface for enumerating the collection. /// /// /// The desired type of the enumerating interface: either IID_IEnumUnknown, IID_IEnumVARIANT or (for a negation condition) IID_ICondition. /// /// The instance. /// /// Receives a collection of zero or more ICondition objects. Each object is a subcondition of this condition node. If /// was IID_ICondition and this is a negation condition, this parameter receives the single subcondition. /// /// /// If the subcondition is a negation node, the return value is set to an enumeration of one element. /// If the node is a conjunction or disjunction node, the return value is set to an enumeration of the subconditions. /// // https://docs.microsoft.com/en-us/windows/desktop/api/structuredquerycondition/nf-structuredquerycondition-icondition-getsubconditions // HRESULT GetSubConditions( REFIID riid, void **ppv ); public static T GetSubConditions(this ICondition c) where T : class => (T)c.GetSubConditions(typeof(T).GUID); } }