IOpcPartSet::CreatePart method (msopc.h)
Creates a part object that represents a part and adds a pointer to the object's IOpcPart interface to the set.
Syntax
HRESULT CreatePart(
[in] IOpcPartUri *name,
[in] LPCWSTR contentType,
[in] OPC_COMPRESSION_OPTIONS compressionOptions,
[out, retval] IOpcPart **part
);
Parameters
[in] name
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.
[in] contentType
The media type of part content.
[in] compressionOptions
A value that describes the way to compress the part content of the part.
[out, retval] part
A pointer to the new IOpcPart that represents the part.
This parameter cannot be NULL.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Return code/value | Description |
---|---|
|
The method succeeded. |
|
The name parameter is NULL. |
|
The value passed in the compressionOptions parameter is not a valid OPC_COMPRESSION_OPTIONS enumeration value. |
|
A part with the specified part name already exists in the current package. |
|
A content type does not conform to the rules for a valid media type, specified in RFC 2616: HTTP/1.1 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) and the OPC. |
|
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. |
|
An HRESULT error code from the Package Consumption Error Group. |
|
An HRESULT error code from the Part URI Error Group. |
Remarks
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.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps only] |
Minimum supported server | Windows Server 2008 R2 [desktop apps only] |
Target Platform | Windows |
Header | msopc.h |
See also
External Resources
Getting Started with the Packaging API
Overviews
Reference