using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using Vanara.Extensions.Reflection; using Vanara.InteropServices; using static Vanara.PInvoke.Crypt32; using static Vanara.PInvoke.UrlMon; namespace Vanara.PInvoke { /// Interfaces from the Microsoft Packaging API for Open Packaging. public static partial class Opc { /// Describes the canonicalization method to be applied to XML markup. /// /// For more information about XML canonicalization, see the W3C Recommendation, Canonical XML Version 1.0 (http://go.microsoft.com/fwlink/p/?linkid=125240). /// /// For more information about canonicalization and packages, see the ECMA-376 OpenXML, 1st Edition, Part 2: Open Packaging /// Conventions (OPC). /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_canonicalization_method typedef enum // __MIDL___MIDL_itf_msopc_0001_0076_0001 { OPC_CANONICALIZATION_NONE, OPC_CANONICALIZATION_C14N, // OPC_CANONICALIZATION_C14N_WITH_COMMENTS } OPC_CANONICALIZATION_METHOD; [PInvokeData("msopc.h", MSDNShortId = "f8401d12-da2e-4b35-b473-ebe3d1f91abd")] public enum OPC_CANONICALIZATION_METHOD { /// No canonicalization method is applied. OPC_CANONICALIZATION_NONE, /// The C14N canonicalization method that removes comments is applied. OPC_CANONICALIZATION_C14N, /// The C14N canonicalization method that preserves comments is applied. OPC_CANONICALIZATION_C14N_WITH_COMMENTS } /// Describes the storage location of a certificate that is used in signing. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_certificate_embedding_option typedef enum // __MIDL___MIDL_itf_msopc_0001_0076_0004 { OPC_CERTIFICATE_IN_CERTIFICATE_PART, OPC_CERTIFICATE_IN_SIGNATURE_PART, // OPC_CERTIFICATE_NOT_EMBEDDED } OPC_CERTIFICATE_EMBEDDING_OPTION; [PInvokeData("msopc.h", MSDNShortId = "4292a53b-33a2-431c-806a-7e8c96ecce40")] public enum OPC_CERTIFICATE_EMBEDDING_OPTION { /// The certificate is stored in a part specific to the certificate. OPC_CERTIFICATE_IN_CERTIFICATE_PART, /// The certificate is encoded within the signature markup in the Signature part. OPC_CERTIFICATE_IN_SIGNATURE_PART, /// The certificate is not stored in the package. OPC_CERTIFICATE_NOT_EMBEDDED, } /// Describes ways to compress part content. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_compression_options typedef enum // __MIDL___MIDL_itf_msopc_0000_0002_0002 { OPC_COMPRESSION_NONE, OPC_COMPRESSION_NORMAL, OPC_COMPRESSION_MAXIMUM, // OPC_COMPRESSION_FAST, OPC_COMPRESSION_SUPERFAST } OPC_COMPRESSION_OPTIONS; [PInvokeData("msopc.h", MSDNShortId = "bc821e84-fd18-449c-89d0-a261f43f8971")] public enum OPC_COMPRESSION_OPTIONS { /// Compression is turned off. OPC_COMPRESSION_NONE = -1, /// Compression is optimized for a balance between size and performance. OPC_COMPRESSION_NORMAL = 0, /// Compression is optimized for size. OPC_COMPRESSION_MAXIMUM, /// Compression is optimized for performance. OPC_COMPRESSION_FAST, /// Compression is optimized for high performance. OPC_COMPRESSION_SUPERFAST, } /// /// Describes the read settings for caching package components and validating them against ECMA-376 OpenXML, 1st Edition, Part 2: /// Open Packaging Conventions (OPC) conformance requirements. /// /// /// /// If both the OPC_CACHE_ON_ACCESS and OPC_VALIDATE_ON_LOAD read flags are set, all package components are /// decompressed and cached when a package is loaded. /// /// /// The Packaging APIs do not use the OPC core properties feature; therefore, the core properties requirements listed in Table H-9 /// of the OPC are not validated by the Packaging APIs. For more information about OPC conformance requirements, see 1st edition, /// Part 2: Open Packaging Conventions in ECMA-376 OpenXML (http://go.microsoft.com/fwlink/p/?linkid=123375). /// /// /// Important Parts may be repeatedly read from the stream at any time, regardless of which read flags are set. For example, /// when a package is saved, previously accessed relationships in a Relationships part in the original package may be accessed again /// to preserve markup compatibility. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_read_flags typedef enum // __MIDL___MIDL_itf_msopc_0000_0002_0004 { OPC_READ_DEFAULT, OPC_VALIDATE_ON_LOAD, OPC_CACHE_ON_ACCESS } OPC_READ_FLAGS; [PInvokeData("msopc.h", MSDNShortId = "f7d21dac-c606-4a6a-9d6a-cf6f8ec4dbb5")] public enum OPC_READ_FLAGS { /// /// Validate a package component against OPC conformance requirements when the component is accessed. For more information about /// OPC conformance validation, see Remarks.When validation is performed on access, OPC validation errors can be returned by any method. /// OPC_READ_DEFAULT, /// /// Validate all package components against OPC conformance requirements when a package is loaded. For more information about /// OPC conformance validation, see Remarks.If this setting is enabled, performance costs for loading and validating package /// components are paid when the package is first loaded. /// OPC_VALIDATE_ON_LOAD, /// /// Cache decompressed package component data as a temp file when accessing the component for the first time. When a package /// component is accessed repeatedly, this caching reduces overhead because the component data is decompressed one time for the /// first read instead of once for every read operation. /// OPC_CACHE_ON_ACCESS, } /// /// Describes how to interpret the selectionCriterion parameter of the IOpcRelationshipSelector::GetSelectionCriterion method. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_relationship_selector typedef enum // __MIDL___MIDL_itf_msopc_0001_0076_0002 { OPC_RELATIONSHIP_SELECT_BY_ID, OPC_RELATIONSHIP_SELECT_BY_TYPE } OPC_RELATIONSHIP_SELECTOR; [PInvokeData("msopc.h", MSDNShortId = "5532aab1-850e-4de8-a470-c55fb4c2f8c4")] public enum OPC_RELATIONSHIP_SELECTOR { /// The selectionCriterion parameter is a relationship identifier. OPC_RELATIONSHIP_SELECT_BY_ID, /// The selectionCriterion parameter is a relationship type. OPC_RELATIONSHIP_SELECT_BY_TYPE, } /// /// Describes whether a reference represented by the IOpcSignatureRelationshipReference interface refers to all or a subset of /// relationships represented as relationship objects in a relationship set object. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_relationships_signing_option typedef enum // __MIDL___MIDL_itf_msopc_0001_0076_0003 { OPC_RELATIONSHIP_SIGN_USING_SELECTORS, OPC_RELATIONSHIP_SIGN_PART } OPC_RELATIONSHIPS_SIGNING_OPTION; [PInvokeData("msopc.h", MSDNShortId = "b6a83730-459a-4119-a013-7d670e659c32")] public enum OPC_RELATIONSHIPS_SIGNING_OPTION { /// /// The reference refers to a subset of relationships represented as relationship objects and identified using the /// IOpcRelationshipSelectorSet interface. /// OPC_RELATIONSHIP_SIGN_USING_SELECTORS, /// /// The reference refers to all of the relationships represented as relationship objects in the relationship set object. /// OPC_RELATIONSHIP_SIGN_PART, } /// /// Describes how to interpret the signingTime parameter, which is a record of when a signature was created, of the /// IOpcDigitalSignature::GetSigningTime method. /// /// /// The following table provides descriptions of placeholder values. /// /// /// Placeholder /// Description /// Example /// /// /// YYYY /// Four-digit year. /// 2010 /// /// /// MM /// Two-digit month with a leading zero. Possible values: 01–12. /// 03 /// /// /// DD /// Two-digit day of month with a leading zero. Possible values: 01–31. /// 09 /// /// /// hh /// Two-digit hour, 24-hour time with a leading zero. Possible values: 00–23. /// 18 /// /// /// mm /// Two-digit minute with a leading zero. Possible values: 00–59. /// 45 /// /// /// ss /// Two-digit second with a leading zero. Possible values: 00–59. /// 32 /// /// /// s /// One digit representing the decimal fraction of a second. /// 3 /// /// /// TZD /// Time zone designator with a leading zero. Possible values: Z, +hh:mm, -hh:mm. /// -08:00 /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_signature_time_format typedef enum // __MIDL___MIDL_itf_msopc_0001_0076_0005 { OPC_SIGNATURE_TIME_FORMAT_MILLISECONDS, OPC_SIGNATURE_TIME_FORMAT_SECONDS, // OPC_SIGNATURE_TIME_FORMAT_MINUTES, OPC_SIGNATURE_TIME_FORMAT_DAYS, OPC_SIGNATURE_TIME_FORMAT_MONTHS, // OPC_SIGNATURE_TIME_FORMAT_YEARS } OPC_SIGNATURE_TIME_FORMAT; [PInvokeData("msopc.h", MSDNShortId = "9b8ff585-5795-48ce-b2fd-a49e3d34ccb9")] public enum OPC_SIGNATURE_TIME_FORMAT { /// /// The format is the complete date with hours, minutes, and seconds expressed as a decimal fraction.Syntax: /// YYYY-MM-DDThh:mm:ss.sTZDA value of "2010-03-09T18:45:32.3-08:00" would represent 6:45:32.3 P.M. on March 9, 2010 Pacific Time. /// OPC_SIGNATURE_TIME_FORMAT_MILLISECONDS, /// /// The format is the complete date with hours, minutes, and seconds.Syntax: YYYY-MM-DDThh:mm:ssTZDA value of /// "2010-03-09T18:45:32-08:00" would represent 6:45:32 P.M. on March 9, 2010 Pacific Time. /// OPC_SIGNATURE_TIME_FORMAT_SECONDS, /// /// The format is the complete date with hours and minutes.Syntax: YYYY-MM-DDThh:mmTZDA value of "2010-03-09T18:45-08:00" would /// represent 6:45 P.M. on March 9, 2010 Pacific Time. /// OPC_SIGNATURE_TIME_FORMAT_MINUTES, /// The format is the complete date.Syntax: YYYY-MM-DDA value of "2010-03-09" would represent March 9, 2010. OPC_SIGNATURE_TIME_FORMAT_DAYS, /// The format is the year and month.Syntax: YYYY-MMA value of "2010-03" would represent March, 2010. OPC_SIGNATURE_TIME_FORMAT_MONTHS, /// The format is the year.Syntax: YYYYA value of "2010" would represent 2010. OPC_SIGNATURE_TIME_FORMAT_YEARS, } /// Indicates the status of the signature. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_signature_validation_result typedef enum // OPC_SIGNATURE_VALIDATION_RESULT { OPC_SIGNATURE_VALID, OPC_SIGNATURE_INVALID } ; [PInvokeData("msopc.h", MSDNShortId = "991e0620-d674-4c2c-b0d8-18d7fdd031fb")] public enum OPC_SIGNATURE_VALIDATION_RESULT { /// /// The signature is valid.Signature validation using the provided certificate succeeded; signed package components have not /// been altered. /// OPC_SIGNATURE_VALID, /// /// The signature is not valid.Signature markup or signed package components might have been altered. Alternatively, the /// signature might not exist in the current package. /// OPC_SIGNATURE_INVALID = -1, } /// Describes the read/write status of a stream. /// Important Reading and writing to the same package is not recommended and may result in undefined behavior. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_stream_io_mode typedef enum // __MIDL___MIDL_itf_msopc_0000_0002_0003 { OPC_STREAM_IO_READ, OPC_STREAM_IO_WRITE } OPC_STREAM_IO_MODE; [PInvokeData("msopc.h", MSDNShortId = "cf72ddcf-5472-451f-bfa8-94f549dc9246")] public enum OPC_STREAM_IO_MODE { /// Creates a read-only stream for loading an existing package. OPC_STREAM_IO_READ = 1, /// Creates a write-only stream for saving a new package. OPC_STREAM_IO_WRITE, } /// Indicates the target mode of a relationship. /// /// /// If the relationship's target mode is OPC_URI_TARGET_MODE_INTERNAL the URI of the target part is relative to the URI of /// the source of the relationship. /// /// To get the URI of the target of the relationship, call the IOpcRelationship::GetTargetUri method. /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_uri_target_mode typedef enum // __MIDL___MIDL_itf_msopc_0000_0002_0001 { OPC_URI_TARGET_MODE_INTERNAL, OPC_URI_TARGET_MODE_EXTERNAL } OPC_URI_TARGET_MODE; [PInvokeData("msopc.h", MSDNShortId = "af052aa3-db7a-47de-938c-32895b8735e9")] public enum OPC_URI_TARGET_MODE { /// The target of the relationship is a part inside the package. OPC_URI_TARGET_MODE_INTERNAL, /// The target of the relationship is a resource outside of the package. OPC_URI_TARGET_MODE_EXTERNAL, } /// Describes the encoding method that is used by the serialization object to produce the package. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/ne-msopc-opc_write_flags typedef enum // __MIDL___MIDL_itf_msopc_0000_0002_0005 { OPC_WRITE_DEFAULT, OPC_WRITE_FORCE_ZIP32 } OPC_WRITE_FLAGS; [PInvokeData("msopc.h", MSDNShortId = "12006b4a-98e1-4761-bce3-32b83b54a2cb")] public enum OPC_WRITE_FLAGS { /// Use Zip64 encoding. The minimum software version for extracting a package with Zip64 encoding is 4.5. OPC_WRITE_DEFAULT, /// /// Force Zip32 encoding. The minimum software version for extracting a package with Zip32 encoding is 2.0.If one or more of the /// following Zip32 limitations are violated, the package write will fail: /// OPC_WRITE_FORCE_ZIP32, } /// A read-only enumerator of pointers to CERT_CONTEXT structures. /// /// /// When an enumerator is created, the current position precedes the first pointer of the enumerator. To set the current position to /// the first pointer, call the MoveNextmethod after the enumerator is created. /// /// Changes to the set will invalidate the enumerator and all subsequent calls to it will fail. /// /// To get an IOpcCertificateEnumerator interface pointer, call the IOpcCertificateSet::GetEnumerator or /// IOpcDigitalSignature::GetCertificateEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopccertificateenumerator [PInvokeData("msopc.h")] [ComImport, Guid("85131937-8f24-421f-b439-59ab24d140b8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcCertificateEnumerator { /// Moves the current position of the enumerator to the next CERT_CONTEXT structure. /// /// A Boolean value that indicates the status of the CERT_CONTEXT structure at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateenumerator-movenext HRESULT MoveNext( BOOL // *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous CERT_CONTEXT structure. /// /// A Boolean value that indicates the status of the CERT_CONTEXT structure at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the CERT_CONTEXT structure at the current position of the enumerator. /// /// A pointer to a CERT_CONTEXT structure. If the method succeeds, call the CertFreeCertificateContext function to free the /// memory of the structure. /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// OPC_E_DS_EXTERNAL_SIGNATURE 0x8051001E /// /// A relationship whose target is a Signature part has the external target mode; Signature parts must be inside of the package. /// /// /// /// OPC_E_DS_INVALID_CERTIFICATE_RELATIONSHIP 0x8051001D /// /// A relationship of type digital signature certificate has the external target mode. For more information about this /// relationship type, see the OPC. /// /// /// /// OPC_E_DS_INVALID_RELATIONSHIP_TRANSFORM_XML 0x80510021 /// /// A Transform element that indicates the use of the relationships transform and the selection criteria for the transform does /// not conform to the schema specified in the OPC. /// /// /// /// OPC_E_DS_MISSING_CERTIFICATE_PART 0x80510056 /// /// The part that contains the certificate and is the target of a relationship of type digital signature certificate does not /// exist. For more information about this relationship type, see the OPC. /// /// /// /// OPC_E_DS_SIGNATURE_PROPERTY_MISSING_TARGET 0x80510045 /// The SignatureProperty element is missing the required Target attribute. /// /// /// OPC_E_UNEXPECTED_CONTENT_TYPE 0x80510005 /// /// Either the content type of a part differed from the expected content type (specified in the OPC, ECMA-376 Part 2), or the /// part content did not match the part's content type. /// /// /// /// /// /// /// If the certificate represented by the CERT_CONTEXT structure is corrupted or is not an X.509 certificate, this method will /// return an error; further, the signing policy used by the caller dictates whether the signature will still be validated. /// After this kind of error is returned, calls to the MoveNext or MovePrevious method will continue to iterate through the enumerator. /// /// /// When an enumerator is created, the current position precedes the first pointer of the enumerator. To set the current /// position to the first pointer, call the MoveNextmethod after the enumerator is created. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateenumerator-getcurrent HRESULT GetCurrent( // const CERT_CONTEXT **certificate ); [PreserveSig] HRESULT GetCurrent(out IntPtr certificate); /// Creates a copy of the current IOpcCertificateEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcCertificateEnumerator interface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateenumerator-clone HRESULT Clone( // IOpcCertificateEnumerator **copy ); IOpcCertificateEnumerator Clone(); } /// An unordered set of certificates to be used with a signature. /// /// /// Do not add the certificate that will be passed to the IOpcDigitalSignature::Sign method (the signer certificate) to this /// certificate set. /// /// Certificates that are in a certificate chain are added to the package by calling the Add method. /// To access an IOpcCertificateSet interface pointer, call the IOpcSigningOptions::GetCertificateSet method. /// When a signature is generated, certificates that were added to the package by calling Add are associated with the signature. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopccertificateset [PInvokeData("msopc.h")] [ComImport, Guid("56ea4325-8e2d-4167-b1a4-e486d24c8fa7"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcCertificateSet { /// Adds a certificate to the set. /// A CERT_CONTEXT structure that contains the certificate to be added. /// /// Certificates that are in a certificate chain are added to the package by calling the Add method. /// /// When a signature is generated, certificates that were added to the package by calling Add are associated with the signature. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateset-add HRESULT Add( const CERT_CONTEXT // *certificate ); void Add(in CERT_CONTEXT certificate); /// Removes a specified certificate from the set. /// A CERT_CONTEXT structure that contains the certificate to be removed. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateset-remove HRESULT Remove( const // CERT_CONTEXT *certificate ); void Remove(in CERT_CONTEXT certificate); /// Gets an enumerator of certificates in the set. /// A pointer to an IOpcCertificateEnumerator interface of certificates in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopccertificateset-getenumerator HRESULT GetEnumerator( // IOpcCertificateEnumerator **certificateEnumerator ); IOpcCertificateEnumerator GetEnumerator(); } /// Represents a package digital signature. /// /// /// To generate a signature and create an IOpcDigitalSignature interface pointer, call the IOpcDigitalSignatureManager::Sign method. /// /// /// To access generated signature by using an IOpcDigitalSignature interface pointer, call the /// IOpcDigitalSignatureEnumerator::GetCurrent method. /// /// /// When a signature is generated, this information is serialized in the XML markup of the signature (signature markup). The /// signature markup that results is stored in a signature part. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcdigitalsignature [PInvokeData("msopc.h")] [ComImport, Guid("52ab21dd-1cd0-4949-bc80-0c1232d00cb4"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcDigitalSignature { /// Gets the prefix and namespace mapping of the Signature element of the signature markup. /// /// A pointer to a buffer of XML prefix strings. If the method succeeds, call the CoTaskMemFree function to free the memory of /// each string in the buffer and then to free the memory of the buffer itself. /// /// /// A pointer to a buffer of XML namespace strings. If the method succeeds, call the CoTaskMemFree function to free the memory /// of each string in the buffer and then to free the memory of the buffer itself. /// /// The size of the prefixes and namespaces buffers. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The prefixes parameter is NULL. /// /// /// E_POINTER /// The namespaces parameter is NULL. /// /// /// E_POINTER /// The count parameter is NULL. /// /// /// /// /// The prefixes and namespaces buffers are mapped to each other by index. /// /// This method allocates memory used by the buffers returned in prefixes and namespaces and the strings contained in each buffer. /// /// Examples /// The following code shows how to use CoTaskMemFree to free the memory of the buffers and the strings they contain. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getnamespaces HRESULT GetNamespaces( // LPWSTR **prefixes, LPWSTR **namespaces, UINT32 *count ); void GetNamespaces([MarshalAs(UnmanagedType.LPWStr)] out string prefixes, [MarshalAs(UnmanagedType.LPWStr)] out string namespaces, out uint count); /// Gets the value of the Id attribute from the Signature element of the signature markup. /// /// A pointer to the Id attribute value of the signature markup Signature element. /// If the Signature element does not have an Id attribute value, signatureId will be the empty string. /// /// /// /// The Id attribute of the Signature element is optional. If this method is not called, the Signature /// element will not have the Id attribute. /// /// To set the signature Id before the signature is generated, call the IOpcSigningOptions::SetSignatureId method. /// To access the Id before the signature is generated, call the IOpcSigningOptions::GetSignatureId. method. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignatureid HRESULT GetSignatureId( // LPWSTR *signatureId ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSignatureId(); /// Gets the part name of the part that contains the signature markup. /// /// An IOpcPartUri interface pointer that represents the part name of the signature part that contains the signature markup. /// /// /// /// To set the part name of this signature part before the signature is generated, call the /// IOpcSigningOptions::SetSignaturePartName method. To access the signature part name before the signature is generated, call /// the IOpcSigningOptions::GetSignaturePartName. /// /// The signature part that stores signature markup is specific to the signature. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturepartname HRESULT // GetSignaturePartName( IOpcPartUri **signaturePartName ); IOpcPartUri GetSignaturePartName(); /// /// Gets the signature method used to calculate the value in the SignatureValue element of the signature markup. /// /// A pointer to the signature method. /// /// To set the signature method before the signature is generated, call the IOpcSigningOptions::SetSignatureMethod method. /// /// To access the signature method before the signature is generated, call the IOpcSigningOptions::GetSignatureMethod. To access /// the signature method after the signature is generated, call the IOpcDigitalSignature::GetSignatureMethod method. Both /// methods retrieve the value that was set by IOpcSigningOptions::SetSignatureMethod. /// /// /// Important A valid signature method must be set before the signature is generated by calling the /// IOpcDigitalSignatureManager::Sign method. /// /// /// When a signature is generated it is serialized as signature markup. The signature method is used to calculate the value in /// the SignatureValue element in the signature markup. /// /// /// When a signature is validated, the signature method is used to recalculate that value, and the recalculated value is /// compared to the value in the SignatureValue element in the signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturemethod HRESULT // GetSignatureMethod( LPWSTR *signatureMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSignatureMethod(); /// Gets the canonicalization method that was applied to the SignedInfo element of the serialized signature. /// /// An OPC_CANONICALIZATION_METHOD value that specifies the canonicalization method that was applied to the SignedInfo /// element of the signature markup when the signature was generated. /// /// /// /// When using the APIs to generate a signature, the C14N canonicalization method that removes comments is applied to the /// SignedInfo element. This method corresponds to the OPC_CANONICALIZATION_C14N enum value. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getcanonicalizationmethod HRESULT // GetCanonicalizationMethod( OPC_CANONICALIZATION_METHOD *canonicalizationMethod ); OPC_CANONICALIZATION_METHOD GetCanonicalizationMethod(); /// Gets the decoded value in the SignatureValue element of the signature markup. /// /// A pointer to a buffer that contains the decoded value in the SignatureValue element of the signature markup. /// /// The size of the signatureHashValue buffer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// At least one of the signatureValue, and count parameters is NULL. /// /// /// /// /// /// The SignatureValue element contains a base-64 encoded value that was computed by applying the signature method to the /// SignedInfo element of the signature markup. To get the signature method, call the GetSignatureMethod method. /// /// /// When using the APIs to generate a signature, set the signature method by calling the IOpcSigningOptions::SetSignatureMethod method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturevalue HRESULT // GetSignatureValue( UINT8 **signatureValue, UINT32 *count ); void GetSignatureValue(out SafeCoTaskMemHandle signatureValue, out uint count); /// /// Gets an enumerator of IOpcSignaturePartReference interface pointers, which represent references to parts that have been signed. /// /// /// A pointer to an enumerator of IOpcSignaturePartReference interface pointers, which represent references to parts that have /// been signed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturepartreferenceenumerator // HRESULT GetSignaturePartReferenceEnumerator( IOpcSignaturePartReferenceEnumerator **partReferenceEnumerator ); IOpcSignaturePartReferenceEnumerator GetSignaturePartReferenceEnumerator(); /// /// Gets an enumerator of IOpcSignatureRelationshipReference interface pointers, which represent references to relationships /// that have been signed. /// /// /// A pointer to an enumerator of IOpcSignatureRelationshipReference interface pointers, which represent references to /// relationships that have been signed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturerelationshipreferenceenumerator // HRESULT GetSignatureRelationshipReferenceEnumerator( IOpcSignatureRelationshipReferenceEnumerator // **relationshipReferenceEnumerator ); IOpcSignatureRelationshipReferenceEnumerator GetSignatureRelationshipReferenceEnumerator(); /// Gets a string that indicates the time at which the signature was generated. /// A pointer to a string that indicates the time at which the signature was generated. /// /// To get the format of the signingTime string, call the GetTimeFormat method. /// Caution This is not a trusted time stamp. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsigningtime HRESULT GetSigningTime( // LPWSTR *signingTime ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSigningTime(); /// Gets the format of the string returned by the GetSigningTime method. /// An OPC_SIGNATURE_TIME_FORMAT value that describes the format of the string returned by GetSigningTime. /// /// /// To access a string that indicates the time at which the current package signature was generated, call the GetSigningTime method. /// /// /// To set the format of the signing time string before the signature is generated, call the IOpcSigningOptions::SetTimeFormat /// method. To access the format before the signature is generated, call the IOpcSigningOptions::GetTimeFormat method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-gettimeformat HRESULT GetTimeFormat( // OPC_SIGNATURE_TIME_FORMAT *timeFormat ); OPC_SIGNATURE_TIME_FORMAT GetTimeFormat(); /// /// Gets an IOpcSignatureReference interface pointer that represents the reference to the package-specific Object element /// that has been signed. /// /// /// An IOpcSignatureReference interface pointer that represents the reference to the package-specific Object element that /// has been signed. /// /// /// /// The IOpcSignatureReference interface pointer received in the packageObjectReference parameter represents the /// Reference element that has the URI attribute value set to "#idPackageObject". The URI attribute value /// of this element is the Id attribute value of the package-specific Object element, prefixed with a pound sign ("#"). /// /// /// When the signature is generated and serialized as signature markup, the reference and the referenced package-specific /// Object element are signed. The following markup shows the package-specific Reference element and the /// package-specific Object element in the resultant signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getpackageobjectreference HRESULT // GetPackageObjectReference( IOpcSignatureReference **packageObjectReference ); IOpcSignatureReference GetPackageObjectReference(); /// Gets an enumerator of certificates that are used in the signature. /// A pointer to an enumerator of pointers to CERT_CONTEXT structures that are used in the signature. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getcertificateenumerator HRESULT // GetCertificateEnumerator( IOpcCertificateEnumerator **certificateEnumerator ); IOpcCertificateEnumerator GetCertificateEnumerator(); /// /// Gets an enumerator of the IOpcSignatureReference interface pointers that represent references to application-specific XML /// elements that have been signed. /// /// /// A pointer to an enumerator of IOpcSignatureReference interface pointers. An IOpcSignatureReference interface pointer /// represents a reference to an application-specific XML element that has been signed. /// /// /// /// To access the signed XML Element by using an IOpcSignatureCustomObject interface pointer, call the /// IOpcSignatureCustomObjectEnumerator::GetCurrent method. To access the markup of the signed XML element, call the /// IOpcSignatureCustomObject::GetXml method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getcustomreferenceenumerator HRESULT // GetCustomReferenceEnumerator( IOpcSignatureReferenceEnumerator **customReferenceEnumerator ); IOpcSignatureReferenceEnumerator GetCustomReferenceEnumerator(); /// /// Gets an enumerator of IOpcSignatureCustomObject interface pointers that represent application-specific Object /// elements in the signature markup. /// /// A pointer to an enumerator of IOpcSignatureCustomObject interface pointers. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getcustomobjectenumerator HRESULT // GetCustomObjectEnumerator( IOpcSignatureCustomObjectEnumerator **customObjectEnumerator ); IOpcSignatureCustomObjectEnumerator GetCustomObjectEnumerator(); /// Gets the signature markup. /// A pointer to a buffer that contains the signature markup. /// The size of the signatureXml buffer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// At least one of the digestValue, and count parameters is NULL. /// /// /// /// /// /// This method allocates memory used by the buffer returned in signatureXml. If the method succeeds, call the CoTaskMemFree /// function to free the memory. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignature-getsignaturexml HRESULT // GetSignatureXml( UINT8 **signatureXml, UINT32 *count ); void GetSignatureXml(out SafeCoTaskMemHandle signatureXml, out uint count); } /// A read-only enumerator of IOpcDigitalSignature interface pointers. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Changes to the set will invalidate the enumerator and all subsequent calls to it will fail. /// /// To get an IOpcDigitalSignatureEnumerator interface pointer, call the IOpcDigitalSignatureManager::GetSignatureEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcdigitalsignatureenumerator [PInvokeData("msopc.h", MSDNShortId = "73fd0e47-7503-470d-b649-e4b2ba492bf1")] [ComImport, Guid("967b6882-0ba3-4358-b9e7-b64c75063c5e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcDigitalSignatureEnumerator { /// Moves the current position of the enumerator to the next IOpcDigitalSignature interface pointer. /// /// A Boolean value that indicates the status of the IOpcDigitalSignature interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignatureenumerator-movenext HRESULT MoveNext( // BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcDigitalSignature interface pointer. /// /// A Boolean value that indicates the status of the IOpcDigitalSignature interface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignatureenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcDigitalSignature interface pointer at the current position of the enumerator. /// An IOpcDigitalSignature interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// OPC_E_DS_DUPLICATE_PACKAGE_OBJECT_REFERENCES 0x8051002D /// /// The signature markup contains more than one Reference element that refers to the package Object element, but only one such /// Reference is allowed. /// /// /// /// OPC_E_DS_DUPLICATE_SIGNATURE_PROPERTY_ELEMENT 0x80510028 /// The signature markup contains more than one SignatureProperty element that has the same Id attribute. /// /// /// OPC_E_DS_EXTERNAL_SIGNATURE_REFERENCE 0x8051002F /// /// A Reference element in the signature markup indicates an object that is external to the package. Reference elements must /// point to parts or Object elements that are internal. /// /// /// /// OPC_E_DS_INVALID_CANONICALIZATION_METHOD 0x80510022 /// An unsupported canonicalization method was requested or used in a signature. /// /// /// OPC_E_DS_INVALID_SIGNATURE_COUNT 0x8051002B /// A Signature part does not contain the signature markup for exactly one signature. /// /// /// OPC_E_DS_INVALID_SIGNATURE_XML 0x8051002A /// /// The signature markup in a Signature part does not conform to the schema specified in the OPC or XML-Signature Syntax and /// Processing (http://go.microsoft.com/fwlink/p/?linkid=132847). /// /// /// /// OPC_E_DS_MISSING_CANONICALIZATION_TRANSFORM 0x80510032 /// A relationships transform must be followed by a canonicalization method. /// /// /// OPC_E_DS_MISSING_PACKAGE_OBJECT_REFERENCE 0x8051002E /// The signature markup is missing a Reference to the package-specific Object element. /// /// /// OPC_E_DS_MISSING_SIGNATURE_ALGORITHM 0x8051002C /// The signature markup does not specify signature method algorithm. /// /// /// OPC_E_DS_MISSING_SIGNATURE_PART 0x80510020 /// The specified Signature part does not exist in the package. /// /// /// OPC_E_DS_MISSING_SIGNATURE_PROPERTIES_ELEMENT 0x80510026 /// The SignatureProperties element was not found in the signature markup. /// /// /// OPC_E_DS_MISSING_SIGNATURE_PROPERTY_ELEMENT 0x80510027 /// The SignatureProperty child element of the SignatureProperties element was not found. /// /// /// OPC_E_DS_MISSING_SIGNATURE_TIME_PROPERTY 0x80510029 /// /// The SignatureProperty element with the Id attribute value of "idSignatureTime" does not exist or is not correctly constructed. /// /// /// /// OPC_E_DS_MULTIPLE_RELATIONSHIP_TRANSFORMS 0x80510031 /// /// More than one relationships transform is specified for a Reference element, but only one relationships transform is allowed. /// /// /// /// OPC_E_DS_REFERENCE_MISSING_CONTENT_TYPE 0x80510030 /// /// The URI attribute value of a Reference element in the signature markup does not include the content type of the referenced part. /// /// /// /// OPC_E_DS_SIGNATURE_REFERENCE_MISSING_URI 0x80510043 /// The URI attribute is required for a Reference element but is missing. /// /// /// OPC_E_UNEXPECTED_CONTENT_TYPE 0x80510005 /// /// Either the content type of a part differed from the expected content type (specified in the OPC, ECMA-376 Part 2), or the /// part content did not match the part's content type. /// /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignatureenumerator-getcurrent HRESULT // GetCurrent( IOpcDigitalSignature **digitalSignature ); [PreserveSig] HRESULT GetCurrent(out IOpcDigitalSignature certificate); /// Creates a copy of the current IOpcDigitalSignatureEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcDigitalSignatureEnumerator interface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignatureenumerator-clone HRESULT Clone( // IOpcDigitalSignatureEnumerator **copy ); IOpcDigitalSignatureEnumerator Clone(); } /// /// Provides access to Packaging Digital Signature Interfaces for a package that is represented by Packaging API objects. These /// interface methods are called to generate a signature, or to access and validate existing signatures in the package. /// /// /// /// Before the Sign method is called to generate a signature, the IOpcSigningOptions::SetDefaultDigestMethod and /// IOpcSigningOptions::SetSignatureMethod methods must be called. /// /// /// To create an IOpcDigitalSignatureManager interface pointer, call the IOpcFactory::CreateDigitalSignatureManager method. /// /// /// Important If the package is modified while the Sign method is being executed, the method may fail or generate an /// inconsistent signature. To avoid corruption of the package, use the APIs to save the package prior to calling Sign. For /// information about how to save a package, see Saving a Package. /// /// /// The Validate method checks that the specified signature (signed entities and the signature markup) has not been altered since /// the signature was generated, but does not validate the identity of the signer. /// /// Important The caller must validate the identity of the signer. /// Thread Safety /// Packaging objects are not thread-safe. /// IOpcSigningOptions For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcdigitalsignaturemanager [PInvokeData("msopc.h", MSDNShortId = "13e8a7b9-1d25-421b-bc81-adc495e6d9c7")] [ComImport, Guid("d5e62a0b-696d-462f-94df-72e33cef2659"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcDigitalSignatureManager { /// Gets an IOpcPartUri interface pointer that represents the part name of the Digital Signature Origin part. /// An IOpcPartUri interface pointer, or NULL if the Digital Signature Origin part does not exist. /// /// /// When using the APIs to generate a signature, set the Digital Signature Origin part name by calling the /// SetSignatureOriginPartName method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-getsignatureoriginpartname // HRESULT GetSignatureOriginPartName( IOpcPartUri **signatureOriginPartName ); IOpcPartUri GetSignatureOriginPartName(); /// /// Sets the part name of the Digital Signature Origin part to the name represented by a specified IOpcPartUri interface pointer. /// /// /// A pointer to an IOpcPartUri interface pointer that represents the desired part name for the Digital Signature Origin part. /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// OPC_E_DS_SIGNATURE_ORIGIN_EXISTS 0x80510054 /// A Digital Signature Origin part already exists in the package and cannot be renamed. /// /// /// OPC_E_DUPLICATE_PART 0x8051000B /// A part with the specified part name already exists in the current package. /// /// /// /// /// /// If the Digital Signature Origin part exists or if the part name that is in the signatureOriginPartName parameter is being /// used for another part, this method will fail. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-setsignatureoriginpartname // HRESULT SetSignatureOriginPartName( IOpcPartUri *signatureOriginPartName ); [PreserveSig] HRESULT SetSignatureOriginPartName(IOpcPartUri signatureOriginPartName); /// Gets an enumerator of IOpcDigitalSignature interface pointers, which represent package signatures. /// A pointer to an enumerator of IOpcDigitalSignature interface pointers, which represent package signatures. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-getsignatureenumerator HRESULT // GetSignatureEnumerator( IOpcDigitalSignatureEnumerator **signatureEnumerator ); IOpcDigitalSignatureEnumerator GetSignatureEnumerator(); /// Removes from the package a specified signature part that stores signature markup. /// /// An IOpcPartUri interface pointer that represents the part name of the signature part to be removed. /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The signaturePartName parameter is NULL. /// /// /// OPC_E_NO_SUCH_PART 0x80510018 /// The specified part does not exist. /// /// /// /// /// If the specified signature part does not exist, this method will fail. /// If a part is removed from a package, it will not be saved when the package is saved. /// /// If a removed part is the source of one or more relationships, those relationships will not be saved when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-removesignature HRESULT // RemoveSignature( IOpcPartUri *signaturePartName ); [PreserveSig] HRESULT RemoveSignature(IOpcPartUri signaturePartName); /// Creates an IOpcSigningOptions interface pointer. /// A pointer to an IOpcSigningOptions interface pointer. /// /// /// This method creates an IOpcSigningOptions interface pointer that is required to set the properties of a signature to be generated /// /// /// To generate a signature, call the IOpcDigitalSignatureManager::Sign method with the signingOptions parameter value set to an /// IOpcSigningOptions interface pointer that is retrieved by the CreateSigningOptions method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-createsigningoptions HRESULT // CreateSigningOptions( IOpcSigningOptions **signingOptions ); IOpcSigningOptions CreateSigningOptions(); /// Validates a specified package signature using a specified certificate. /// An IOpcDigitalSignature interface pointer that represents the signature to be validated. /// /// A pointer to a CERT_CONTEXT structure that contains a certificate that is used to validate the signature. /// /// A value that describes the result of the validation check. /// /// /// This method does not perform security checks on an X.509 Public Key Infrastructure Certificate; the caller must perform the /// checks for revocation, expiration, certificate chain, and all other necessary checks. /// /// /// This method checks that the specified signature (signed entities and the signature markup) has not been altered since the /// signature was generated, but does not validate the identity of the signer. /// /// Important The caller must validate the identity of the signer. /// If there are errors in a package signature, some of these errors may not be exposed until this method is called. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-validate HRESULT Validate( // IOpcDigitalSignature *signature, const CERT_CONTEXT *certificate, OPC_SIGNATURE_VALIDATION_RESULT *validationResult ); void Validate(IOpcDigitalSignature signature, in CERT_CONTEXT certificate, out OPC_SIGNATURE_VALIDATION_RESULT validationResult); /// /// Signs the package by generating a signature by using the specified certificate and IOpcSigningOptions interface pointer. The /// resultant signature is represented by an IOpcDigitalSignature interface pointer. /// /// A pointer to a CERT_CONTEXT structure that contains the certificate. /// An IOpcSigningOptions interface pointer that is used to generate the signature. /// A new IOpcDigitalSignature interface pointer that represents the signature. /// /// /// This method uses Packaging objects to make changes to a package. The resultant changes are not saved until the package /// itself is saved. /// /// /// Before this method is called to generate a signature, call the IOpcSigningOptions::SetDefaultDigestMethod and /// IOpcSigningOptions::SetSignatureMethod methods. /// /// /// To create an IOpcSigningOptions interface pointer, which is required by this method, call the CreateSigningOptions method. /// /// /// Important If the package is modified while this method is being executed, Sign may fail or generate an /// inconsistent signature. To avoid corruption of the package, use the APIs to save the package prior to calling Sign. /// For information about how to save a package, see Saving a Package. /// /// This method may create the following parts and relationships: /// /// /// The Digital Signature Origin part /// /// /// The package relationship of the digital signature origin relationship type /// /// /// One signature part that contains signature markup /// /// /// One or more part that contains a certificate /// /// /// One relationship that targets a signature part and that has the Digital Signature Origin part as its source /// /// /// /// One or more relationship that targets a signature part that contains a certificate and that has another signature part as /// its source /// /// /// /// /// If Sign fails, any of the above parts and relationships may be represented, in the package, by Packaging objects. If /// the method returns the OPC_E_DS_SIGNATURE_METHOD_NOT_SET or OPC_E_DS_DEFAULT_DIGEST_METHOD_NOT_SET error code, /// the package has not been altered. /// /// /// If Sign is successful, digest values are calculated for signed enitities, and the generated signature is serialized /// as signature markup. Possible signed entities include the Signature element, references, parts, relationships, and /// package-specific and application-specific Object elements. /// /// /// Errors that are introduced into a package signature when the caller is using the IOpcSigningOptions interface to set /// signature information may not be exposed until Sign is called. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-sign HRESULT Sign( const // CERT_CONTEXT *certificate, IOpcSigningOptions *signingOptions, IOpcDigitalSignature **digitalSignature ); IOpcDigitalSignature Sign(in CERT_CONTEXT certificate, IOpcSigningOptions signingOptions); /// Replaces the existing signature markup that is stored in a specified signature part. /// /// An IOpcPartUri interface pointer that represents the part name of the signature part that stores the existing signature markup. /// /// A buffer that contains the signature markup that will replace the existing markup. /// The size of the newSignatureXml buffer. /// /// A pointer to a new IOpcDigitalSignature interface that represents the signature derived from the signature markup that is /// passed in newSignatureXml. /// /// /// /// This method does not validate the signature that is derived from the new signature markup that is in the newSignatureXml parameter. /// /// /// The caller must confirm that the new signature markup, which replaces the existing signature markup in the specified /// signature part, will not break the signature. /// /// /// This method changes the existing signature markup; certificates and relationships that have the specified signature part as /// their source are preserved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcdigitalsignaturemanager-replacesignaturexml HRESULT // ReplaceSignatureXml( IOpcPartUri *signaturePartName, const UINT8 *newSignatureXml, UINT32 count, IOpcDigitalSignature // **digitalSignature ); IOpcDigitalSignature ReplaceSignatureXml(IOpcPartUri signaturePartName, [In] byte[] newSignatureXml, uint count); } /// /// Creates Packaging API objects and provides support for saving and loading packages. Objects that are created by /// IOpcFactory interface methods provide support for creating, populating, modifying, and digitally signing packages. /// /// /// /// Do not use a stream to serialize package data when the same stream is being used to deserialize a package; attempting to do so /// may result in undefined behavior. /// /// /// To use the Packaging API, the package must map to a ZIP archive as specified in the ECMA-376 OpenXML, 1st Edition, Part 2: Open /// Packaging Conventions (OPC). /// /// /// To create a factory that implements the IOpcFactory interface, call the CoCreateInstance function. This factory is not /// tied to any particular package or Packaging API object, and it can be used for the lifetime of the application. For example code /// that shows how to create a factory implementing IOpcFactory, see the Getting Started with the Packaging API. /// /// IOpcFactory Support on Previous Versions of Windows /// /// If an application attempts to an unsupported IOpcFactory method, the E_NOTIMPL error code will be returned. For more /// information, see Getting Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcfactory [PInvokeData("msopc.h", MSDNShortId = "0a265a0a-c109-4afc-a0ad-d3ee31757aa1")] [ComImport, Guid("6d0b4446-cd73-4ab3-94f4-8ccdf6116154"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(OpcFactory))] public interface IOpcFactory { /// Creates an OPC URI object that represents the root of a package. /// A pointer to the IOpcUri interface of the OPC URI object that represents the URI of the root of a package. /// /// The URI of the root of a package is always represented as "/". /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-createpackagerooturi HRESULT // CreatePackageRootUri( IOpcUri **rootUri ); IOpcUri CreatePackageRootUri(); /// Creates a part URI object that represents a part name. /// A URI that represents the location of a part relative to the root of the package that contains it. /// /// /// A pointer to the IOpcPartUri interface of the part URI object. This object represents the part name derived from the URI /// passed in pwzUri. /// /// Part names must conform to the syntax specified in the OPC. /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// At least one of the pwzUri and partUri parameters is NULL. /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot be the empty string "". /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot be a '/'. /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot begin with "//". /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot end with a '/'. /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot end with a '.'. /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// A part name cannot have any segments that end with a '.'. /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// /// A part name cannot have fragment component. A fragment component is preceded by a '#' character, as described in RFC 3986: /// URI Generic Syntax. /// /// /// /// OPC_E_NONCONFORMING_URI 0x80510001 /// /// A part name cannot be the name of a Relationships part that indicates another Relationships part as the source of the /// relationships contained therein. /// /// /// /// OPC_E_RELATIVE_URI_REQUIRED 0x80510002 /// /// A part name cannot be an absolute URI. An absolute URI begins with a schema component followed by a ":", as described in RFC /// 3986: URI Generic Syntax. /// /// /// /// CreateUri function error /// An HRESULT error code from the CreateUri function. /// /// /// WinINet error /// An HRESULT error code from a WinINet API. /// /// /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-createparturi HRESULT CreatePartUri( LPCWSTR // pwzUri, IOpcPartUri **partUri ); [PreserveSig] HRESULT CreatePartUri([MarshalAs(UnmanagedType.LPWStr)] string pwzUri, out IOpcPartUri partUri); /// /// Creates a stream over a file. This method is a simplified wrapper for a call to the CreateFile function. CreateFile /// parameters that are not exposed through this method use their default values. For more information, see CreateFile. /// /// The name of the file over which the stream is created. /// The value that describes the read/write status of the stream to be created. /// /// For information about the SECURITY_ATTRIBUTES structure in this parameter, see the CreateFile function. /// /// /// The settings and attributes of the file. For most files, FILE_ATTRIBUTE_NORMAL can be used. /// For more information about this parameter, see CreateFile. /// /// A pointer to the IStream interface of the stream. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_INVALIDARG /// The value passed in the ioMode parameter is not a valid OPC_STREAM_IO_MODE enumeration value. /// /// /// E_POINTER /// At least one of the filename and stream parameters is NULL. /// /// /// CreateFile function error /// An HRESULT error code from the CreateFile function. /// /// /// /// /// /// Do not use a stream to serialize package data when the same stream is being used to deserialize a package, because the /// attempt may result in undefined behavior. /// /// /// For information about using this method when loading or saving a package, see the Loading a Package or Saving a Package /// programming task. /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-createstreamonfile HRESULT CreateStreamOnFile( // LPCWSTR filename, OPC_STREAM_IO_MODE ioMode, LPSECURITY_ATTRIBUTES securityAttributes, DWORD dwFlagsAndAttributes, IStream // **stream ); [PreserveSig] HRESULT CreateStreamOnFile([MarshalAs(UnmanagedType.LPWStr)] string filename, OPC_STREAM_IO_MODE ioMode, [Optional] SECURITY_ATTRIBUTES securityAttributes, FileFlagsAndAttributes dwFlagsAndAttributes, out IStream stream); /// Creates a package object that represents an empty package. /// A pointer to the IOpcPackage interface of the package object that represents an empty package. /// /// Support on Previous Versions of Windows /// /// This method is not supported on versions of Windows prior to Windows 7. For more information, see Getting Started with the /// Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-createpackage HRESULT CreatePackage( // IOpcPackage **package ); IOpcPackage CreatePackage(); /// /// Deserializes package data from a stream and creates a package object to represent the package being read. While a Packaging /// API object obtained from the package object, or the package object itself, is still in use, the stream may be used to access /// package data. /// /// /// A pointer to the IStream interface of the stream. /// /// The stream must be readable, seekable, have size, and must contain package data. Additionally, if the stream is not /// clonable, it will be buffered and read sequentially, incurring overhead. /// /// /// /// The value that specifies the read settings for caching package components and validating them against OPC conformance requirements. /// /// /// A pointer to the IOpcPackage interface of the package object that represents the package being read through the stream. /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_INVALIDARG /// The value passed in the flags parameter is not a valid OPC_READ_FLAGS enumeration value. /// /// /// E_NOTIMPL /// This method is not implemented for this version of Windows. /// /// /// E_POINTER /// At least one of the stream and package parameters is NULL. /// /// /// IStream interface error /// An HRESULT error code from the IStream interface. /// /// /// Package Consumption error /// An HRESULT error code from the Package Consumption Error Group. /// /// /// Part URI error /// An HRESULT error code from the Part URI Error Group. /// /// /// /// /// /// Do not use a stream to serialize package data when the same stream is being used to deserialize a package, because the /// attempt may result in undefined behavior. /// /// /// The Packaging APIs can interact with packages that map a ZIP archive as specified in the OPC, and that are based on either /// Zip32 (ZIP 2.0) or Zip64 (ZIP 4.5) encoding. /// /// For information about how to use this method to load a package, see the Loading a Package programming task. /// Support on Previous Versions of Windows /// /// This method is not supported on versions of Windows prior to Windows 7. For more information, see Getting Started with the /// Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-readpackagefromstream HRESULT // ReadPackageFromStream( IStream *stream, OPC_READ_FLAGS flags, IOpcPackage **package ); [PreserveSig] HRESULT ReadPackageFromStream(IStream stream, OPC_READ_FLAGS flags, out IOpcPackage package); /// Serializes a package that is represented by a package object. /// A pointer to the IOpcPackage interface of the package object that contains data to be serialized. /// The value that describes the encoding method used in serialization. /// A pointer to the IStream interface of the stream where the package object data will be written. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_INVALIDARG /// The value passed in the flags parameter is not a valid OPC_WRITE_FLAGS enumeration value. /// /// /// E_NOTIMPL /// This method is not implemented for this version of Windows. /// /// /// E_POINTER /// At least one of the stream and package parameters is NULL. /// /// /// IStream interface error /// An HRESULT error code from the IStream interface. /// /// /// Package Consumption error /// An HRESULT error code from the Package Consumption Error Group. /// /// /// Part URI error /// An HRESULT error code from the Part URI Error Group. /// /// /// /// /// /// Do not use a stream to serialize package data when the same stream is being used to deserialize a package, because the /// attempt may result in undefined behavior. /// /// /// For information about how to use this method to save a package that is represented as a package object, see the Saving a /// Package programming task. /// /// Support on Previous Versions of Windows /// /// This method is not supported on versions of Windows prior to Windows 7. For more information, see Getting Started with the /// Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-writepackagetostream HRESULT // WritePackageToStream( IOpcPackage *package, OPC_WRITE_FLAGS flags, IStream *stream ); [PreserveSig] HRESULT WritePackageToStream(IOpcPackage package, OPC_WRITE_FLAGS flags, IStream stream); /// Creates a digital signature manager object for a package object. /// /// A pointer to the IOpcPackage interface of the package object to associate with the digital signature manager object. /// /// /// /// A pointer to the IOpcDigitalSignatureManager interface of the digital signature manager object that is created for use with /// the package object. /// /// /// A digital signature manager object provides access to the Packaging API's digital signature interfaces and methods. These /// can be used to sign the package represented by the package object or to validate the signatures in a package that has /// already been signed. /// /// /// /// /// If a package is modified while Packaging Digital Signature Interfaces are being used to sign the package, signing may fail /// or result in an inconsistent signature or package. /// /// Support on Previous Versions of Windows /// /// This method is not supported on versions of Windows prior to Windows 7. For more information, see Getting Started with the /// Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcfactory-createdigitalsignaturemanager HRESULT // CreateDigitalSignatureManager( IOpcPackage *package, IOpcDigitalSignatureManager **signatureManager ); IOpcDigitalSignatureManager CreateDigitalSignatureManager(IOpcPackage package); } /// Represents a package and provides methods to access the package's parts and relationships. /// /// To get a pointer to this interface, call either the IOpcFactory::CreatePackage or IOpcFactory::ReadPackageFromStream method. /// /// Package relationships serve as an entry point to the package by links from the package to target resources. The target of a /// package relationship is often an important part described in the ECMA-376 OpenXML, 1st Edition, Part 2: Open Packaging /// Conventions (OPC) or by the package format designer. /// /// /// For example, a package relationship can provide access to the Core Properties part that stores package metadata, or to a part /// containing format-specific data, where the part and data are described by the package designer. The Main Document part of the /// word processing OpenXML format is one such format-specific part. For more information about this part, see Part 1: Fundamentals /// in ECMA-376 OpenXML (http://go.microsoft.com/fwlink/p/?linkid=123375). /// /// /// The definitive way to find a part of interest is by using a relationship type. Several steps are required; for details, see the /// Parts Overview and the Finding the Core Properties Part how-to task. /// /// For more information about packages, see the Open Packaging Conventions Fundamentals and the OPC. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcpackage [PInvokeData("msopc.h", MSDNShortId = "e7052dd2-c910-41d8-a58a-8f3e68e09dd0")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE70"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcPackage { /// Gets a part set object that contains IOpcPart interface pointers. /// /// A pointer to the IOpcPartSet interface of the part set object that contains IOpcPart interface pointers to part objects. /// /// /// The IOpcPart interface is only used to represent parts in the package that are not Relationships parts. /// /// For more information about packages, parts, relationships, and the interfaces that represent them, see the Open Packaging /// Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpackage-getpartset HRESULT GetPartSet( IOpcPartSet // **partSet ); IOpcPartSet GetPartSet(); /// Gets a relationship set object that represents the Relationships part that stores package relationships. /// /// A pointer to the IOpcRelationshipSet interface of the relationship set object. The set represents the Relationships part /// that stores package relationships. /// /// /// The Package relationships represented in the set provide the entry point to a package for an application. /// /// For more information about packages, parts, relationships, and the interfaces that represent them, see the Open Packaging /// Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpackage-getrelationshipset HRESULT GetRelationshipSet( // IOpcRelationshipSet **relationshipSet ); IOpcRelationshipSet GetRelationshipSet(); } /// Represents a part that contains data and is not a Relationships part. /// /// /// To create a part object to represent a part, call the IOpcPartSet::CreatePart method. To get a pointer to the interface of a /// part object that represents an existing part, call the IOpcPartSet::GetPart or IOpcPartEnumerator::GetCurrent method. /// /// A Relationships part cannot be represented by an implementation of the IOpcPart interface. /// For more information about parts, see the Open Packaging Conventions Fundamentals and the OPC. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcpart [PInvokeData("msopc.h", MSDNShortId = "e6a40f30-03d1-4c93-a5e0-563b4c6588b4")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE71"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcPart { /// /// Gets a relationship set object that represents the Relationships part that stores relationships that have the part as their source. /// /// /// A pointer to a relationship set object that represents the Relationships part that stores all relationships that have the /// part as their source. /// /// /// /// The definitive way to find a part of interest is by using a relationship type to find the relationship that has the part of /// interest as its target. The target's URI can then be resolved to a part name which is used to access the part. /// /// /// For more information about using the relationship type to find a relationship and then a part of interest, see /// IOpcRelationshipSet and IOpcRelationship. /// /// /// For more information about parts and relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 /// OpenXML, 1st Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpart-getrelationshipset HRESULT GetRelationshipSet( // IOpcRelationshipSet **relationshipSet ); IOpcRelationshipSet GetRelationshipSet(); /// Gets a stream that provides read/write access to part content. /// A pointer to the IStream interface of a stream that provides read and write access to part content. /// /// /// For more information about parts, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpart-getcontentstream HRESULT GetContentStream( IStream // **stream ); IStream GetContentStream(); /// Gets a part URI object that represents the part name. /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name. /// Part names conform to specific syntax specified in the OPC. /// /// /// For more information about parts, see the Open Packaging Conventions Fundamentals and the OPC. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpart-getname HRESULT GetName( IOpcPartUri **name ); IOpcPartUri GetName(); /// Gets the media type of part content. /// The media type of part content, as specified by the package format designer and adhering to RFC 2616: HTTP/1.1. /// /// /// For more information about parts, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpart-getcontenttype HRESULT GetContentType( LPWSTR // *contentType ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetContentType(); /// Gets a value that describes the way part content is compressed. /// A value that describes the way part content is compressed. /// /// /// For more information about parts, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpart-getcompressionoptions HRESULT // GetCompressionOptions( OPC_COMPRESSION_OPTIONS *compressionOptions ); OPC_COMPRESSION_OPTIONS GetCompressionOptions(); } /// A read-only enumerator of IOpcPart interface pointers. /// /// To get a pointer to this interface, call the IOpcPartSet::GetEnumerator method. /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Note Changes to the enumerator's underlying set will invalidate the enumerator, and all subsequent calls will fail. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcpartenumerator [PInvokeData("msopc.h")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE75"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcPartEnumerator { /// Moves the current position of the enumerator to the next IOpcPart interface pointer. /// /// A Boolean value that indicates the status of the IOpcPart interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNext method after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartenumerator-movenext HRESULT MoveNext( BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcPart interface pointer. /// /// A Boolean value that indicates the status of the IOpcPart interface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartenumerator-moveprevious HRESULT MovePrevious( BOOL // *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcPart interface pointer at the current position of the enumerator. /// An IOpcPart interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartenumerator-getcurrent HRESULT GetCurrent( IOpcPart // **part ); [PreserveSig] HRESULT GetCurrent(out IOpcPart part); /// Creates a copy of the current enumerator and all its descendants. /// A pointer to the IOpcPartEnumerator interface of the new enumerator. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartenumerator-clone HRESULT Clone( IOpcPartEnumerator // **copy ); IOpcPartEnumerator Clone(); } /// /// An unordered set of IOpcPart interface pointers to part objects that represent the parts in a package that are not Relationships parts. /// /// /// /// To retrieve the IOpcPart interface pointer of the part object that represents a specific part, call the PartExists method and /// pass in the part name to confirm that the part is represented in the set. If it is, call the GetPart method and pass in the part /// name to retrieve the IOpcPart interface pointer. /// /// The CreatePart method cannot create a part object that represents a Relationships part. /// /// When a package that is represented as a package object is serialized, only the parts that are represented by part objects with /// IOpcPart interface pointers included in the set are serialized with the package. /// /// /// If a part is not represented by a part object in the set when the package is serialized, that part will not be serialized with /// the package. /// /// /// When a part object is created and a pointer to it is added to the set, the part it represents is serialized when the package is serialized. /// /// /// When an IOpcPart interface pointer is deleted from the set, the part it represents is not serialized when the package is serialized. /// /// /// An IOpcPart provides access to the properties of the part. For details about these properties, see the Parts Overview and IOpcPart. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcpartset [PInvokeData("msopc.h")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE73"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcPartSet { /// Gets a part object, which represents a specified part, in the set. /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name of a part. /// A pointer to the IOpcPart of the part object that represents the part that has the specified part name. /// /// /// To retrieve the IOpcPart interface pointer of the part object that represents a specific part, call the PartExists method /// and pass in the part name to confirm that the part is represented in the set. If it is, call the GetPart method and /// pass in the part name to retrieve the IOpcPart interface pointer. /// /// /// If the part URI object represents the part name of a Relationships part, this method will fail because Relationships parts /// are not included in the set. /// /// /// The IOpcPart interface provides access to the properties of a part. For details about these properties, see the Parts /// Overview and IOpcPart. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartset-getpart HRESULT GetPart( IOpcPartUri *name, // IOpcPart **part ); IOpcPart GetPart(IOpcPartUri name); /// Creates a part object that represents a part and adds a pointer to the object's IOpcPart interface to the set. /// /// A pointer to the IOpcPartUri interface of a part URI object that represents the part name of the part. /// /// To create a part URI object (which implements the IOpcPartUri interface) to represent the part name of the part, call the /// IOpcFactory::CreatePartUri method. /// /// /// The media type of part content. /// A value that describes the way to compress the part content of the part. /// /// A pointer to the new IOpcPart that represents the part. /// This parameter cannot be NULL. /// /// /// /// When a part object is created and a pointer to it is added to the set, the part it represents is serialized when the package /// is serialized. /// /// This method cannot create a part object that represents a Relationships part. /// /// If part content is compressed prior to the creation of the part object, pass the OPC_COMPRESSION_NONE value in the /// compressionOptions parameter. /// /// Part content that is already compressed will not compress significantly more. /// /// An IOpcPart provides access to the properties of a part. For details about these properties, see the Parts Overview and the /// IOpcPart topic. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartset-createpart HRESULT CreatePart( IOpcPartUri // *name, LPCWSTR contentType, OPC_COMPRESSION_OPTIONS compressionOptions, IOpcPart **part ); IOpcPart CreatePart(IOpcPartUri name, [MarshalAs(UnmanagedType.LPWStr)] string contentType, OPC_COMPRESSION_OPTIONS compressionOptions); /// Deletes the IOpcPart interface pointer of a specified part object from the set. /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name. /// /// /// When an IOpcPart interface pointer is deleted from the set, the part it represents is not serialized when the package is /// serialized. Additionally, if the represented part is the source of one or more relationships, those relationships are not /// saved with the package when the package object is written. /// /// /// The data contained in a deleted part object is accessible until the package object that contains the deleted part object is /// released. Additionally, a Relationship whose source is the part that is represented by the deleted part object also remains /// accessible until the package object that contains the deleted part object is released. However, these relationships will not /// be saved when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartset-deletepart HRESULT DeletePart( IOpcPartUri // *name ); void DeletePart(IOpcPartUri name); /// Gets a value that indicates whether a specified part is represented as a part object in the set. /// A pointer to an IOpcPartUri that represents the part name of the part. /// /// One of the following values: /// /// /// Value /// Meaning /// /// /// TRUE /// A part that has the specified part name is represented in the set. /// /// /// FALSE /// A part that has the specified part name is not represented in the set. /// /// /// /// /// /// To retrieve the IOpcPart interface pointer of the part object that represents a specific part, call the PartExists /// method and pass in the part name to confirm that the part is represented in the set. If it is, call the GetPart method and /// pass in the part name to retrieve the IOpcPart interface pointer. /// /// /// If the represented part name is the name of a Relationships part, partExists is receives FALSE because Relationships /// parts are not included in the set. /// /// If a part is represented in the set, the part exists in the package being read or the package to be written. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartset-partexists HRESULT PartExists( IOpcPartUri // *name, BOOL *partExists ); [return: MarshalAs(UnmanagedType.Bool)] bool PartExists(IOpcPartUri name); /// Gets an enumerator of IOpcPart interface pointers in the set. /// A pointer to the IOpcPartEnumerator interface of the enumerator of IOpcPart interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcpartset-getenumerator HRESULT GetEnumerator( // IOpcPartEnumerator **partEnumerator ); IOpcPartEnumerator GetEnumerator(); } /// /// Represents the part name of a part. If the part is a Relationships part, it is represented by the IOpcRelationshipSet interface; /// otherwise, it is represented by the IOpcPart interface. /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this interface is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcparturi [PInvokeData("msopc.h", MSDNShortId = "81123212-7a32-4833-b81f-8454a544327d")] [ComImport, Guid("7D3BABE7-88B2-46BA-85CB-4203CB016C87"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcPartUri : IOpcUri { /// Returns the specified Uniform Resource Identifier (URI) property value in a new BSTR. /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// /// [out] /// Address of a BSTR that receives the property value. /// /// /// [in] /// One of the following property-specific flags, or zero. /// Uri_DISPLAY_NO_FRAGMENT (0x00000001) /// Uri_PROPERTY_DISPLAY_URI: Exclude the fragment portion of the URI, if any. /// Uri_PUNYCODE_IDN_HOST (0x00000002) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: If the URI is an IDN, always display /// the hostname encoded as punycode. /// /// Uri_DISPLAY_IDN_HOST (0x00000004) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: Display the hostname in punycode or /// Unicode as it would appear in the Uri_PROPERTY_DISPLAY_URI property. /// /// /// /// IUri::GetPropertyBSTR was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a string property. This method will fail if the specified property isn't a BSTR property. /// /// /// The pbstrProperty parameter will be set to a new BSTR containing the value of the specified string property. The /// caller should use SysFreeString to free the string. /// /// This method will return and set pbstrProperty to an empty string if the URI doesn't contain the specified property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775026(v=vs.85) // HRESULT GetPropertyBSTR( [in] Uri_PROPERTY uriProp, [out] BSTR *pbstrProperty, [in] DWORD dwFlags ); new void GetPropertyBSTR([In] Uri_PROPERTY uriProp, [MarshalAs(UnmanagedType.BStr)] out string pbstrProperty, [In] Uri_DISPLAY dwFlags); /// /// Returns the string length of the specified Uniform Resource Identifier (URI) property. Call this function if you want the /// length but don't necessarily want to create a new BSTR. /// /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// /// [out] /// /// Address of a DWORD that is set to the length of the value of the string property excluding the NULL terminator. /// /// /// /// [in] /// One of the following property-specific flags, or zero. /// Uri_DISPLAY_NO_FRAGMENT (0x00000001) /// Uri_PROPERTY_DISPLAY_URI: Exclude the fragment portion of the URI, if any. /// Uri_PUNYCODE_IDN_HOST (0x00000002) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: If the URI is an IDN, always display /// the hostname encoded as punycode. /// /// Uri_DISPLAY_IDN_HOST (0x00000004) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: Display the hostname in punycode or /// Unicode as it would appear in the Uri_PROPERTY_DISPLAY_URI property. /// /// /// /// IUri::GetPropertyLength was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a string property. This method will fail if the specified property isn't a BSTR property. /// /// This method will return and set pcchProperty to if the URI doesn't contain the specified property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775028(v=vs.85) // HRESULT GetPropertyLength( [in] Uri_PROPERTY uriProp, [out] DWORD *pcchProperty, [in] DWORD dwFlags ); new void GetPropertyLength([In] Uri_PROPERTY uriProp, out uint pcchProperty, [In] Uri_DISPLAY dwFlags); /// Returns the specified numeric Uniform Resource Identifier (URI) property value. /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// Address of a DWORD that is set to the value of the specified property. /// Property-specific flags. Must be set to 0. /// /// IUri::GetPropertyDWORD was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a numeric property. This method will fail if the specified property isn't a DWORD property. /// /// This method will return and set pdwProperty to if the specified property doesn't exist in the URI. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775027(v=vs.85) // HRESULT GetPropertyDWORD( [in] Uri_PROPERTY uriProp, [out] DWORD *pdwProperty, [in] DWORD dwFlags ); new void GetPropertyDWORD([In] Uri_PROPERTY uriProp, out uint pdwProperty, [In] uint dwFlags); /// Determines if the specified property exists in the Uniform Resource Identifier (URI). /// Address of a BOOL value. Set to TRUE if the specified property exists in the URI. /// IUri::HasProperty was introduced in Windows Internet Explorer 7. // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775036(v=vs.85) // HRESULT HasProperty( [in] Uri_PROPERTY uriProp, [out] BOOL *pfHasProperty ); [return: MarshalAs(UnmanagedType.Bool)] new bool HasProperty([In] Uri_PROPERTY uriProp); /// Returns the entire canonicalized Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetAbsoluteUri was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_ABSOLUTE_URI property. /// /// This property is not defined for relative URIs. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775013%28v%3dvs.85%29 // HRESULT GetAbsoluteUri( [out] BSTR *pbstrAbsoluteUri ); [return: MarshalAs(UnmanagedType.BStr)] new string GetAbsoluteUri(); /// Returns the user name, password, domain, and port. /// Address of a string that receives the property value. /// /// IUri::GetAuthority was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_AUTHORITY property. /// /// /// If user name and password are not specified, the separator characters (: and @) are removed. The trailing colon is also /// removed if the port number is not specified or is the default for the protocol scheme. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775014(v=vs.85) // HRESULT GetAuthority( [out] BSTR *pbstrAuthority ); [return: MarshalAs(UnmanagedType.BStr)] new string GetAuthority(); /// Returns a Uniform Resource Identifier (URI) that can be used for display purposes. /// Address of a string that receives the property value. /// /// IUri::GetDisplayUri was introduced in Windows Internet Explorer 7. /// /// The display URI combines protocol scheme, fully qualified domain name, port number (if not the default for the scheme), full /// resource path, query string, and fragment. /// /// /// Note The display URI may have additional formatting applied to it, such that the string produced by /// IUri::GetDisplayUri isn't necessarily a valid URI. For this reason, and since the userinfo is not present, the /// display URI should be used for viewing only; it should not be used for edit by the user, or as a form of transfer for URIs /// inside or between applications. /// /// /// If the scheme is known (for example, http, ftp, or file) then the display URI will hide credentials. However, if the URI /// uses an unknown scheme and supplies user name and password, the display URI will also contain the user name and password. /// /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_DISPLAY_URI property and no flags. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775015(v=vs.85) // HRESULT GetDisplayUri( [out] BSTR *pbstrDisplayString ); [return: MarshalAs(UnmanagedType.BStr)] new string GetDisplayUri(); /// Returns the domain name (including top-level domain) only. /// Address of a string that receives the property value. /// /// IUri::GetDomain was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_DOMAIN property. /// /// /// If the URL contains only a plain hostname (for example, "http://example/") or a public suffix (for example, /// "http://co.uk/"), then IUri::GetDomain returns NULL. Use IUri::GetHost instead. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775016(v=vs.85) // HRESULT GetDomain( [out] BSTR *pbstrDomain ); [return: MarshalAs(UnmanagedType.BStr)] new string GetDomain(); /// Returns the file name extension of the resource. /// Address of a string that receives the property value. /// /// IUri::GetExtension was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_EXTENSION property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775017(v=vs.85) // HRESULT GetExtension( [out] BSTR *pbstrExtension ); [return: MarshalAs(UnmanagedType.BStr)] new string GetExtension(); /// Returns the text following a fragment marker (#), including the fragment marker itself. /// Address of a string that receives the property value. /// /// IUri::GetFragment was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_FRAGMENT property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775018(v=vs.85) // HRESULT GetFragment( [out] BSTR *pbstrFragment ); [return: MarshalAs(UnmanagedType.BStr)] new string GetFragment(); /// Returns the fully qualified domain name. /// Address of a string that receives the property value. /// /// IUri::GetHost was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_HOST property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775019(v=vs.85) // HRESULT GetHost( [out] BSTR *pbstrHost ); [return: MarshalAs(UnmanagedType.BStr)] new string GetHost(); /// Returns the password, as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetPassword was introduced in Windows Internet Explorer 7. /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_PASSWORD property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775021(v=vs.85) // HRESULT GetPassword( [out] BSTR *pbstrPassword ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPassword(); /// Returns the path and resource name. /// Address of a string that receives the property value. /// /// IUri::GetPath was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_PATH property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775022(v=vs.85) // HRESULT GetPath( [out] BSTR *pbstrPath ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPath(); /// Returns the path, resource name, and query string. /// Address of a string that receives the property value. /// /// IUri::GetPathAndQuery was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_PATH_AND_QUERY property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775023(v=vs.85) // HRESULT GetPathAndQuery( [out] BSTR *pbstrPathAndQuery ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPathAndQuery(); /// Returns the query string. /// Address of a string that receives the property value. /// /// IUri::GetQuery was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_QUERY property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775029(v=vs.85) // HRESULT GetQuery( [out] BSTR *pbstrQuery ); [return: MarshalAs(UnmanagedType.BStr)] new string GetQuery(); /// Returns the entire original Uniform Resource Identifier (URI) input string. /// Address of a string that receives the property value. /// /// IUri::GetRawUri was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_RAW_URI property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775030(v=vs.85) // HRESULT GetRawUri( [out] BSTR *pbstrRawUri ); [return: MarshalAs(UnmanagedType.BStr)] new string GetRawUri(); /// Returns the protocol scheme name. /// Address of a string that receives the property value. /// /// IUri::GetSchemeName was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_SCHEME_NAME property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775032(v=vs.85) // HRESULT GetSchemeName( [out] BSTR *pbstrSchemeName ); [return: MarshalAs(UnmanagedType.BStr)] new string GetSchemeName(); /// Returns the user name and password, as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetUserInfo was introduced in Windows Internet Explorer 7. /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_USER_INFO property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775033(v=vs.85) // HRESULT GetUserInfo( [out] BSTR *pbstrUserInfo ); [return: MarshalAs(UnmanagedType.BStr)] new string GetUserInfo(); /// Returns the user name as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_USER_NAME property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775034(v=vs.85) // HRESULT GetUserName( [out] BSTR *pbstrUserName ); [return: MarshalAs(UnmanagedType.BStr)] new string GetUserName(); /// Returns a value from the Uri_HOST_TYPE enumeration. /// Address of a DWORD that receives a value from the Uri_HOST_TYPE enumeration. /// /// IUri::GetHostType was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the /// Uri_PROPERTY_HOST_TYPE property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775020(v=vs.85) // HRESULT GetHostType( [out] DWORD *pdwHostType ); new Uri_HOST_TYPE GetHostType(); /// Returns the port number. /// Address of a DWORD that receives the port number value. /// /// IUri::GetPort was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the Uri_PROPERTY_PORT property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775024(v=vs.85) // HRESULT GetPort( [out] DWORD *pdwPort ); new uint GetPort(); /// Returns a value from the URL_SCHEME enumeration. /// Address of a DWORD that receives a value from the URL_SCHEME enumeration. /// /// IUri::GetScheme was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the /// Uri_PROPERTY_SCHEME property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775031(v=vs.85) // HRESULT GetScheme( [out] DWORD *pdwScheme ); new URL_SCHEME GetScheme(); /// This method is not implemented. /// new URLZONE GetZone(); /// Returns a bitmap of flags that indicate which Uniform Resource Identifier (URI) properties have been set. /// /// [out] /// Address of a DWORD that receives a combination of the following flags: /// Uri_HAS_ABSOLUTE_URI (0x00000000) /// Uri_PROPERTY_ABSOLUTE_URI exists. /// Uri_HAS_AUTHORITY (0x00000001) /// Uri_PROPERTY_AUTHORITY exists. /// Uri_HAS_DISPLAY_URI (0x00000002) /// Uri_PROPERTY_DISPLAY_URI exists. /// Uri_HAS_DOMAIN (0x00000004) /// Uri_PROPERTY_DOMAIN exists. /// Uri_HAS_EXTENSION (0x00000008) /// Uri_PROPERTY_EXTENSION exists. /// Uri_HAS_FRAGMENT (0x00000010) /// Uri_PROPERTY_FRAGMENT exists. /// Uri_HAS_HOST (0x00000020) /// Uri_PROPERTY_HOST exists. /// Uri_HAS_HOST_TYPE (0x00004000) /// Uri_PROPERTY_HOST_TYPE exists. /// Uri_HAS_PASSWORD (0x00000040) /// Uri_PROPERTY_PASSWORD exists. /// Uri_HAS_PATH (0x00000080) /// Uri_PROPERTY_PATH exists. /// Uri_HAS_PATH_AND_QUERY (0x00001000) /// Uri_PROPERTY_PATH_AND_QUERY exists. /// Uri_HAS_PORT (0x00008000) /// Uri_PROPERTY_PORT exists. /// Uri_HAS_QUERY (0x00000100) /// Uri_PROPERTY_QUERY exists. /// Uri_HAS_RAW_URI (0x00000200) /// Uri_PROPERTY_RAW_URI exists. /// Uri_HAS_SCHEME (0x00010000) /// Uri_PROPERTY_SCHEME exists. /// Uri_HAS_SCHEME_NAME (0x00000400) /// Uri_PROPERTY_SCHEME_NAME exists. /// Uri_HAS_USER_NAME (0x00000800) /// Uri_PROPERTY_USER_NAME exists. /// Uri_HAS_USER_INFO (0x00002000) /// Uri_PROPERTY_USER_INFO exists. /// Uri_HAS_ZONE (0x00020000) /// Uri_PROPERTY_ZONE exists. /// /// IUri::GetProperties was introduced in Windows Internet Explorer 7. // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775025(v=vs.85) // HRESULT GetProperties( [out] LPDWORD pdwFlags ); new Uri_HAS GetProperties(); /// Compares the logical content of two IUri objects. /// Address of a BOOL that is set to TRUE if the logical content of pUri is the same. /// /// IUri::IsEqual was introduced in Windows Internet Explorer 7. /// The comparison is case-insensitive. Comparing an IUri to itself will always return TRUE. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775037(v=vs.85) // HRESULT IsEqual( [in] IUri *pUri, [out] BOOL *pfEqual ); [return: MarshalAs(UnmanagedType.Bool)] new bool IsEqual([In] IUri pUri); /// /// Gets the part name of the Relationships part that stores relationships that have the source URI represented by the current /// OPC URI object. /// /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name of the Relationships part. The /// source URI of the relationships stored in this Relationships part is represented by the current OPC URI object. /// /// /// The following table shows Relationships part URIs for some OPC URIs. /// /// /// OPC URI /// Relationships Part Name /// Return Value /// /// /// /mydoc/images/picture.jpg /// /mydoc/images/_rels/picture.jpg.rels /// S_OK /// /// /// / /// /_rels/.rels /// S_OK /// /// /// /mydoc/images/_rels/picture.jpg.rels /// Undefined /// OPC_E_NONCONFORMING_URI /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-getrelationshipsparturi HRESULT // GetRelationshipsPartUri( IOpcPartUri **relationshipPartUri ); new IOpcPartUri GetRelationshipsPartUri(); /// Forms a relative URI for a specified part, relative to the URI represented by the current OPC URI object. /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name from which the relative URI is formed. /// /// A pointer to the IUri interface of the URI of the part, relative to the current OPC URI object. /// /// Example input and output: /// /// /// Input IOpcPartUri represents /// Current IOpcUri represents /// Returned relative IUri represents /// /// /// /mydoc/markup/page.xml /// /mydoc/markup/picture.jpg /// picture.jpg /// /// /// /mydoc/markup/page.xml /// /mydoc/picture.jpg /// ../picture.jpg /// /// /// /mydoc/markup/page.xml /// /mydoc/images/pictures.jpg /// ../images/pictures.jpg /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-getrelativeuri HRESULT GetRelativeUri( IOpcPartUri // *targetPartUri, IUri **relativeUri ); new IUri GetRelativeUri([In] IOpcPartUri targetPartUri); /// /// Forms the part name of the part that is referenced by the specified relative URI. The specified relative URI of the part is /// resolved against the URI represented as the current OPC URI object. /// /// /// A pointer to the IUri interface of the relative URI of the part. /// /// To form the part URI object that represents the part name, this input URI is resolved against the URI represented as the /// current OPC URI object. Therefore, the input URI must be relative to the URI represented by the current OPC URI object. /// /// /// This URI may include a fragment component; however, the fragment will be ignored and will not be included in the part name /// to be formed. A fragment component is preceded by a '#', as described in RFC 3986: URI Generic Syntax. /// /// /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name. /// /// The part URI object is formed by resolving the relative URI in relativeUri against the URI represented by the current OPC /// URI object. /// /// /// /// Example input and output: /// /// /// Input relative IUri /// Current IOpcUri /// Formed IOpcPartUri /// /// /// picture.jpg /// /mydoc/markup/page.xml /// /mydoc/markup/picture.jpg /// /// /// ../picture.jpg /// /mydoc/markup/page.xml /// /mydoc/picture.jpg /// /// /// ../../images/picture.jpg /// /mydoc/page.xml /// /images/picture.jpg /// /// /// /// For information about how to use this method to help resolve a part name, see Resolving a Part Name from a Target URI. /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-combineparturi HRESULT CombinePartUri( IUri // *relativeUri, IOpcPartUri **combinedUri ); new IOpcPartUri CombinePartUri([In] IUri relativeUri); /// /// Returns an integer that indicates whether the URIs represented by the current part URI object and a specified part URI /// object are equivalent. /// /// /// A pointer to the IOpcPartUri interface of the part URI object to compare with the current part URI object. /// /// /// Receives an integer that indicates whether the two part URI objects are equivalent. /// /// /// Value /// Meaning /// /// /// <0 /// The current part URI object is less than the input part URI object that is passed in partUri. /// /// /// 0 /// The current part URI object is equivalent to the input part URI object that is passed in partUri. /// /// /// >0 /// The current part URI object is greater than the input part URI object that is passed in partUri. /// /// /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcparturi-compareparturi HRESULT ComparePartUri( // IOpcPartUri *partUri, INT32 *comparisonResult ); int ComparePartUri([In] IOpcPartUri partUri); /// /// Gets the source URI of the relationships that are stored in a Relationships part. The current part URI object represents the /// part name of that Relationships part. /// /// /// A pointer to the IOpcUri interface of the OPC URI object that represents the URI of the source of the relationships stored /// in the Relationships part. /// /// /// /// If the current part URI object represents the part name of the Relationships part that stores package relationships /// ("/_rels/.rels"), the OPC URI object returned in sourceUri will represent the package root ("/"). /// /// /// If the current part URI object is not the part name of a Relationships part, this method fails with the /// OPC_E_RELATIONSHIP_URI_REQUIRED error. The syntax for Relationship part names is specified in the OPC. /// /// The following table shows possible current part URIs and the source URI that would be returned by this method. /// /// /// Current Part URI /// Current Part URI Description /// Source URI /// Source URI Description /// Return Value /// /// /// /mydoc/_rels/picture.jpg.rels /// The part name of a Relationships part /// /mydoc/picture.jpg /// /// The part name of the part that is the source of the relationships stored in the Relationships part that is represented by /// the current part URI object /// /// S_OK /// /// /// /_rels/.rels /// The part name of a Relationships part /// / /// /// The package root; the source of the relationships stored in the Relationships part that is represented by the current part /// URI object /// /// S_OK /// /// /// /mydoc/image/chart1.jpg /// The part name of a part that is not a Relationships part /// Undefined /// Undefined /// OPC_E_RELATIONSHIP_URI_REQUIRED /// /// /// /_rels/a.jpg /// The part name of a part that is not a Relationships part /// Undefined /// Undefined /// OPC_E_RELATIONSHIP_URI_REQUIRED /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcparturi-getsourceuri HRESULT GetSourceUri( IOpcUri // **sourceUri ); IOpcUri GetSourceUri(); /// /// Returns a value that indicates whether the current part URI object represents the part name of a Relationships part. /// /// /// Receives a value that indicates whether the current part URI object represents the part name of a Relationships part. /// /// /// Value /// Meaning /// /// /// TRUE /// The current part URI object represents the part name of a Relationships part. /// /// /// FALSE /// The current part URI object does not represent the part name of a Relationships part. /// /// /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcparturi-isrelationshipsparturi HRESULT // IsRelationshipsPartUri( BOOL *isRelationshipUri ); [return: MarshalAs(UnmanagedType.Bool)] bool IsRelationshipsPartUri(); } /// /// Represents a relationship, which is a link between a source, which is a part or the package, and a target. The relationship's /// target can be a part or external resource. /// /// /// /// To create a relationship object to represent a relationship, call the IOpcRelationshipSet::CreateRelationship method. To get a /// pointer to the interface of a relationship object that represents an existing relationship, call the /// IOpcRelationshipSet::GetRelationship or IOpcRelationshipEnumerator::GetCurrent method. /// /// Example relationship markup for a relationship that targets a part: /// /// Using the relationship type ( Type attribute of the Relationship element) is the definitive way find a part in a /// package. For more information about why the relationship type is used, see the Parts Overview. For an example of to use the /// relationship type to find a part, see Finding the Core Properties Part. /// /// /// Valid identifiers for relationships conform to the restrictions for xsd:ID, which are documented in section 3.3.8 ID of /// the W3C Recommendation, XML Schema Part 2: Datatypes Second Edition (http://go.microsoft.com/fwlink/p/?linkid=126664). /// /// /// IOpcRelationship interface methods provide access to relationship properties for a relationship (which is represented by /// a relationship object). The methods, associated properties and descriptions are listed in the following table. /// /// /// /// Method /// Property /// Description /// /// /// GetId /// Relationship identifier /// The unique, arbitrary identifier of a relationship that is local to the package. /// /// /// GetRelationshipType /// Relationship type /// The qualified name of a relationship defined by the package designer. /// /// /// GetSourceUri /// Source URI /// The URI of the relationship's source. The source URI can be the URI of the package or of a part. /// /// /// GetTargetMode /// Target mode /// Indicates whether the relationship's target is internal or external to the package. /// /// /// GetTargetUri /// Target URI /// The URI of the relationship's target. /// /// /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationship [PInvokeData("msopc.h")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE72"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationship { /// Gets the unique identifier of the relationship. /// /// The identifier of the relationship. /// The identifier of a relationship is arbitrary and local to the package, and, therefore, . /// /// Valid identifiers conform to the restrictions for xsd:ID, which are documented in section 3.3.8 ID of the W3C /// Recommendation, XML Schema Part 2: Datatypes Second Edition (http://go.microsoft.com/fwlink/p/?linkid=126664). /// /// /// /// /// The identifier of a relationship is not useful for finding relationships because it is arbitrary and local to the package. /// /// The definitive way to find a part of interest is by using a relationship type. /// /// Finding a part requires several steps. For detailed information about finding a part, see Finding the Core Properties Part. /// /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st /// Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationship-getid HRESULT GetId( LPWSTR // *relationshipIdentifier ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetId(); /// Gets the relationship type. /// /// /// Receives the relationship type, which is the qualified name of the relationship, as defined by the package format designer /// or the OPC. /// /// For more information about relationship types see Remarks. /// /// /// The definitive way to find a part of interest is by using a relationship type. /// /// Finding a part of interest requires several steps. For detailed information about finding a part, see Finding the Core /// Properties Part. /// /// /// For more information about relationships, relationship types and a list of relationship types defined by the OPC, see the /// Open Packaging Conventions Fundamentals and the OPC. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationship-getrelationshiptype HRESULT // GetRelationshipType( LPWSTR *relationshipType ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetRelationshipType(); /// Gets the URI of the relationship source. /// A pointer to the IOpcUri interface of the OPC URI object that represents the URI of the relationship source. /// /// If the source of a relationship is the package itself, the URI in sourceUri represents the package root: "/". /// /// If the relationship target is a part, form the part name by calling the IOpcUri::CombinePartUri method from the IOpcUri /// interface pointer received in sourceUri. Use the relative URI received in the targetUri parameter of the GetTargetUri method /// as the input parameter of the IOpcUri::CombinePartUri call. For an example, see Resolving a Part Name from a Target URI. /// /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st /// Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationship-getsourceuri HRESULT GetSourceUri( IOpcUri // **sourceUri ); IOpcUri GetSourceUri(); /// Gets the URI of the relationship target. /// /// A pointer to the IUri interface of the URI that represents the URI of the relationship's target. /// /// If the relationship target is internal, the target is a part and the URI of the target is relative to the URI of the source part. /// /// /// /// The definitive way to find a part of interest is by using a relationship type. /// /// Finding a part of interest requires several steps. For detailed information about finding a part, see the Parts Overview and /// Finding the Core Properties Part. /// /// To determine whether the target of the relationship is internal or external, call the GetTargetUri method. /// If the relationship target is internal, the target is a part. /// If the relationship target is a part, the URI in targetUri is relative to the URI of the relationship source. /// /// If the relationship target is a part, form the part name by calling the IOpcUri::CombinePartUri method from the IOpcUri /// interface pointer received in sourceUri parameter of the GetSourceUri method. Use the relative URI received in targetUri as /// the input parameter of the IOpcUri::CombinePartUri call. For an example, see Resolving a Part Name from a Target URI. /// /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st /// Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationship-gettargeturi HRESULT GetTargetUri( IUri // **targetUri ); IUri GetTargetUri(); /// Gets a value that describes whether the relationship's target is internal or external to the package. /// /// A value that describes whether the relationship's target is internal or external to the package. /// If the target of the relationship is internal, the target is a part. /// If the target of the relationship is external, the target is a resource outside of the package. /// /// /// /// If the relationship target is internal, the target is a part. The URI of the target is relative to the URI of the source part. /// /// To get the URI of the target of the relationship, call the IOpcRelationship::GetTargetUri method. /// The definitive way to find a part of interest is by using a relationship type. /// /// Finding a part of interest requires several steps. For detailed information about finding a part, see the Parts Overview and /// Finding the Core Properties Part. /// /// /// For more information about relationships, see the Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st /// Edition, Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationship-gettargetmode HRESULT GetTargetMode( // OPC_URI_TARGET_MODE *targetMode ); OPC_URI_TARGET_MODE GetTargetMode(); } /// A read-only enumerator of IOpcRelationship interface pointers. /// /// /// To get a pointer to this interface, call either the IOpcRelationshipSet::GetEnumerator or the /// IOpcRelationshipSet::GetEnumeratorForType method. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Note Changes to the set will invalidate the enumerator, and all subsequent calls will fail. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationshipenumerator [PInvokeData("msopc.h")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE76"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationshipEnumerator { /// Moves the current position of the enumerator to the next IOpcRelationship interface pointer. /// /// A Boolean value that indicates the status of the IOpcRelationship interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNext method after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipenumerator-movenext HRESULT MoveNext( BOOL // *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcRelationship interface pointer. /// /// A Boolean value that indicates the status of the IOpcRelationship interface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the enumerator and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcRelationship interface pointer at the current position of the enumerator. /// An IOpcRelationship interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipenumerator-getcurrent HRESULT GetCurrent( // IOpcRelationship **relationship ); [PreserveSig] HRESULT GetCurrent(out IOpcRelationship relationship); /// Creates a copy of the current enumerator and all its descendants. /// A pointer to the IOpcRelationshipEnumerator interface of the new enumerator. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipenumerator-clone HRESULT Clone( // IOpcRelationshipEnumerator **copy ); IOpcRelationshipEnumerator Clone(); } /// Represents how to select, from a Relationships part, the relationships to be referenced for signing. /// /// To create an IOpcRelationshipSelector interface pointer, call the IOpcRelationshipSelectorSet::Create method. /// To access an IOpcRelationshipSelector, call the IOpcRelationshipSelectorEnumerator::GetCurrent method. /// /// Use the IOpcRelationshipSelector interface methods to select relationships for signing. A relationship is selected if its /// type or identifier matches the string that is retrieved by calling the GetSelectionCriterion method. This string is either a /// relationship type or a relationship identifier. Call the GetSelectorType method to get an OPC_RELATIONSHIP_SELECTOR value to /// determine whether the string is a relationship type or an identifier. To access these relationship properties, call the /// IOpcRelationship::GetRelationshipType and IOpcRelationship::GetId methods. /// /// /// The following table shows how OPC_RELATIONSHIP_SELECTOR values map to the relationship type and relationship identifier properties. /// /// /// /// OPC_RELATIONSHIP_SELECTOR Value /// Relationship Property /// Description /// /// /// OPC_RELATIONSHIP_SELECT_BY_TYPE /// Relationship type /// Selects relationships that have a relationship type that matches selectionCriterion string. /// /// /// OPC_RELATIONSHIP_SELECT_BY_ID /// Relationship identifier /// Selects relationships that have a relationship identifier that matches selectionCriterion string. /// /// /// /// When a signature is generated, the relationship selection information provided by the interface is serialized in the XML markup /// of the signature (signature markup). In signature markup, this information is represented by the RelationshipReference /// and RelationshipGroupReference elements, which are specified in section 12. Digital Signatures in the ECMA-376 OpenXML, /// 1st Edition, Part 2: Open Packaging Conventions (OPC). The following table shows how the elements map to relationship properties /// and to OPC_RELATIONSHIP_SELECTOR values. /// /// /// /// Package signature element /// Relationship Property /// OPC_RELATIONSHIP_SELECTOR Value /// /// /// RelationshipGroupReference /// Relationship type /// OPC_RELATIONSHIP_SELECT_BY_TYPE /// /// /// RelationshipReference /// Relationship identifier /// OPC_RELATIONSHIP_SELECT_BY_ID /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationshipselector [PInvokeData("msopc.h")] [ComImport, Guid("f8f26c7f-b28f-4899-84c8-5d5639ede75f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationshipSelector { /// Gets a value that describes how relationships are selected to be referenced for signing. /// /// A value that describes which IOpcRelationship interface property will be compared to the string returned by the /// GetSelectionCriterion method. /// /// /// /// The following table shows how OPC_RELATIONSHIP_SELECTOR values map to the relationship type and relationship identifier properties. /// /// /// /// OPC_RELATIONSHIP_SELECTOR Value /// Relationship Property /// Description /// /// /// OPC_RELATIONSHIP_SELECT_BY_TYPE /// Relationship type /// Selects relationships that have a relationship type that matches selectionCriterion string. /// /// /// OPC_RELATIONSHIP_SELECT_BY_ID /// Relationship identifier /// Selects relationships that have a relationship identifier that matches selectionCriterion string. /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselector-getselectortype HRESULT // GetSelectorType( OPC_RELATIONSHIP_SELECTOR *selector ); OPC_RELATIONSHIP_SELECTOR GetSelectorType(); /// Gets a string that is used to select relationships to be referenced for signing. /// A string used to select relationships to be referenced for signing. /// /// /// Use the IOpcRelationshipSelector interface methods to select relationships for signing. A relationship is selected if its /// type or identifier matches the string that is retrieved by calling the GetSelectionCriterion method. This string is /// either a relationship type or a relationship identifier. Call the GetSelectorType method to get an OPC_RELATIONSHIP_SELECTOR /// value to determine whether the string is a relationship type or an identifier. To access these relationship properties, call /// the IOpcRelationship::GetRelationshipType and IOpcRelationship::GetId methods. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselector-getselectioncriterion HRESULT // GetSelectionCriterion( LPWSTR *selectionCriterion ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSelectionCriterion(); } /// A read-only enumerator of IOpcRelationshipSelector interface pointers. /// /// When an enumerator is created, the current position precedes the first pointer. /// To set the current position to the first pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// Changes to the set will invalidate the enumerator, and all subsequent calls to it will fail. /// /// To get an IOpcRelationshipSelectorEnumerator interface pointer, call the IOpcRelationshipSelectorSet::GetEnumerator or /// IOpcSignatureRelationshipReference::GetRelationshipSelectorEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationshipselectorenumerator [PInvokeData("msopc.h")] [ComImport, Guid("5e50a181-a91b-48ac-88d2-bca3d8f8c0b1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationshipSelectorEnumerator { /// Moves the current position of the enumerator to the next IOpcRelationshipSelectorinterface pointer. /// /// A Boolean value that indicates the status of the IOpcRelationshipSelector interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorenumerator-movenext HRESULT // MoveNext( BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcRelationshipSelectorinterface pointer. /// /// A Boolean value that indicates the status of the IOpcRelationshipSelectorinterface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcRelationshipSelector interface pointer at the current position of the enumerator. /// An IOpcRelationshipSelector interface pointer . /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. /// To set the current position to the first pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorenumerator-getcurrent HRESULT // GetCurrent( IOpcRelationshipSelector **relationshipSelector ); [PreserveSig] HRESULT GetCurrent(out IOpcRelationshipSelector relationshipSelector); /// Creates a copy of the current IOpcRelationshipSelectorEnumeratorinterface pointer and all its descendants. /// A pointer to a copy of the IOpcRelationshipSelectorEnumeratorinterface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorenumerator-clone HRESULT Clone( // IOpcRelationshipSelectorEnumerator **copy ); IOpcRelationshipSelectorEnumerator Clone(); } /// /// An unordered set of IOpcRelationshipSelector interface pointers that represent the selection criteria that is used to identify /// relationships for signing. The subset is selected from the relationships stored in a Relationships part. /// /// /// Use the methods of the IOpcRelationshipSelector interface pointers in the set to select relationships for signing. /// /// To create an IOpcRelationshipSelectorSet interface pointer, call the /// IOpcSignatureRelationshipReference::CreateRelationshipSelectorSet method. /// /// /// When an IOpcRelationshipSelector interface pointer is created and added to the set, the criterion it provides access to is saved /// when the package is saved. /// /// /// When an IOpcRelationshipSelector interface pointer is deleted from the set, the criterion it provides access to is not saved /// when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationshipselectorset [PInvokeData("msopc.h")] [ComImport, Guid("6e34c269-a4d3-47c0-b5c4-87ff2b3b6136"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationshipSelectorSet { /// /// Creates an IOpcRelationshipSelector interface pointer to represent how a subset of relationships are selected to be signed, /// and adds the new pointer to the set. /// /// A value that describes how to interpret the string that is passed in selectionCriterion. /// A string that is interpreted to yield a criterion. /// /// /// A new IOpcRelationshipSelector interface pointer that represents how relationships are selected from a Relationships part. /// /// This parameter can be NULL if a pointer to the new interface is not needed. /// /// /// Use the methods of the IOpcRelationshipSelector interface pointers in the set to select relationships for signing. /// /// When an IOpcRelationshipSelector interface pointer is created and added to the set, the criterion it provides access to is /// saved when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorset-create HRESULT Create( // OPC_RELATIONSHIP_SELECTOR selector, LPCWSTR selectionCriterion, IOpcRelationshipSelector **relationshipSelector ); IOpcRelationshipSelector Create(OPC_RELATIONSHIP_SELECTOR selector, [MarshalAs(UnmanagedType.LPWStr)] string selectionCriterion); /// Deletes a specified IOpcRelationshipSelector interface pointer from the set. /// An IOpcRelationshipSelector interface pointer to be deleted. /// /// /// When an IOpcRelationshipSelector interface pointer is deleted from the set, the criterion it provides access to is not saved /// when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorset-delete HRESULT Delete( // IOpcRelationshipSelector *relationshipSelector ); void Delete(IOpcRelationshipSelector relationshipSelector); /// Gets an enumerator of IOpcRelationshipSelector interface pointers in the set. /// A pointer to an enumerator of the IOpcRelationshipSelector interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipselectorset-getenumerator HRESULT // GetEnumerator( IOpcRelationshipSelectorEnumerator **relationshipSelectorEnumerator ); IOpcRelationshipSelectorEnumerator GetEnumerator(); } /// Represents a Relationships part as an unordered set of IOpcRelationship interface pointers to relationship objects. /// /// /// When a relationship object is created and a pointer to it is added to the set, the relationship it represents is saved when the /// package is saved. /// /// /// When an IOpcRelationship interface pointer is deleted from the set, the relationship it represents is not saved when the package /// is saved. /// /// If a relationship is represented in the set, the relationship is stored in the Relationships part represented as the set. /// For how to form the part name for the target of a relationship, see Resolving a Part Name from a Target URI. /// /// For more information about relationships, see Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// /// The IOpcRelationship interface provides access to relationship properties. For details about these properties, see the /// Relationships Overview and IOpcRelationship. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcrelationshipset [PInvokeData("msopc.h")] [ComImport, Guid("42195949-3B79-4fc8-89C6-FC7FB979EE74"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcRelationshipSet { /// Gets a relationship object from the set that represents a specified relationship. /// The unique identifier of a relationship. /// /// A pointer to the IOpcRelationship interface of the relationship object that represents the relationship that has the /// specified identifier. /// /// /// /// The IOpcRelationship interface provides access to relationship properties. For details about these properties, see the /// Relationships Overview and IOpcRelationship. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-getrelationship HRESULT // GetRelationship( LPCWSTR relationshipIdentifier, IOpcRelationship **relationship ); IOpcRelationship GetRelationship([MarshalAs(UnmanagedType.LPWStr)] string relationshipIdentifier); /// /// Creates a relationship object that represents a specified relationship, then adds to the set a pointer to the object's /// IOpcRelationship interface. /// /// /// /// A unique identifier of the relationship to be represented as the relationship object. To use a randomly generated /// identifier, pass NULL to this parameter. /// /// /// Valid identifiers conform to the restrictions for xsd:ID, which are documented in section 3.3.8 ID of the W3C /// Recommendation, XML Schema Part 2: Datatypes Second Edition (http://go.microsoft.com/fwlink/p/?linkid=126664). /// /// /// /// The relationship type that defines the role of the relationship to be represented as the relationship object. /// /// /// A URI to the target of the relationship to be represented as the relationship object. /// /// If the value in targetMode is OPC_URI_TARGET_MODE_INTERNAL, target is a part and the URI must be relative to the /// source of the relationship. /// /// /// If the value in targetMode is OPC_URI_TARGET_MODE_EXTERNAL, target is a resource outside of the package and the URI /// may be absolute or relative to the location of the package. /// /// For more information about the URI of a relationship's target, see the OPC. /// /// /// A value that indicates whether the target of the relationship to be represented as the relationship object is internal or /// external to the package. /// /// /// A pointer to the IOpcRelationship interface of the relationship object that represents the relationship. /// This parameter can be NULL if a pointer to the new object is not needed. /// /// /// /// When a relationship object is created and a pointer to it is added to the set, the relationship it represents is saved when /// the package is saved. /// /// /// The IOpcRelationship interface provides access to relationship properties. For details about these properties, see the /// Relationships Overview and IOpcRelationship. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-createrelationship HRESULT // CreateRelationship( LPCWSTR relationshipIdentifier, LPCWSTR relationshipType, IUri *targetUri, OPC_URI_TARGET_MODE // targetMode, IOpcRelationship **relationship ); IOpcRelationship CreateRelationship([Optional, MarshalAs(UnmanagedType.LPWStr)] string relationshipIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string relationshipType, IUri targetUri, OPC_URI_TARGET_MODE targetMode); /// Deletes a specified IOpcRelationship interface pointer from the set. /// /// The unique identifier of a relationship. /// /// The IOpcRelationship interface pointer to be deleted is the pointer to the relationship object that represents the /// relationship the specified identifier. /// /// /// /// /// When an IOpcRelationship interface pointer is deleted from the set, the relationship it represents is not saved when the /// package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-deleterelationship HRESULT // DeleteRelationship( LPCWSTR relationshipIdentifier ); void DeleteRelationship([MarshalAs(UnmanagedType.LPWStr)] string relationshipIdentifier); /// /// Gets a value that indicates whether a specified relationship is represented as a relationship object in the set. /// /// The unique identifier of a relationship. /// /// One of the following values: /// /// /// Value /// Meaning /// /// /// TRUE /// A relationship that has the identifier specified in relationshipIdentifier is represented in the set. /// /// /// FALSE /// A relationship that has the identifier specified in relationshipIdentifier is not represented in the set. /// /// /// /// /// /// If a relationship is represented in the set, the relationship is stored in the Relationships part represented by that set. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-relationshipexists HRESULT // RelationshipExists( LPCWSTR relationshipIdentifier, BOOL *relationshipExists ); [return: MarshalAs(UnmanagedType.Bool)] bool RelationshipExists([MarshalAs(UnmanagedType.LPWStr)] string relationshipIdentifier); /// Gets an enumerator of IOpcRelationship interface pointers in the set. /// /// A pointer to the IOpcRelationshipEnumerator interface of the enumerator of IOpcRelationship interface pointers in the set. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-getenumerator HRESULT GetEnumerator( // IOpcRelationshipEnumerator **relationshipEnumerator ); IOpcRelationshipEnumerator GetEnumerator(); /// /// Gets an enumerator of the IOpcRelationship interface pointers in the set that point to representations of relationships that /// have a specified relationship type. /// /// The relationship type used to identify IOpcRelationship interface pointers to be enumerated. /// /// A pointer to the IOpcRelationshipEnumerator interface of the enumerator of the IOpcRelationship interface pointers in the /// set that point to representations of relationships that have a specified relationship type. /// /// /// For information about forming the part name for the target of a relationship, see the IOpcRelationship topic. /// /// The IOpcRelationship interface provides access to relationship properties. For details about these properties, see the /// Relationships Overview and IOpcRelationship. /// /// /// For more information about relationships, see Open Packaging Conventions Fundamentals and the ECMA-376 OpenXML, 1st Edition, /// Part 2: Open Packaging Conventions (OPC). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-getenumeratorfortype HRESULT // GetEnumeratorForType( LPCWSTR relationshipType, IOpcRelationshipEnumerator **relationshipEnumerator ); IOpcRelationshipEnumerator GetEnumeratorForType([MarshalAs(UnmanagedType.LPWStr)] string relationshipType); /// Gets a read-only stream that contains the part content of the Relationships part represented by the set. /// /// /// A pointer to the IStream interface of the read-only stream that contains the part content of the Relationships part /// represented by the set. /// /// /// If the relationships stored in the Relationships part have not been modified, part content can include markup compatibility /// data that is not otherwise accessible through the relationship objects in the set. /// /// /// /// /// Calling this method will parse and validate all the relationships in the relationships markup. If the Relationships part /// contains invalid relationships markup, the markup cannot be retrieved by this method. /// /// /// For more information about markup compatibility and packages, see Part 5: Markup Compatibility in ECMA-376 OpenXML (http://go.microsoft.com/fwlink/p/?linkid=123375). /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcrelationshipset-getrelationshipscontentstream HRESULT // GetRelationshipsContentStream( IStream **contents ); IStream GetRelationshipsContentStream(); } /// Represents an application-specific Object element that has been or will be signed. /// /// /// An IOpcSignatureCustomObject interface pointer provides access to the XML markup of the Object element it /// represents. To access the XML markup of the Object element, call the IOpcSignatureCustomObject::GetXml method. /// /// /// Serialized application-specific Object elements in signature markup can be added, removed, or modified by replacing the /// signature markup. /// /// /// To replace signature markup, call the IOpcDigitalSignatureManager::ReplaceSignatureXml method. The caller must ensure that /// addition, deletion, or modification of application-specific Object elements does not break the signature. /// /// /// To sign an application-specific Object element or a child of the element, create a reference to the element to be signed. /// Create the reference by calling the IOpcSignatureReferenceSet::Create method with the referenceUri parameter value set to "#" /// followed by the Id attribute value of the referenced element. For example, if the Id attribute of the referenced /// element is "Application", set referenceUri to "#Application". /// /// To create an IOpcSignatureCustomObject interface pointer, call the IOpcSignatureCustomObjectSet::Create method. /// /// To access an IOpcSignatureCustomObject interface pointer, call the IOpcSignatureCustomObjectEnumerator::GetCurrent method. /// /// When a signature is generated, the markup of application-specific Object element is included in the signature markup. /// Application-specific Object elements are not required for package signatures. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturecustomobject [PInvokeData("msopc.h")] [ComImport, Guid("5d77a19e-62c1-44e7-becd-45da5ae51a56"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureCustomObject { /// Gets the XML markup of an application-specific Object element. /// /// /// A pointer to a buffer that contains the XML markup of an Object element and includes the opening and closing /// Object tags. /// /// In the buffer, XML markup is preceded by a byte order mark that corresponds to the encoding of the markup. /// Supported encodings and /// byte order mark /// values. /// /// /// Encoding /// Description /// Byte order mark /// /// /// UTF8 /// UTF-8 /// EF BB BF /// /// /// UTF16LE /// UTF-16, little endian /// FF FE /// /// /// UTF16BE /// UTF-16, big endian /// FE FF /// /// /// For an example of a buffer with a byte order mark, see the Remarks section. /// /// A pointer to the size of the xmlMarkup buffer. /// /// /// This method allocates memory used by the buffer returned in xmlMarkup. If the method succeeds, call the CoTaskMemFree /// function to free the memory. /// /// /// Serialized application-specific Object elements in signature markup can be added, removed, or modified by replacing /// the signature markup. /// /// /// To replace signature markup, call the IOpcDigitalSignatureManager::ReplaceSignatureXml method. The caller must ensure that /// addition, deletion, or modification of application-specific Object elements does not break the signature. /// /// /// To sign an application-specific Object element or a child of that element, create a reference to the XML element to /// be signed. Create the reference by calling the IOpcSignatureReferenceSet::Create method with the referenceUri parameter /// value set to "#" followed by the Id attribute value of the referenced element. For example, if the Id /// attribute of the referenced element is "Application", set referenceUri to "#Application". /// /// The following table shows a byte order mark at the beginning of an xmlMarkup buffer that contains "<Object Id="id1"></Object>": /// /// /// Buffer Byte Index /// 0 /// 1 /// 2 /// 3 /// 4 /// 5 /// 6 /// 7 /// ... /// /// /// UTF8 Value /// EF /// BB /// BF /// '<' /// 'O' /// 'b' /// 'j' /// 'e' /// ... /// /// /// UTF16LE Value /// FF /// FE /// '<' /// 00 /// 'O' /// 00 /// 'b' /// 00 /// ... /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobject-getxml HRESULT GetXml( UINT8 // **xmlMarkup, UINT32 *count ); void GetXml(out SafeCoTaskMemHandle xmlMarkup, out uint count); } /// A read-only enumerator of IOpcSignatureCustomObject interface pointers. /// /// /// When an enumerator is created, the current position precedes the first pointer of the enumerator. To set the current position to /// the first pointer, call the MoveNextmethod after creating the enumerator. /// /// Changes to the set will invalidate the enumerator, and all subsequent calls to it will fail. /// /// To get an IOpcSignatureCustomObjectEnumerator interface pointer, call the IOpcDigitalSignature::GetCustomObjectEnumerator /// or IOpcSignatureCustomObjectSet::GetEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturecustomobjectenumerator [PInvokeData("msopc.h")] [ComImport, Guid("5ee4fe1d-e1b0-4683-8079-7ea0fcf80b4c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureCustomObjectEnumerator { /// Moves the current position of the enumerator to the next IOpcSignatureCustomObject interface pointer. /// /// A Boolean value that indicates the status of the IOpcSignatureCustomObject interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectenumerator-movenext HRESULT // MoveNext( BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcSignatureCustomObjectinterface pointer. /// /// A Boolean value that indicates the status of the IOpcSignatureCustomObjectinterface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcSignatureCustomObject interface at the current position of the enumerator. /// An IOpcSignatureCustomObject interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer of the enumerator. To set the current /// position to the first pointer, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectenumerator-getcurrent HRESULT // GetCurrent( IOpcSignatureCustomObject **customObject ); [PreserveSig] HRESULT GetCurrent(out IOpcSignatureCustomObject customObject); /// Creates a copy of the current IOpcSignatureCustomObjectEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcSignatureCustomObjectEnumeratorinterface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectenumerator-clone HRESULT Clone( // IOpcSignatureCustomObjectEnumerator **copy ); IOpcSignatureCustomObjectEnumerator Clone(); } /// /// An unordered set of IOpcSignatureCustomObject interface pointers that contain the XML markup of application-specific /// Object elements. /// /// /// /// An IOpcSignatureCustomObject interface pointer provides access to the XML markup of the Object element it represents. To /// access the XML markup of the Object element, call the IOpcSignatureCustomObject::GetXml method. /// /// /// When an IOpcSignatureCustomObject interface pointer is created and added to the set, the Object it represents is saved /// when the package is saved. /// /// /// When an IOpcSignatureCustomObject interface pointer is deleted from the set, the Object it represents is not saved when /// the package is saved. /// /// To create an IOpcSignatureCustomObjectSet interface pointer, call the IOpcSigningOptions::GetCustomObjectSet method. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturecustomobjectset [PInvokeData("msopc.h")] [ComImport, Guid("8f792ac5-7947-4e11-bc3d-2659ff046ae1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureCustomObjectSet { /// /// Creates an IOpcSignatureCustomObject interface pointer to represent an application-specific Object element in the /// signature, and adds the new interface to the set. /// /// /// A buffer that contains the XML markup for the Object element to be represented. /// This XML markup must include the opening Object and closing /Object tags. /// /// The encoding of the markup contained in xmlMarkup will be inferred. Inclusion of a byte order mark at the beginning of the /// buffer passed in xmlMarkup is optional. /// /// The following encodings and /// byte order mark /// values are supported: /// /// /// Encoding /// Description /// Byte order mark /// /// /// UTF8 /// UTF-8 /// EF BB BF /// /// /// UTF16LE /// UTF-16, little endian /// FF FE /// /// /// UTF16BE /// UTF-16, big endian /// FE FF /// /// /// /// The size of the xmlMarkup buffer. /// /// A new IOpcSignatureCustomObject interface pointer that represents the application-specific Object element. /// This parameter can be NULL if a pointer to the new interface is not needed. /// /// /// /// An IOpcSignatureCustomObject interface pointer provides access to the XML markup of the Object element it represents. /// To access the XML markup of the Object element, call the IOpcSignatureCustomObject::GetXml method. /// /// /// When an IOpcSignatureCustomObject interface pointer is created and added to the set, the Object it represents is /// saved when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectset-create HRESULT Create( const // UINT8 *xmlMarkup, UINT32 count, IOpcSignatureCustomObject **customObject ); IOpcSignatureCustomObject Create([In] byte[] xmlMarkup, uint count); /// Deletes a specified IOpcSignatureCustomObject interface pointer from the set. /// An IOpcSignatureCustomObject interface pointer to be deleted. /// /// /// When an IOpcSignatureCustomObject interface pointer is deleted from the set, the Object it represents is not saved /// when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectset-delete HRESULT Delete( // IOpcSignatureCustomObject *customObject ); void Delete(IOpcSignatureCustomObject customObject); /// Gets an enumerator of IOpcSignatureCustomObject interface pointers in the set. /// A pointer to an enumerator of IOpcSignatureCustomObject interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturecustomobjectset-getenumerator HRESULT // GetEnumerator( IOpcSignatureCustomObjectEnumerator **customObjectEnumerator ); IOpcSignatureCustomObjectEnumerator GetEnumerator(); } /// Represents a reference to a part that has been or will be signed. /// /// /// Only parts that can be represented by the IOpcPart interface can be referenced by an IOpcSignaturePartReference interface /// pointer. Relationships parts are referenced for signing by a pointer to the IOpcSignatureRelationshipReference interface. To /// create an IOpcSignatureRelationshipReference interface pointer, call the IOpcSignatureRelationshipReferenceSet::Create method. /// /// To create an IOpcSignaturePartReference interface pointer, call the IOpcSignaturePartReferenceSet::Create method. /// /// To access an IOpcSignaturePartReference interface pointer, call the IOpcSignaturePartReferenceEnumerator::GetCurrent method. /// /// /// The interface provides methods to access information about the referenced part and the reference itself. When a signature is /// generated, this reference information is serialized in the XML markup of the signature (signature markup). In signature markup, /// the information is represented by a Reference element that has its URI attribute value set to the part name of the /// referenced part. /// /// /// The following markup shows that these Reference elements are children of the Manifest element in signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturepartreference [PInvokeData("msopc.h")] [ComImport, Guid("e24231ca-59f4-484e-b64b-36eeda36072c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignaturePartReference { /// Gets the part name of the referenced part. /// A pointer to an IOpcPartUri interface that represents the part name. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreference-getpartname HRESULT GetPartName( // IOpcPartUri **partName ); IOpcPartUri GetPartName(); /// Gets the content type of the referenced part. /// The content type of the referenced part. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreference-getcontenttype HRESULT // GetContentType( LPWSTR *contentType ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetContentType(); /// Gets the digest method to use on part content of the referenced part when the part is signed. /// The digest method to use on part content of the referenced part when the part is signed. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreference-getdigestmethod HRESULT // GetDigestMethod( LPWSTR *digestMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetDigestMethod(); /// Gets the digest value that is calculated for part content of the referenced part when the part is signed. /// /// A pointer to a buffer that contains the digest value that is calculated using the specified digest method; the method is /// applied to part content of the referenced part when the part is signed. /// /// /// The size of the digestValue buffer. /// If the referenced part has not been signed yet, count is 0. /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreference-getdigestvalue HRESULT // GetDigestValue( UINT8 **digestValue, UINT32 *count ); void GetDigestValue(out SafeCoTaskMemHandle digestValue, out uint count); /// Gets the canonicalization method to use on part content of a referenced part when the part is signed. /// The canonicalization method to use on part content of a referenced part when the part is signed. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreference-gettransformmethod HRESULT // GetTransformMethod( OPC_CANONICALIZATION_METHOD *transformMethod ); OPC_CANONICALIZATION_METHOD GetTransformMethod(); } /// A read-only enumerator of IOpcSignaturePartReference interface pointers. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Changes to the set will invalidate the enumerator, and all subsequent calls to it will fail. /// /// To get an IOpcSignaturePartReferenceEnumerator interface pointer, call the IOpcSignaturePartReferenceSet::GetEnumerator /// or IOpcDigitalSignature::GetSignaturePartReferenceEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturepartreferenceenumerator [PInvokeData("msopc.h")] [ComImport, Guid("80eb1561-8c77-49cf-8266-459b356ee99a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignaturePartReferenceEnumerator { /// Moves the current position of the enumerator to the next IOpcSignaturePartReference interface pointer. /// /// A Boolean value that indicates the status of the IOpcSignaturePartReference interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceenumerator-movenext HRESULT // MoveNext( BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcSignaturePartReference interface pointer. /// /// A Boolean value that indicates the status of the IOpcSignaturePartReference interface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcSignaturePartReference interface pointer at the current position of the enumerator. /// An IOpcSignaturePartReference interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceenumerator-getcurrent HRESULT // GetCurrent( IOpcSignaturePartReference **partReference ); [PreserveSig] HRESULT GetCurrent(out IOpcSignaturePartReference partReference); /// Creates a copy of the current IOpcSignaturePartReferenceEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcSignaturePartReferenceEnumerator interface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceenumerator-clone HRESULT Clone( // IOpcSignaturePartReferenceEnumerator **copy ); IOpcSignaturePartReferenceEnumerator Clone(); } /// An unordered set of IOpcSignaturePartReference interface pointers that represent references to parts to be signed. /// /// /// Only parts that can be represented by the IOpcPart interface can be referenced by an IOpcSignaturePartReference interface /// pointer. Relationships parts are referenced for signing by a pointer to the IOpcSignatureRelationshipReference interface. To /// create an IOpcSignatureRelationshipReference interface pointer, call the IOpcSignatureRelationshipReferenceSet::Create method. /// /// /// When an IOpcSignaturePartReference interface pointer is created and added to the set, the reference it represents is saved when /// the package is saved. /// /// /// When an IOpcSignaturePartReference interface pointer is deleted from the set, the reference it represents is not saved when the /// package is saved. /// /// /// To create an IOpcSignaturePartReferenceSet interface pointer, call the IOpcSigningOptions::GetSignaturePartReferenceSet method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturepartreferenceset [PInvokeData("msopc.h")] [ComImport, Guid("6c9fe28c-ecd9-4b22-9d36-7fdde670fec0"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignaturePartReferenceSet { /// /// Creates an IOpcSignaturePartReference interface pointer that represents a reference to a part to be signed, and adds the new /// interface to the set. /// /// An IOpcPartUri that represents the part name of the part to be referenced. /// /// The digest method to be used for part content of the part to be referenced. To use the default digest method, pass /// NULL to this parameter. /// /// The canonicalization method used for part content of the part to be referenced. /// /// A new IOpcSignaturePartReference interface pointer that represents the reference to the part to be signed. /// This parameter can be NULL if a pointer to the new interface is not needed. /// /// /// /// Only parts that can be represented by the IOpcPart interface can be referenced by an IOpcSignaturePartReference interface /// pointer. Relationships parts are referenced for signing by a pointer to the IOpcSignatureRelationshipReference interface. To /// create an IOpcSignatureRelationshipReference interface pointer, call the /// IOpcSignatureRelationshipReferenceSet::Create method. /// /// /// When an IOpcSignaturePartReference interface pointer is created and added to the set, the reference it represents is saved /// when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceset-create HRESULT Create( // IOpcPartUri *partUri, LPCWSTR digestMethod, OPC_CANONICALIZATION_METHOD transformMethod, IOpcSignaturePartReference // **partReference ); IOpcSignaturePartReference Create(IOpcPartUri partUri, [Optional, MarshalAs(UnmanagedType.LPWStr)] string digestMethod, OPC_CANONICALIZATION_METHOD transformMethod); /// Deletes a specified IOpcSignaturePartReference interface pointer from the set. /// An IOpcSignaturePartReference interface pointer to be deleted. /// /// /// When an IOpcSignaturePartReference interface pointer is deleted from the set, the reference it represents is not saved when /// the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceset-delete HRESULT Delete( // IOpcSignaturePartReference *partReference ); void Delete(IOpcSignaturePartReference partReference); /// Gets an enumerator of IOpcSignaturePartReference interface pointers in the set. /// A pointer to an enumerator of IOpcSignaturePartReference interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturepartreferenceset-getenumerator HRESULT // GetEnumerator( IOpcSignaturePartReferenceEnumerator **partReferenceEnumerator ); IOpcSignaturePartReferenceEnumerator GetEnumerator(); } /// /// Represents a reference to XML markup that has been or will be signed. This referenced XML markup is serialized in the signature /// markup when a signature is generated. /// /// /// /// To create an IOpcSignatureReference interface pointer, call the IOpcSignatureReferenceSet::Create method. /// IOpcSignatureReferenceSet::Create does not create the reference to the package-specific Object element; that /// reference is created automatically when the signature is generated. /// /// /// To access an IOpcSignatureReference interface pointer, call the IOpcSignatureReferenceEnumerator::GetCurrent method. /// IOpcSignatureReferenceEnumerator::GetCurrent does not access the reference to the package-specific Object element; /// call the IOpcDigitalSignature::GetPackageObjectReference method to access that reference. /// /// /// The interface provides methods to access information about the reference itself, and referenced XML element. The referenced /// element can be the package-specific Object element, an application-specific Object element, or a child element of /// an application-specific Object. /// /// /// When a signature is generated, this reference information is serialized in the XML markup of the signature (signature markup). /// In signature markup, the information is represented by a Reference element that has its URI attribute value set to /// "#" followed by the Id attribute value of the referenced element. For example, if the Id attribute of the /// referenced element is "Application" the URI attribute of the Reference element is set to "#Application" as shown /// in the following markup. /// /// The following signature markup shows a serialized reference to a signed, application-specific Object element. /// /// The following signature markup shows a serialized reference to a signed, child element of an application-specific Object element. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturereference [PInvokeData("msopc.h")] [ComImport, Guid("1b47005e-3011-4edc-be6f-0f65e5ab0342"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureReference { /// Gets the identifier for the reference. /// /// An identifier for the reference. /// If the identifier is not set, referenceId will be the empty string, "". /// /// /// /// Providing an identifier for a reference is optional. If used, the identifier is serialized as the optional Id /// attribute of a Reference element in the signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-getid HRESULT GetId( LPWSTR // *referenceId ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetId(); /// Gets the URI of the referenced XML element. /// /// A pointer to the URI of the referenced element. /// This URI represented by a string is "#" followed by the Id attribute value of the referenced element: "#<elementIdValue>". /// For examples, see the Remarks section. /// /// /// /// The URI of the referenced element is serialized in the signature markup as the URI attribute of a Reference element. /// /// The following table shows two examples of the referenceUri parameter value represented as strings. /// /// /// referenceUri Value as String /// Referenced Element /// Element Description /// /// /// "#idMyCustomObject" /// "<Object Id="idMyCustomObject">...</Object>" /// An application-specific Object element. /// /// /// "#idMyElement" /// "<Object><MyElement Id="idMyElement">...</MyElement>...</Object>" /// A child element of an application-specific Object. /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-geturi HRESULT GetUri( IUri // **referenceUri ); IUri GetUri(); /// Gets a string that indicates the type of the referenced XML element. /// /// A string that indicates the type of the referenced XML element. /// If the type is not set, the type parameter will be the empty string "". /// /// /// /// Providing a type for the referenced XML element is optional. If used, the type of the referenced element is serialized in /// the signature markup as the optional Type attribute value of a Reference element. /// /// /// The caller can use the type of the referenced element to indicate whether the element is an Object, /// SignatureProperty, or Manifest element. This identification can aid the caller in processing the reference. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-gettype HRESULT GetType( LPWSTR // *type ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetType(); /// Gets the canonicalization method to use on the referenced XML element, when the element is signed. /// The canonicalization method to use on the referenced XML element, when the element is signed. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-gettransformmethod HRESULT // GetTransformMethod( OPC_CANONICALIZATION_METHOD *transformMethod ); OPC_CANONICALIZATION_METHOD GetTransformMethod(); /// Gets the digest method to use on the referenced XML element, when the element is signed. /// The digest method to use on the referenced XML element. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-getdigestmethod HRESULT // GetDigestMethod( LPWSTR *digestMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetDigestMethod(); /// Gets the digest value that is calculated for the referenced XML element when the element is signed. /// /// A pointer to a buffer that contains the digest value calculated using the specified digest method when the referenced XML /// element is signed. /// /// If the referenced XML element has not been signed yet, count is 0. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereference-getdigestvalue HRESULT // GetDigestValue( UINT8 **digestValue, UINT32 *count ); void GetDigestValue(out SafeCoTaskMemHandle digestValue, out uint count); } /// A read-only enumerator of IOpcSignatureReference interface pointers. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Changes to the set will invalidate the enumerator, and all subsequent calls to it will fail. /// /// To get an IOpcSignatureReferenceEnumerator interface pointer, call the IOpcSignatureReferenceSet::GetEnumerator or /// IOpcDigitalSignature::GetCustomReferenceEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturereferenceenumerator [PInvokeData("msopc.h")] [ComImport, Guid("cfa59a45-28b1-4868-969e-fa8097fdc12a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureReferenceEnumerator { /// Moves the current position of the enumerator to the next IOpcSignatureReference interface pointer. /// /// A Boolean value that indicates the status of the IOpcSignatureReference interface pointer at the current position. /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceenumerator-movenext HRESULT MoveNext( // BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcSignatureReferenceinterface pointer. /// /// A Boolean value that indicates the status of the IOpcSignatureReference interface pointer at the current position. /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceenumerator-moveprevious HRESULT // MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcSignatureReference interface pointer at the current position of the enumerator. /// An IOpcSignatureReference interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceenumerator-getcurrent HRESULT // GetCurrent( IOpcSignatureReference **reference ); [PreserveSig] HRESULT GetCurrent(out IOpcSignatureReference reference); /// Creates a copy of the current IOpcSignatureReferenceEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcSignatureReferenceEnumerator interface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceenumerator-clone HRESULT Clone( // IOpcSignatureReferenceEnumerator **copy ); IOpcSignatureReferenceEnumerator Clone(); } /// /// An unordered set of IOpcSignatureReference interface pointers that represent references to XML elements to be signed. An XML /// element to be signed can be either an application-specific Object element or a child element. /// /// /// /// The Create method creates a reference to an application-specific Object element or a child of an application-specific /// Object that is signed when the signature is generated. Create does not create the reference to the /// package-specific Object element to be signed; that reference is created automatically when the signature is generated. /// /// /// When an IOpcSignatureReference interface pointer is created and added to the set, the reference it represents is saved when the /// package is saved. /// /// /// When an IOpcSignatureReference interface pointer is deleted from the set, the reference it represents is not saved when the /// package is saved. /// /// To access an IOpcSignatureReferenceSet interface pointer, call the IOpcSigningOptions::GetCustomReferenceSet method. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturereferenceset [PInvokeData("msopc.h")] [ComImport, Guid("f3b02d31-ab12-42dd-9e2f-2b16761c3c1e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureReferenceSet { /// Creates an IOpcSignatureReference interface pointer that represents a reference to an XML element to be signed. /// /// The URI of the referenced XML element. /// /// Set the value of this parameter to a URI that represents "#" followed by the Id attribute value of the referenced /// element: "#<elementIdValue>". /// /// For examples, see the Remarks section. /// /// /// The Id attribute of the Reference element that represents the reference in signature markup. To omit the /// Id attribute, set this parameter value to NULL. /// /// /// The Type attribute of the Reference element that represents the reference in signature markup. To omit the /// Type attribute, set this parameter value to NULL. /// /// /// /// The digest method to be used for the XML markup to be referenced. To use the default digest method, set this parameter value /// to NULL. /// /// /// Important The default digest method must be set by calling the IOpcSigningOptions::SetDefaultDigestMethod method /// before IOpcDigitalSignatureManager::Sign is called. /// /// /// The canonicalization method to be used for the XML markup to be referenced. /// A new IOpcSignatureReference interface pointer that represents the reference to the XML element to be signed. /// /// /// This method creates a reference to an XML element that is signed when the signature is generated. The referenced element can /// be either an application-specific Object element or a child of an application-specific Object. /// /// /// To reference an XML element for signing, set the referenceUri parameter value to a URI that represents "#" followed by the /// Id attribute value of the referenced element, as shown in the following table. /// /// /// /// referenceUri Value as String /// Referenced Element /// Element Description /// /// /// "#idMyCustomObject" /// "<Object Id="idMyCustomObject">...</Object>" /// An application-specific Object element. /// /// /// "#idMyElement" /// "<Object><MyElement Id="idMyElement">...</MyElement>...</Object>" /// A child element of an application-specific Object. /// /// /// /// This method does not create the reference to the package-specific Object element to be signed; that reference is /// created automatically when the signature is generated. /// /// /// When an IOpcSignatureReference interface pointer is created and added to the set, the reference it represents is saved when /// the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceset-create HRESULT Create( IUri // *referenceUri, LPCWSTR referenceId, LPCWSTR type, LPCWSTR digestMethod, OPC_CANONICALIZATION_METHOD transformMethod, // IOpcSignatureReference **reference ); IOpcSignatureReference Create(IUri referenceUri, [MarshalAs(UnmanagedType.LPWStr)] string referenceId, [MarshalAs(UnmanagedType.LPWStr)] string type, [Optional, MarshalAs(UnmanagedType.LPWStr)] string digestMethod, OPC_CANONICALIZATION_METHOD transformMethod); /// Deletes a specified IOpcSignatureReference interface pointer from the set. /// An IOpcSignatureReference interface pointer to be deleted. /// /// /// When an IOpcSignatureReference interface pointer is deleted from the set, the reference it represents is not saved when the /// package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceset-delete HRESULT Delete( // IOpcSignatureReference *reference ); void Delete(IOpcSignatureReference reference); /// Gets an enumerator of IOpcSignatureReference interface pointers in the set. /// A pointer to an enumerator of IOpcSignatureReference interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturereferenceset-getenumerator HRESULT // GetEnumerator( IOpcSignatureReferenceEnumerator **referenceEnumerator ); IOpcSignatureReferenceEnumerator GetEnumerator(); } /// Represents a reference to a Relationships part that contains relationships that have been or will be signed. /// /// /// To create an IOpcSignatureRelationshipReference interface pointer that represents a reference to a Relationships part, /// call the Create method. This reference will indicate whether all or a subset of the relationships in the Relationships part will /// be signed when the signature is generated. /// /// /// To access an IOpcSignatureRelationshipReference interface pointer, call the /// IOpcSignatureRelationshipReferenceEnumerator::GetCurrent method. /// /// /// Relationships that are not selected for signing can be removed, modified or added to the package without invalidating the /// signature. If a subset of relationships has been selected for signing and the subset is altered, the signature will be invalidated. /// /// /// The interface provides methods to access information about the referenced Relationships part, the selected relationships that /// have been or will be signed, and the reference itself. When a signature is generated, this reference information is serialized /// in the XML markup of the signature (signature markup). In signature markup, the information is represented by a Reference /// element that has a URI attribute value that identifies a Relationships part. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturerelationshipreference [PInvokeData("msopc.h")] [ComImport, Guid("57babac6-9d4a-4e50-8b86-e5d4051eae7c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureRelationshipReference { /// Gets the source URI of the relationships that are stored in the referenced Relationships part. /// A pointer to the source URI of the relationships that are stored in the referenced Relationships part. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-getsourceuri HRESULT // GetSourceUri( IOpcUri **sourceUri ); IOpcUri GetSourceUri(); /// Gets the digest method to use on relationship markup of the selected relationships. /// The digest method to use on relationship markup of the selected relationships when they are signed. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-getdigestmethod HRESULT // GetDigestMethod( LPWSTR *digestMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetDigestMethod(); /// Gets the digest value calculated for the selected relationships when they are signed. /// /// A pointer to a buffer that contains the digest value calculated using the specified digest method; the method is applied to /// the relationship markup of the selected relationships when they are signed. /// /// /// The size of the digestValue buffer. /// If the selected relationships have not been signed yet, count is 0. /// /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-getdigestvalue HRESULT // GetDigestValue( UINT8 **digestValue, UINT32 *count ); void GetDigestValue(out SafeCoTaskMemHandle digestValue, out uint count); /// /// Gets the canonicalization method to use on the relationship markup of the selected relationships when they are signed. /// /// The canonicalization method to use on the relationship markup of the selected relationships when they are signed. /// /// All or a subset of the relationships in a referenced Relationships part can be signed. /// /// If a subset of is selected and the signature is generated by calling the IOpcDigitalSignatureManager::Sign method, the /// transform methods that are applied to relationship markup are the relationships transform followed by the /// OPC_CANONICALIZATION_C14N canonicalization method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-gettransformmethod // HRESULT GetTransformMethod( OPC_CANONICALIZATION_METHOD *transformMethod ); OPC_CANONICALIZATION_METHOD GetTransformMethod(); /// /// Gets a value that describes whether all or a subset of relationships that are stored in the referenced Relationships part /// are selected. /// /// A value that describes whether all or a subset of relationships are selected. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-getrelationshipsigningoption // HRESULT GetRelationshipSigningOption( OPC_RELATIONSHIPS_SIGNING_OPTION *relationshipSigningOption ); OPC_RELATIONSHIPS_SIGNING_OPTION GetRelationshipSigningOption(); /// /// Gets an enumerator of IOpcRelationshipSelector interface pointers that represent the techniques used to select the subset of /// relationships in the referenced Relationships part. /// /// A pointer to an enumerator of IOpcRelationshipSelector interface pointers. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreference-getrelationshipselectorenumerator // HRESULT GetRelationshipSelectorEnumerator( IOpcRelationshipSelectorEnumerator **selectorEnumerator ); IOpcRelationshipSelectorEnumerator GetRelationshipSelectorEnumerator(); } /// A read-only enumerator of IOpcSignatureRelationshipReference interface pointers. /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first pointer /// of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Changes to the set will invalidate the enumerator and all subsequent calls to it will fail. /// /// To get an IOpcSignatureRelationshipReferenceEnumerator interface pointer, call the /// IOpcSignatureRelationshipReferenceSet::GetEnumerator or IOpcDigitalSignature::GetSignatureRelationshipReferenceEnumerator method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturerelationshipreferenceenumerator [PInvokeData("msopc.h")] [ComImport, Guid("773ba3e4-f021-48e4-aa04-9816db5d3495"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureRelationshipReferenceEnumerator { /// Moves the current position of the enumerator to the next IOpcSignatureRelationshipReference interface pointer. /// /// /// A Boolean value that indicates the status of the IOpcSignatureRelationshipReference interface pointer at the current position. /// /// The value of hasNext is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// The current position of the enumerator has been advanced to the next pointer and that pointer is valid. /// /// /// FALSE /// The current position of the enumerator has been advanced past the end of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasNext parameter is NULL. /// /// /// OPC_E_ENUM_CANNOT_MOVE_NEXT 0x80510051 /// The current position is already past the last item of the enumerator. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceenumerator-movenext // HRESULT MoveNext( BOOL *hasNext ); [PreserveSig] HRESULT MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasNext); /// Moves the current position of the enumerator to the previous IOpcSignatureRelationshipReference interface pointer. /// /// /// A Boolean value that indicates the status of the IOpcSignatureRelationshipReference interface pointer at the current position. /// /// The value of hasPrevious is only valid when the method succeeds. /// /// /// Value /// Meaning /// /// /// TRUE /// /// The current position of the enumerator has been moved to the previous pointer in the collection, and that pointer is valid. /// /// /// /// FALSE /// The current position of the enumerator has been moved past the beginning of the collection and is no longer valid. /// /// /// /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The hasPrevious parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_CANNOT_MOVE_PREVIOUS 0x80510052 /// The current position already precedes the first item of the enumerator. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceenumerator-moveprevious // HRESULT MovePrevious( BOOL *hasPrevious ); [PreserveSig] HRESULT MovePrevious([MarshalAs(UnmanagedType.Bool)] out bool hasPrevious); /// Gets the IOpcSignatureRelationshipReference interface pointer at the current position of the enumerator. /// An IOpcSignatureRelationshipReference interface pointer. /// /// The method returns an HRESULT. Possible values include, but are not limited to, those in the following table. /// /// /// Return code/value /// Description /// /// /// S_OK /// The method succeeded. /// /// /// E_POINTER /// The partReference parameter is NULL. /// /// /// OPC_E_ENUM_COLLECTION_CHANGED 0x80510050 /// The enumerator is invalid because the underlying set has changed. /// /// /// OPC_E_ENUM_INVALID_POSITION 0x80510053 /// The enumerator cannot perform this operation from its current position. /// /// /// /// /// /// When an enumerator is created, the current position precedes the first pointer. To set the current position to the first /// pointer of the enumerator, call the MoveNextmethod after creating the enumerator. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceenumerator-getcurrent // HRESULT GetCurrent( IOpcSignatureRelationshipReference **relationshipReference ); [PreserveSig] HRESULT GetCurrent(out IOpcSignatureRelationshipReference relationshipReference); /// Creates a copy of the current IOpcSignatureRelationshipReferenceEnumerator interface pointer and all its descendants. /// A pointer to a copy of the IOpcSignatureRelationshipReferenceEnumerator interface pointer. /// /// The copy has a current position and set that are identical to the current enumerator. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceenumerator-clone HRESULT // Clone( IOpcSignatureRelationshipReferenceEnumerator **copy ); IOpcSignatureRelationshipReferenceEnumerator Clone(); } /// /// An unordered set of IOpcSignatureRelationshipReference interface pointers that represent references to Relationships parts that /// contain relationships to be signed. /// /// /// /// To create an IOpcSignatureRelationshipReference interface pointer that represents a reference to a Relationships part, call the /// Create method. This reference will indicate whether all or a subset of the relationships in the Relationships part will be /// signed when the signature is generated. /// /// /// To access an IOpcSignatureRelationshipReferenceSet interface pointer, call the /// IOpcSigningOptions::GetSignatureRelationshipReferenceSet method. /// /// /// When an IOpcSignatureRelationshipReference interface pointer is created and added to the set, the reference it represents is /// saved when the package is saved. /// /// /// When an IOpcSignatureRelationshipReference interface pointer is deleted from the set, the reference it represents is not saved /// when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsignaturerelationshipreferenceset [PInvokeData("msopc.h")] [ComImport, Guid("9f863ca5-3631-404c-828d-807e0715069b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSignatureRelationshipReferenceSet { /// /// Creates an IOpcSignatureRelationshipReference interface pointer that represents a reference to a Relationships part, and /// adds the new interface pointer to the set. All or a subset of the relationships stored in the Relationships part to be /// referenced are selected for signing. /// /// /// An IOpcUri interface pointer that represents the source URI of the relationships to be selected for signing. /// /// /// /// The digest method to be used for the relationships to be selected. To use the default digest method, pass NULL in /// this parameter. /// /// /// Important The default digest method must be set by calling the IOpcSigningOptions::SetDefaultDigestMethod method /// before IOpcDigitalSignatureManager::Sign is called. /// /// /// /// /// A value that indicates whether the relationships selected for signing include all or a subset of the relationships in the /// Relationships part to be referenced. /// /// For information about the effect of relationshipSigningOption values on other parameters, see Remarks. /// /// /// /// An IOpcRelationshipSelectorSet interface pointer that can be used to identify a subset of relationships in the Relationships /// part to be selected for signing. /// /// If relationshipSigningOption is set to OPC_RELATIONSHIP_SIGN_PART, selectorSet is NULL. /// For information about selectorSet values, see Remarks. /// /// /// A value that describes the canonicalization method to be applied to the relationship markup of the selected relationships. /// /// If relationshipSigningOption is set OPC_RELATIONSHIP_SIGN_USING_SELECTORS, the value of transformMethod is ignored. /// /// /// For more information about the transform methods to be applied when relationshipSigningOption is set to /// OPC_RELATIONSHIP_SIGN_USING_SELECTORS, see Remarks. /// /// /// A new IOpcSignatureRelationshipReference interface pointer that represents the referenced Relationships part. /// /// /// This method creates a reference to a Relationships part. All or a subset of the relationships that are stored in a /// referenced Relationships part can be signed when the signature is generated. /// /// /// To sign all of the relationships in a Relationships part, call this method with the relationshipSigningOption parameter /// value set to OPC_RELATIONSHIP_SIGN_PART and the selectorSet parameter value set to NULL. /// /// /// To sign a subset of the relationships in a Relationships part, call this method with the relationshipSigningOption parameter /// value set to OPC_RELATIONSHIP_SIGN_USING_SELECTORS and the selectorSet parameter value set to an /// IOpcRelationshipSelectorSet interface pointer. To create an IOpcRelationshipSelectorSet interface pointer, call the /// CreateRelationshipSelectorSet method. /// /// /// The following table summarizes the parameter values required by this method to create a reference that indicates whether all /// of the relationships or a subset of the relationships (which are stored in the Relationships part to be referenced) are to /// be signed. /// /// /// /// Description /// relationshipSigningOption Value /// selectorSet Value /// /// /// Sign all of the relationships in the Relationships part /// OPC_RELATIONSHIP_SIGN_PART /// NULL /// /// /// Sign a subset of the relationships in the Relationships part /// OPC_RELATIONSHIP_SIGN_USING_SELECTORS /// An IOpcRelationshipSelectorSet interface pointer /// /// /// /// If a subset of relationships are to be signed, the specified transform method is ignored. Instead, when the signature is /// generated, the first transform applied is the Relationships Transform, and the second is the /// OPC_CANONICALIZATION_C14N canonicalization method. /// /// /// When an IOpcSignatureRelationshipReference interface pointer is created and added to the set, the reference it represents is /// saved when the package is saved. /// /// /// Relationships that will not be signed can be removed, modified or added to the package without invalidating the signature. /// If a subset of relationships has been selected for signing and the subset is altered, the signature will be invalidated. /// /// /// Important A selected subset could be altered if the relationship type of a relationship that is added to or modified /// in a referenced Relationships part matches a relationship type that was used to select one or more relationships in the subset. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceset-create HRESULT // Create( IOpcUri *sourceUri, LPCWSTR digestMethod, OPC_RELATIONSHIPS_SIGNING_OPTION relationshipSigningOption, // IOpcRelationshipSelectorSet *selectorSet, OPC_CANONICALIZATION_METHOD transformMethod, IOpcSignatureRelationshipReference // **relationshipReference ); IOpcSignatureRelationshipReference Create(IOpcUri sourceUri, [MarshalAs(UnmanagedType.LPWStr)] string digestMethod, OPC_RELATIONSHIPS_SIGNING_OPTION relationshipSigningOption, IOpcRelationshipSelectorSet selectorSet, OPC_CANONICALIZATION_METHOD transformMethod); /// /// Creates an IOpcRelationshipSelectorSet interface pointer that is used as the selectorSet parameter value of the Create method. /// /// A new IOpcRelationshipSelectorSet interface pointer. /// /// /// To select a subset of the relationships (which are stored in the Relationships part to be referenced) to be signed when the /// signature is generated, call the Create method with the relationshipSigningOption parameter value set to /// OPC_RELATIONSHIP_SIGN_USING_SELECTORS and the selectorSet parameter value set to the IOpcRelationshipSelectorSet /// interface pointer created by this method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceset-createrelationshipselectorset // HRESULT CreateRelationshipSelectorSet( IOpcRelationshipSelectorSet **selectorSet ); IOpcRelationshipSelectorSet CreateRelationshipSelectorSet(); /// Deletes a specified IOpcSignatureRelationshipReference interface pointer from the set. /// An IOpcSignatureRelationshipReference interface pointer to be deleted. /// /// /// When an IOpcSignatureRelationshipReference interface pointer is deleted from the set, the reference it represents is not /// saved when the package is saved. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceset-delete HRESULT // Delete( IOpcSignatureRelationshipReference *relationshipReference ); void Delete(IOpcSignatureRelationshipReference relationshipReference); /// Gets an enumerator of IOpcSignatureRelationshipReference interface pointers in the set. /// A pointer to an enumerator of IOpcSignatureRelationshipReference interface pointers in the set. // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsignaturerelationshipreferenceset-getenumerator HRESULT // GetEnumerator( IOpcSignatureRelationshipReferenceEnumerator **relationshipReferenceEnumerator ); IOpcSignatureRelationshipReferenceEnumerator GetEnumerator(); } /// Provides methods to set and access information required to generate a signature. /// /// /// To generate a signature, call the IOpcDigitalSignatureManager::Sign method with the signingOptions parameter value set to an /// IOpcSigningOptions interface pointer. /// /// To create an IOpcSigningOptions interface pointer, call the IOpcDigitalSignatureManager::CreateSigningOptions method. /// /// The caller must set a default for the digest method and signature method before generating a signature. To set a default digest /// method, call the SetDefaultDigestMethod method. To set a signature method, call the SetSignatureMethod method. /// /// /// To get an IOpcSignatureCustomObjectSet interface pointer, call the GetCustomObjectSet method. The interface pointers in the set /// represent application-specific Object elements. /// /// /// To get an IOpcSignatureReferenceSet interface pointer, call the GetCustomReferenceSet method. The interface pointers in the set /// represent references to application-specific Object elements or their children that will be signed when the signature is generated. /// /// /// The default location of the certificate is OPC_CERTIFICATE_IN_CERTIFICATE_PART. To change this value, call the /// SetCertificateEmbeddingOption method. /// /// /// The default format of the signing time string is OPC_SIGNATURE_TIME_FORMAT_MILLISECONDS. To change the format of the /// signing time string, call the SetTimeFormat method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcsigningoptions [PInvokeData("msopc.h")] [ComImport, Guid("50d2d6a5-7aeb-46c0-b241-43ab0e9b407e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcSigningOptions { /// Gets the value of the Id attribute from the Signature element. /// A pointer to the value of the Id attribute, or the empty string "" if there is no Id. /// /// The Id attribute of the Signature element is optional. /// To set the signature Id, call the IOpcSigningOptions::SetSignatureId method. /// /// To access the Id before the signature is generated, call the IOpcSigningOptions::GetSignatureId. To access the /// signature Id after the signature is generated, call the IOpcDigitalSignature::GetSignatureId method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getsignatureid HRESULT GetSignatureId( // LPWSTR *signatureId ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSignatureId(); /// Sets the value of the Id attribute of the Signature element. /// The value of the Id attribute. /// /// /// The Id attribute of the Signature element is optional. If this method is not called, the Signature /// element will not have the Id attribute. /// /// /// To access the Id before the signature is generated, call the IOpcSigningOptions::GetSignatureId. To access the signature Id /// after the signature is generated, call the IOpcDigitalSignature::GetSignatureId method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-setsignatureid HRESULT SetSignatureId( // LPCWSTR signatureId ); void SetSignatureId([MarshalAs(UnmanagedType.LPWStr)] string signatureId); /// /// Gets the signature method to use to calculate and encrypt the hash value of the SignedInfo element, which will be /// serialized as the SignatureValue element of the signature. /// /// /// A pointer to the signature method to use, or the empty string "" if no method has been set using the SetSignatureMethod method. /// /// /// To set the signature method, call the IOpcSigningOptions::SetSignatureMethod method. /// /// To access the signature method before the signature is generated, call the IOpcSigningOptions::GetSignatureMethod. To /// access the signature method after the signature is generated, call the IOpcDigitalSignature::GetSignatureMethod method. /// /// /// Important A valid signature method must be set before the signature is generated by calling the /// IOpcDigitalSignatureManager::Sign method. /// /// /// When a signature is generated it is serialized as signature markup. The signature method is used to calculate the value in /// the SignatureValue element in the signature markup. /// /// /// When a signature is validated, the signature method is used to recalculate that value, and the recalculated value is /// compared to the value in the SignatureValue element in the signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getsignaturemethod HRESULT // GetSignatureMethod( LPWSTR *signatureMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetSignatureMethod(); /// /// Sets the signature method to use to calculate and encrypt the hash value of the SignedInfo element, which will be /// contained in the SignatureValue element of the signature. /// /// The signature method to use. /// /// /// To access the signature method before the signature is generated, call the IOpcSigningOptions::GetSignatureMethod. To access /// the signature method after the signature is generated, call the IOpcDigitalSignature::GetSignatureMethod method. /// /// /// Important A valid signature method must be set before the signature is generated by calling the /// IOpcDigitalSignatureManager::Sign method. /// /// /// When a signature is generated it is serialized as signature markup. The signature method is used to calculate the value in /// the SignatureValue element in the signature markup. /// /// /// When a signature is validated, the signature method is used to recalculate that value, and the recalculated value is /// compared to the value in the SignatureValue element in the signature markup. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-setsignaturemethod HRESULT // SetSignatureMethod( LPCWSTR signatureMethod ); void SetSignatureMethod([MarshalAs(UnmanagedType.LPWStr)] string signatureMethod); /// Gets the default digest method that will be used to compute digest values for objects to be signed. /// /// A pointer to the default digest method, or the empty string "" if a default has not been set using the /// SetDefaultDigestMethod method. /// /// /// To set the default digest method, call the IOpcSigningOptions::SetDefaultDigestMethod method. /// /// Important The default digest method must be set before the signature is generated by calling the /// IOpcDigitalSignatureManager::Sign method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getdefaultdigestmethod HRESULT // GetDefaultDigestMethod( LPWSTR *digestMethod ); [return: MarshalAs(UnmanagedType.LPWStr)] string GetDefaultDigestMethod(); /// Sets the default digest method that will be used to compute digest values for objects to be signed. /// The default digest method. /// /// To access the default digest method before the signature is generated, call the IOpcSigningOptions::GetDefaultDigestMethod. /// /// Important The default digest method for entities to be signed must be set before the signature is generated by /// calling the IOpcDigitalSignatureManager::Sign method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-setdefaultdigestmethod HRESULT // SetDefaultDigestMethod( LPCWSTR digestMethod ); void SetDefaultDigestMethod([MarshalAs(UnmanagedType.LPWStr)] string digestMethod); /// Gets a value that specifies the storage location in the package of the certificate to be used for the signature. /// A value that specifies the location of the certificate. /// /// /// The default location of the certificate is OPC_CERTIFICATE_IN_CERTIFICATE_PART. To change this value, call the /// IOpcSigningOptions::SetCertificateEmbeddingOption method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getcertificateembeddingoption HRESULT // GetCertificateEmbeddingOption( OPC_CERTIFICATE_EMBEDDING_OPTION *embeddingOption ); OPC_CERTIFICATE_EMBEDDING_OPTION GetCertificateEmbeddingOption(); /// Set the storage location of the certificate to be used for the signature. /// The OPC_CERTIFICATE_EMBEDDING_OPTION value that describes the location of the certificate. /// /// /// This method changes the location of the certificate from the default location, OPC_CERTIFICATE_IN_CERTIFICATE_PART, /// to a location that is specified by the caller. /// /// /// To access the value that describes the certificate location, call the IOpcSigningOptions::GetCertificateEmbeddingOption method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-setcertificateembeddingoption HRESULT // SetCertificateEmbeddingOption( OPC_CERTIFICATE_EMBEDDING_OPTION embeddingOption ); void SetCertificateEmbeddingOption(OPC_CERTIFICATE_EMBEDDING_OPTION embeddingOption); /// Gets the format of the string retrieved by the IOpcDigitalSignature::GetSigningTime method. /// The value that describes the format of the signingTime parameter of GetSigningTime. /// /// /// The default format of the signing time string is OPC_SIGNATURE_TIME_FORMAT_MILLISECONDS. To change the format of the /// signing time string, call the IOpcSigningOptions::SetTimeFormat method. /// /// /// To access the format of the signing time string after the signature has been generated, call the /// IOpcDigitalSignature::GetTimeFormat method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-gettimeformat HRESULT GetTimeFormat( // OPC_SIGNATURE_TIME_FORMAT *timeFormat ); OPC_SIGNATURE_TIME_FORMAT GetTimeFormat(); /// Sets the format of the string retrieved by the IOpcDigitalSignature::GetSigningTime method. /// /// The value that describes the format of the string retrieved by the IOpcDigitalSignature::GetSigningTime method. /// /// /// /// This method changes the format of the signing time string from the default format, /// OPC_SIGNATURE_TIME_FORMAT_MILLISECONDS, to a format that is specified by the caller. /// /// /// To access the format of the signing time string before the signature is generated, call the /// IOpcSigningOptions::GetTimeFormat method. To access the format after the signature has been generated, call the /// IOpcDigitalSignature::GetTimeFormat method. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-settimeformat HRESULT SetTimeFormat( // OPC_SIGNATURE_TIME_FORMAT timeFormat ); void SetTimeFormat(OPC_SIGNATURE_TIME_FORMAT timeFormat); /// Gets an IOpcSignaturePartReferenceSet interface. /// An IOpcSignaturePartReferenceSet interface pointers. /// /// /// This method gets an IOpcSignaturePartReferenceSet interface pointer that provides methods enabling the creation and deletion /// of the IOpcSignaturePartReference interface pointers in the set. The IOpcSignaturePartReference interface pointers /// represent references to parts to be signed. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getsignaturepartreferenceset HRESULT // GetSignaturePartReferenceSet( IOpcSignaturePartReferenceSet **partReferenceSet ); IOpcSignaturePartReferenceSet GetSignaturePartReferenceSet(); /// Gets an IOpcSignatureRelationshipReferenceSet interface pointer. /// An IOpcSignatureRelationshipReferenceSet interface pointer. /// /// /// This method gets an IOpcSignatureRelationshipReferenceSet interface pointer that provides methods enabling the creation and /// deletion of the IOpcSignaturePartReference interface pointers in the set. The IOpcSignatureRelationshipReference interface /// pointers represent references to Relationships parts that contain relationships to be signed. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getsignaturerelationshipreferenceset // HRESULT GetSignatureRelationshipReferenceSet( IOpcSignatureRelationshipReferenceSet **relationshipReferenceSet ); IOpcSignatureRelationshipReferenceSet GetSignatureRelationshipReferenceSet(); /// Gets an IOpcSignatureCustomObjectSet interface. /// A pointer to an IOpcSignatureCustomObjectSet. /// /// /// This method gets an IOpcSignatureCustomObjectSet interface pointer that provides methods enabling the creation and deletion /// of the IOpcSignatureCustomObject interface pointers in the set. The IOpcSignatureCustomObject interface pointers /// represent application-specific Object elements which are serialized in the signature markup when the signature is generated. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getcustomobjectset HRESULT // GetCustomObjectSet( IOpcSignatureCustomObjectSet **customObjectSet ); IOpcSignatureCustomObjectSet GetCustomObjectSet(); /// Gets an IOpcSignatureReferenceSet interface pointer. /// A pointer to an IOpcSignatureReferenceSet. /// /// /// This method gets an IOpcSignatureReferenceSet interface pointer that provides methods enabling the creation and deletion of /// the IOpcSignatureReference interface pointers in the set. The IOpcSignatureReference interface pointers represent /// references to XML elements to be signed. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getcustomreferenceset HRESULT // GetCustomReferenceSet( IOpcSignatureReferenceSet **customReferenceSet ); IOpcSignatureReferenceSet GetCustomReferenceSet(); /// Gets an IOpcCertificateSet interface pointer. /// An IOpcCertificateSet interface pointer. /// /// /// This method gets a set that provides methods enabling the addition and removal of certificates from a certificate chain that /// will be associated with the signature when it is generated. /// /// /// Do not include the certificate use to generate the signature in this set. This certificate, the signer certificate, is /// required for signature generation. To generate the signature, call the IOpcDigitalSignatureManager::Sign method with the /// certificate parameter value set to a pointer to the signer certificate. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getcertificateset HRESULT // GetCertificateSet( IOpcCertificateSet **certificateSet ); IOpcCertificateSet GetCertificateSet(); /// Gets the part name of the signature part where the signature markup will be stored. /// /// An IOpcPartUri interface pointer that represents the part name of the part where the signature markup is stored, or /// NULL if the part name has not been set by a call to the SetSignaturePartName method. /// /// /// /// To set the part name of the signature part that stores the signature markup, call the /// IOpcSigningOptions::SetSignaturePartName method. /// /// /// To access the signature part name after the signature is generated, call the IOpcDigitalSignature::GetSignaturePartName method. /// /// The signature part that stores signature markup is specific to the signature. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-getsignaturepartname HRESULT // GetSignaturePartName( IOpcPartUri **signaturePartName ); IOpcPartUri GetSignaturePartName(); /// Sets the part name of the signature part where the signature markup will be stored. /// /// An IOpcPartUri interface pointer that represents the part name of the part where the signature markup is stored, or /// NULL to generate a part name when the signature is created. /// /// /// /// Until the signature is generated, the part name of the signature part that stores the signature markup can be changed. To /// set a new part name, call this method with the signaturePartName parameter value set to an IOpcPartUri interface pointer /// that represents the new name. To clear an existing part name, set the signaturePartName parameter value to NULL. /// /// /// To access the signature part name before the signature is generated, call the IOpcSigningOptions::GetSignaturePartName. To /// access the signature part name after the signature is generated, call the IOpcDigitalSignature::GetSignaturePartName method. /// /// The signature part that stores signature markup is specific to the signature. /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcsigningoptions-setsignaturepartname HRESULT // SetSignaturePartName( IOpcPartUri *signaturePartName ); void SetSignaturePartName(IOpcPartUri signaturePartName); } /// Represents the URI of the package root or of a part that is relative to the package root. /// /// Support on Previous Windows Versions /// /// The behavior and performance of this interface is the same on all supported Windows versions. For more information, see the /// Getting Started with the Packaging API, and Platform Update for Windows Vista. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nn-msopc-iopcuri [PInvokeData("msopc.h", MSDNShortId = "35ce7946-f7e7-4ac3-852f-e3fcca23d6d4")] [ComImport, Guid("BC9C1B9B-D62C-49EB-AEF0-3B4E0B28EBED"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IOpcUri : IUri { /// Returns the specified Uniform Resource Identifier (URI) property value in a new BSTR. /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// /// [out] /// Address of a BSTR that receives the property value. /// /// /// [in] /// One of the following property-specific flags, or zero. /// Uri_DISPLAY_NO_FRAGMENT (0x00000001) /// Uri_PROPERTY_DISPLAY_URI: Exclude the fragment portion of the URI, if any. /// Uri_PUNYCODE_IDN_HOST (0x00000002) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: If the URI is an IDN, always display /// the hostname encoded as punycode. /// /// Uri_DISPLAY_IDN_HOST (0x00000004) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: Display the hostname in punycode or /// Unicode as it would appear in the Uri_PROPERTY_DISPLAY_URI property. /// /// /// /// IUri::GetPropertyBSTR was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a string property. This method will fail if the specified property isn't a BSTR property. /// /// /// The pbstrProperty parameter will be set to a new BSTR containing the value of the specified string property. The /// caller should use SysFreeString to free the string. /// /// This method will return and set pbstrProperty to an empty string if the URI doesn't contain the specified property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775026(v=vs.85) // HRESULT GetPropertyBSTR( [in] Uri_PROPERTY uriProp, [out] BSTR *pbstrProperty, [in] DWORD dwFlags ); new void GetPropertyBSTR([In] Uri_PROPERTY uriProp, [MarshalAs(UnmanagedType.BStr)] out string pbstrProperty, [In] Uri_DISPLAY dwFlags); /// /// Returns the string length of the specified Uniform Resource Identifier (URI) property. Call this function if you want the /// length but don't necessarily want to create a new BSTR. /// /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// /// [out] /// /// Address of a DWORD that is set to the length of the value of the string property excluding the NULL terminator. /// /// /// /// [in] /// One of the following property-specific flags, or zero. /// Uri_DISPLAY_NO_FRAGMENT (0x00000001) /// Uri_PROPERTY_DISPLAY_URI: Exclude the fragment portion of the URI, if any. /// Uri_PUNYCODE_IDN_HOST (0x00000002) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: If the URI is an IDN, always display /// the hostname encoded as punycode. /// /// Uri_DISPLAY_IDN_HOST (0x00000004) /// /// Uri_PROPERTY_ABSOLUTE_URI, Uri_PROPERTY_DOMAIN, Uri_PROPERTY_HOST: Display the hostname in punycode or /// Unicode as it would appear in the Uri_PROPERTY_DISPLAY_URI property. /// /// /// /// IUri::GetPropertyLength was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a string property. This method will fail if the specified property isn't a BSTR property. /// /// This method will return and set pcchProperty to if the URI doesn't contain the specified property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775028(v=vs.85) // HRESULT GetPropertyLength( [in] Uri_PROPERTY uriProp, [out] DWORD *pcchProperty, [in] DWORD dwFlags ); new void GetPropertyLength([In] Uri_PROPERTY uriProp, out uint pcchProperty, [In] Uri_DISPLAY dwFlags); /// Returns the specified numeric Uniform Resource Identifier (URI) property value. /// /// [in] /// A value from the Uri_PROPERTY enumeration. /// /// Address of a DWORD that is set to the value of the specified property. /// Property-specific flags. Must be set to 0. /// /// IUri::GetPropertyDWORD was introduced in Windows Internet Explorer 7. /// /// The uriProp parameter must be a numeric property. This method will fail if the specified property isn't a DWORD property. /// /// This method will return and set pdwProperty to if the specified property doesn't exist in the URI. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775027(v=vs.85) // HRESULT GetPropertyDWORD( [in] Uri_PROPERTY uriProp, [out] DWORD *pdwProperty, [in] DWORD dwFlags ); new void GetPropertyDWORD([In] Uri_PROPERTY uriProp, out uint pdwProperty, [In] uint dwFlags); /// Determines if the specified property exists in the Uniform Resource Identifier (URI). /// Address of a BOOL value. Set to TRUE if the specified property exists in the URI. /// IUri::HasProperty was introduced in Windows Internet Explorer 7. // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775036(v=vs.85) // HRESULT HasProperty( [in] Uri_PROPERTY uriProp, [out] BOOL *pfHasProperty ); [return: MarshalAs(UnmanagedType.Bool)] new bool HasProperty([In] Uri_PROPERTY uriProp); /// Returns the entire canonicalized Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetAbsoluteUri was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_ABSOLUTE_URI property. /// /// This property is not defined for relative URIs. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775013%28v%3dvs.85%29 // HRESULT GetAbsoluteUri( [out] BSTR *pbstrAbsoluteUri ); [return: MarshalAs(UnmanagedType.BStr)] new string GetAbsoluteUri(); /// Returns the user name, password, domain, and port. /// Address of a string that receives the property value. /// /// IUri::GetAuthority was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_AUTHORITY property. /// /// /// If user name and password are not specified, the separator characters (: and @) are removed. The trailing colon is also /// removed if the port number is not specified or is the default for the protocol scheme. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775014(v=vs.85) // HRESULT GetAuthority( [out] BSTR *pbstrAuthority ); [return: MarshalAs(UnmanagedType.BStr)] new string GetAuthority(); /// Returns a Uniform Resource Identifier (URI) that can be used for display purposes. /// Address of a string that receives the property value. /// /// IUri::GetDisplayUri was introduced in Windows Internet Explorer 7. /// /// The display URI combines protocol scheme, fully qualified domain name, port number (if not the default for the scheme), full /// resource path, query string, and fragment. /// /// /// Note The display URI may have additional formatting applied to it, such that the string produced by /// IUri::GetDisplayUri isn't necessarily a valid URI. For this reason, and since the userinfo is not present, the /// display URI should be used for viewing only; it should not be used for edit by the user, or as a form of transfer for URIs /// inside or between applications. /// /// /// If the scheme is known (for example, http, ftp, or file) then the display URI will hide credentials. However, if the URI /// uses an unknown scheme and supplies user name and password, the display URI will also contain the user name and password. /// /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_DISPLAY_URI property and no flags. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775015(v=vs.85) // HRESULT GetDisplayUri( [out] BSTR *pbstrDisplayString ); [return: MarshalAs(UnmanagedType.BStr)] new string GetDisplayUri(); /// Returns the domain name (including top-level domain) only. /// Address of a string that receives the property value. /// /// IUri::GetDomain was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_DOMAIN property. /// /// /// If the URL contains only a plain hostname (for example, "http://example/") or a public suffix (for example, /// "http://co.uk/"), then IUri::GetDomain returns NULL. Use IUri::GetHost instead. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775016(v=vs.85) // HRESULT GetDomain( [out] BSTR *pbstrDomain ); [return: MarshalAs(UnmanagedType.BStr)] new string GetDomain(); /// Returns the file name extension of the resource. /// Address of a string that receives the property value. /// /// IUri::GetExtension was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_EXTENSION property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775017(v=vs.85) // HRESULT GetExtension( [out] BSTR *pbstrExtension ); [return: MarshalAs(UnmanagedType.BStr)] new string GetExtension(); /// Returns the text following a fragment marker (#), including the fragment marker itself. /// Address of a string that receives the property value. /// /// IUri::GetFragment was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_FRAGMENT property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775018(v=vs.85) // HRESULT GetFragment( [out] BSTR *pbstrFragment ); [return: MarshalAs(UnmanagedType.BStr)] new string GetFragment(); /// Returns the fully qualified domain name. /// Address of a string that receives the property value. /// /// IUri::GetHost was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_HOST property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775019(v=vs.85) // HRESULT GetHost( [out] BSTR *pbstrHost ); [return: MarshalAs(UnmanagedType.BStr)] new string GetHost(); /// Returns the password, as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetPassword was introduced in Windows Internet Explorer 7. /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_PASSWORD property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775021(v=vs.85) // HRESULT GetPassword( [out] BSTR *pbstrPassword ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPassword(); /// Returns the path and resource name. /// Address of a string that receives the property value. /// /// IUri::GetPath was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_PATH property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775022(v=vs.85) // HRESULT GetPath( [out] BSTR *pbstrPath ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPath(); /// Returns the path, resource name, and query string. /// Address of a string that receives the property value. /// /// IUri::GetPathAndQuery was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_PATH_AND_QUERY property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775023(v=vs.85) // HRESULT GetPathAndQuery( [out] BSTR *pbstrPathAndQuery ); [return: MarshalAs(UnmanagedType.BStr)] new string GetPathAndQuery(); /// Returns the query string. /// Address of a string that receives the property value. /// /// IUri::GetQuery was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the Uri_PROPERTY_QUERY property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775029(v=vs.85) // HRESULT GetQuery( [out] BSTR *pbstrQuery ); [return: MarshalAs(UnmanagedType.BStr)] new string GetQuery(); /// Returns the entire original Uniform Resource Identifier (URI) input string. /// Address of a string that receives the property value. /// /// IUri::GetRawUri was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_RAW_URI property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775030(v=vs.85) // HRESULT GetRawUri( [out] BSTR *pbstrRawUri ); [return: MarshalAs(UnmanagedType.BStr)] new string GetRawUri(); /// Returns the protocol scheme name. /// Address of a string that receives the property value. /// /// IUri::GetSchemeName was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_SCHEME_NAME property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775032(v=vs.85) // HRESULT GetSchemeName( [out] BSTR *pbstrSchemeName ); [return: MarshalAs(UnmanagedType.BStr)] new string GetSchemeName(); /// Returns the user name and password, as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// IUri::GetUserInfo was introduced in Windows Internet Explorer 7. /// /// Security Warning: Storing sensitive information as clear text in a URI is not recommended. According to RFC3986: /// Uniform Resource Identifier (URI), Generic Syntax, Section 7.5, "A password appearing within the userinfo component is /// deprecated and should be considered an error except in those rare cases where the 'password' parameter is intended to be public." /// /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_USER_INFO property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775033(v=vs.85) // HRESULT GetUserInfo( [out] BSTR *pbstrUserInfo ); [return: MarshalAs(UnmanagedType.BStr)] new string GetUserInfo(); /// Returns the user name as parsed from the Uniform Resource Identifier (URI). /// Address of a string that receives the property value. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyBSTR with the /// Uri_PROPERTY_USER_NAME property. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775034(v=vs.85) // HRESULT GetUserName( [out] BSTR *pbstrUserName ); [return: MarshalAs(UnmanagedType.BStr)] new string GetUserName(); /// Returns a value from the Uri_HOST_TYPE enumeration. /// Address of a DWORD that receives a value from the Uri_HOST_TYPE enumeration. /// /// IUri::GetHostType was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the /// Uri_PROPERTY_HOST_TYPE property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775020(v=vs.85) // HRESULT GetHostType( [out] DWORD *pdwHostType ); new Uri_HOST_TYPE GetHostType(); /// Returns the port number. /// Address of a DWORD that receives the port number value. /// /// IUri::GetPort was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the Uri_PROPERTY_PORT property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775024(v=vs.85) // HRESULT GetPort( [out] DWORD *pdwPort ); new uint GetPort(); /// Returns a value from the URL_SCHEME enumeration. /// Address of a DWORD that receives a value from the URL_SCHEME enumeration. /// /// IUri::GetScheme was introduced in Windows Internet Explorer 7. /// /// This function is for convenience. It is the same as calling IUri::GetPropertyDWORD with the /// Uri_PROPERTY_SCHEME property. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775031(v=vs.85) // HRESULT GetScheme( [out] DWORD *pdwScheme ); new URL_SCHEME GetScheme(); /// This method is not implemented. /// new URLZONE GetZone(); /// Returns a bitmap of flags that indicate which Uniform Resource Identifier (URI) properties have been set. /// /// [out] /// Address of a DWORD that receives a combination of the following flags: /// Uri_HAS_ABSOLUTE_URI (0x00000000) /// Uri_PROPERTY_ABSOLUTE_URI exists. /// Uri_HAS_AUTHORITY (0x00000001) /// Uri_PROPERTY_AUTHORITY exists. /// Uri_HAS_DISPLAY_URI (0x00000002) /// Uri_PROPERTY_DISPLAY_URI exists. /// Uri_HAS_DOMAIN (0x00000004) /// Uri_PROPERTY_DOMAIN exists. /// Uri_HAS_EXTENSION (0x00000008) /// Uri_PROPERTY_EXTENSION exists. /// Uri_HAS_FRAGMENT (0x00000010) /// Uri_PROPERTY_FRAGMENT exists. /// Uri_HAS_HOST (0x00000020) /// Uri_PROPERTY_HOST exists. /// Uri_HAS_HOST_TYPE (0x00004000) /// Uri_PROPERTY_HOST_TYPE exists. /// Uri_HAS_PASSWORD (0x00000040) /// Uri_PROPERTY_PASSWORD exists. /// Uri_HAS_PATH (0x00000080) /// Uri_PROPERTY_PATH exists. /// Uri_HAS_PATH_AND_QUERY (0x00001000) /// Uri_PROPERTY_PATH_AND_QUERY exists. /// Uri_HAS_PORT (0x00008000) /// Uri_PROPERTY_PORT exists. /// Uri_HAS_QUERY (0x00000100) /// Uri_PROPERTY_QUERY exists. /// Uri_HAS_RAW_URI (0x00000200) /// Uri_PROPERTY_RAW_URI exists. /// Uri_HAS_SCHEME (0x00010000) /// Uri_PROPERTY_SCHEME exists. /// Uri_HAS_SCHEME_NAME (0x00000400) /// Uri_PROPERTY_SCHEME_NAME exists. /// Uri_HAS_USER_NAME (0x00000800) /// Uri_PROPERTY_USER_NAME exists. /// Uri_HAS_USER_INFO (0x00002000) /// Uri_PROPERTY_USER_INFO exists. /// Uri_HAS_ZONE (0x00020000) /// Uri_PROPERTY_ZONE exists. /// /// IUri::GetProperties was introduced in Windows Internet Explorer 7. // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775025(v=vs.85) // HRESULT GetProperties( [out] LPDWORD pdwFlags ); new Uri_HAS GetProperties(); /// Compares the logical content of two IUri objects. /// Address of a BOOL that is set to TRUE if the logical content of pUri is the same. /// /// IUri::IsEqual was introduced in Windows Internet Explorer 7. /// The comparison is case-insensitive. Comparing an IUri to itself will always return TRUE. /// // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775037(v=vs.85) // HRESULT IsEqual( [in] IUri *pUri, [out] BOOL *pfEqual ); [return: MarshalAs(UnmanagedType.Bool)] new bool IsEqual([In] IUri pUri); /// /// Gets the part name of the Relationships part that stores relationships that have the source URI represented by the current /// OPC URI object. /// /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name of the Relationships part. The /// source URI of the relationships stored in this Relationships part is represented by the current OPC URI object. /// /// /// The following table shows Relationships part URIs for some OPC URIs. /// /// /// OPC URI /// Relationships Part Name /// Return Value /// /// /// /mydoc/images/picture.jpg /// /mydoc/images/_rels/picture.jpg.rels /// S_OK /// /// /// / /// /_rels/.rels /// S_OK /// /// /// /mydoc/images/_rels/picture.jpg.rels /// Undefined /// OPC_E_NONCONFORMING_URI /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-getrelationshipsparturi HRESULT // GetRelationshipsPartUri( IOpcPartUri **relationshipPartUri ); IOpcPartUri GetRelationshipsPartUri(); /// Forms a relative URI for a specified part, relative to the URI represented by the current OPC URI object. /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name from which the relative URI is formed. /// /// A pointer to the IUri interface of the URI of the part, relative to the current OPC URI object. /// /// Example input and output: /// /// /// Input IOpcPartUri represents /// Current IOpcUri represents /// Returned relative IUri represents /// /// /// /mydoc/markup/page.xml /// /mydoc/markup/picture.jpg /// picture.jpg /// /// /// /mydoc/markup/page.xml /// /mydoc/picture.jpg /// ../picture.jpg /// /// /// /mydoc/markup/page.xml /// /mydoc/images/pictures.jpg /// ../images/pictures.jpg /// /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-getrelativeuri HRESULT GetRelativeUri( IOpcPartUri // *targetPartUri, IUri **relativeUri ); IUri GetRelativeUri([In] IOpcPartUri targetPartUri); /// /// Forms the part name of the part that is referenced by the specified relative URI. The specified relative URI of the part is /// resolved against the URI represented as the current OPC URI object. /// /// /// A pointer to the IUri interface of the relative URI of the part. /// /// To form the part URI object that represents the part name, this input URI is resolved against the URI represented as the /// current OPC URI object. Therefore, the input URI must be relative to the URI represented by the current OPC URI object. /// /// /// This URI may include a fragment component; however, the fragment will be ignored and will not be included in the part name /// to be formed. A fragment component is preceded by a '#', as described in RFC 3986: URI Generic Syntax. /// /// /// /// A pointer to the IOpcPartUri interface of the part URI object that represents the part name. /// /// The part URI object is formed by resolving the relative URI in relativeUri against the URI represented by the current OPC /// URI object. /// /// /// /// Example input and output: /// /// /// Input relative IUri /// Current IOpcUri /// Formed IOpcPartUri /// /// /// picture.jpg /// /mydoc/markup/page.xml /// /mydoc/markup/picture.jpg /// /// /// ../picture.jpg /// /mydoc/markup/page.xml /// /mydoc/picture.jpg /// /// /// ../../images/picture.jpg /// /mydoc/page.xml /// /images/picture.jpg /// /// /// /// For information about how to use this method to help resolve a part name, see Resolving a Part Name from a Target URI. /// /// Support on Previous Windows Versions /// /// The behavior and performance of this method is the same on all supported Windows versions. For more information, see Getting /// Started with the Packaging API, and Platform Update for Windows Vista. /// /// Thread Safety /// Packaging objects are not thread-safe. /// For more information, see the Getting Started with the Packaging API. /// // https://docs.microsoft.com/en-us/windows/win32/api/msopc/nf-msopc-iopcuri-combineparturi HRESULT CombinePartUri( IUri // *relativeUri, IOpcPartUri **combinedUri ); IOpcPartUri CombinePartUri([In] IUri relativeUri); } /// CoClass for IOpcFactory. [PInvokeData("msopc.h", MSDNShortId = "0a265a0a-c109-4afc-a0ad-d3ee31757aa1")] [ComImport, ClassInterface(ClassInterfaceType.None), Guid("6B2D6BA0-9F3E-4f27-920B-313CC426A39E")] public class OpcFactory { } /// Creates an instance from one of the IOpcXXXEnumerator interface instances. /// /// The type of the enumerator interface. This interface must support the MoveNext, GetCurrent and Clone methods. /// /// The type of the elemement interface returned as the parameter in TElem.GetCurrent. /// public class OpcEnumerator : IEnumerator { private MethodInfo getCurrent; private MethodInfo moveNext; private TEnum opcEnum; /// Initializes a new instance of the class. /// The opc enumerator. /// opcEnumerator /// The type specified for TEnum is not a valid Opc Enumerator instance. public OpcEnumerator(TEnum opcEnumerator) { opcEnum = opcEnumerator ?? throw new ArgumentNullException(nameof(opcEnumerator)); moveNext = typeof(TEnum).GetMethod("MoveNext"); getCurrent = typeof(TEnum).GetMethod("GetCurrent"); if (moveNext is null || getCurrent is null) throw new ArgumentException("The type specified for TEnum is not a valid Opc Enumerator instance."); } /// Gets the element in the collection at the current position of the enumerator. public TElem Current { get { var p = new object[] { default(TElem) }; ((HRESULT)getCurrent.Invoke(opcEnum, p)).ThrowIfFailed(); return (TElem)p[0]; } } /// Gets the element in the collection at the current position of the enumerator. object IEnumerator.Current => Current; /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. public void Dispose() => opcEnum = default; /// Advances the enumerator to the next element of the collection. /// /// if the enumerator was successfully advanced to the next element; if the /// enumerator has passed the end of the collection. /// public bool MoveNext() { var p = new object[] { false }; ((HRESULT)moveNext.Invoke(opcEnum, p)).ThrowIfFailed(); return (bool)p[0]; } /// Sets the enumerator to its initial position, which is before the first element in the collection. public void Reset() { var clone = opcEnum.InvokeMethod("Clone"); opcEnum = clone; } } } }