harmony 鸿蒙Pasteboard

  • 2025-06-12
  • 浏览 (3)

Pasteboard

Overview

The Pasteboard module supports copying and pasting multiple types of data, including plain text, HTML, URI, and pixel map.

Since: 13

Summary

Files

Name Description
oh_pasteboard.h Provides data structure, enum types, and APIs for accessing the system pasteboard.
oh_pasteboard_err_code.h Declares the error code information of the pasteboard.

Types

Name Description
typedef enum Pasteboard_NotifyType Pasteboard_NotifyType Defines an enum for the data change types of the pasteboard.
typedef void(* Pasteboard_Notify) (void *context, Pasteboard_NotifyType type) Defines a callback to be invoked when the pasteboard content changes.
typedef void(* Pasteboard_Finalize) (void *context) Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed.
typedef struct OH_PasteboardObserver OH_PasteboardObserver Defines a struct for the pasteboard observer.
typedef struct OH_Pasteboard OH_Pasteboard Defines a struct for the pasteboard object to operate the system pasteboard.
typedef enum PASTEBOARD_ErrCode PASTEBOARD_ErrCode Defines an enum for the error codes.
typedef enum Pasteboard_FileConflictOptions Pasteboard_FileConflictOptions Defines an enum for the file conflict options.
typedef enum Pasteboard_ProgressIndicator Pasteboard_ProgressIndicator Defines an enum for progress indicator options. You can use the default progress indicator as required.
typedef struct Pasteboard_ProgressInfo Pasteboard_ProgressInfo Defines a struct for the progress information. This information is reported only when Pasteboard_ProgressIndicator is set to PASTEBOARD_NONE.
typedef void (* OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo) Defines a callback for obtaining the progress information. If the default progress indicator is not used, you can set this parameter to obtain the pasting progress.
typedef struct Pasteboard_GetDataParams Pasteboard_GetDataParams Defines a struct for the pasteboard parameters required for displaying progress, including progress indicator options, destination path, and file conflict options.

Enums

Name Description
Pasteboard_NotifyType { NOTIFY_LOCAL_DATA_CHANGE = 1, NOTIFY_REMOTE_DATA_CHANGE = 2 } Enumerates the data change types of the pasteboard.
PASTEBOARD_ErrCode {
ERR_OK = 0, ERR_PERMISSION_ERROR = 201, ERR_INVALID_PARAMETER = 401, ERR_DEVICE_NOT_SUPPORTED = 801,
ERR_INNER_ERROR = 12900000, ERR_BUSY = 12900003, ERR_PASTEBOARD_COPY_FILE_ERROR = 12900007, ERR_PASTEBOARD_PROGRESS_START_ERROR = 12900008, ERR_PASTEBOARD_PROGRESS_ABNORMAL = 12900009, ERR_PASTEBOARD_GET_DATA_FAILED = 12900010, ERR_BUSY_PROCESSING = 27787277, ERR_COPY_FORBIDDEN = 27787278
}
Enumerates the error codes.
Pasteboard_FileConflictOptions { PASTEBOARD_OVERWRITE = 0, PASTEBOARD_SKIP = 1} Enumerates the file conflict options.
Pasteboard_ProgressIndicator { PASTEBOARD_NONE = 0, PASTEBOARD_DEFAULT = 1 } Enumerates progress indicator types.

Functions

Name Description
OH_PasteboardObserver * OH_PasteboardObserver_Create () Creates an OH_PasteboardObserver instance and a pointer to it.
int OH_PasteboardObserver_Destroy (OH_PasteboardObserver *observer) Destroys an OH_PasteboardObserver instance.
int OH_PasteboardObserver_SetData (OH_PasteboardObserver *observer, void *context, const Pasteboard_Notify callback, const Pasteboard_Finalize finalize) Sets a callback for the pasteboard observer.
OH_Pasteboard * OH_Pasteboard_Create () Creates an OH_Pasteboard instance and a pointer to it.
void OH_Pasteboard_Destroy (OH_Pasteboard *pasteboard) Destroys an OH_Pasteboard instance.
int OH_Pasteboard_Subscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) Subscribes to the pasteboard observer.
int OH_Pasteboard_Unsubscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) Unsubscribes from the pasteboard observer.
bool OH_Pasteboard_IsRemoteData (OH_Pasteboard *pasteboard) Checks whether the pasteboard data comes from remote devices.
int OH_Pasteboard_GetDataSource (OH_Pasteboard *pasteboard, char *source, unsigned int len) Obtains the pasteboard data source.
bool OH_Pasteboard_HasType (OH_Pasteboard *pasteboard, const char *type) Checks whether the pasteboard contains data of the specified type.
bool OH_Pasteboard_HasData (OH_Pasteboard *pasteboard) Checks whether the pasteboard contains data.
OH_UdmfData * OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status) Obtains data from the pasteboard.
int OH_Pasteboard_SetData (OH_Pasteboard *pasteboard, OH_UdmfData *data) Writes the unified data object to the pasteboard.
int OH_Pasteboard_ClearData (OH_Pasteboard *pasteboard) Clears data from the pasteboard.
char ** OH_Pasteboard_GetMimeTypes (OH_Pasteboard *pasteboard, unsigned int *count) Obtains the MIME type from the pasteboard.
Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void) Creates a Pasteboard_GetDataParams instance and a pointer to it.
void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params) Destroys a Pasteboard_GetDataParams instance.
void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params, Pasteboard_ProgressIndicator progressIndicator) Sets the progress indication options in Pasteboard_GetDataParams. You can use the default progress indicator as required.
void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen) Sets the destination path in Pasteboard_GetDataParams.
void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params, Pasteboard_FileConflictOptions option) Sets the file copy conflict options in Pasteboard_GetDataParams.
void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params, const OH_Pasteboard_ProgressListener listener) Sets a progress listener in Pasteboard_GetDataParams.
int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo) Obtains the pasting progress using Pasteboard_ProgressInfo.
void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params) Cancels an ongoing copy and paste task using Pasteboard_GetDataParams.
OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params, int* status) Obtains the pasteboard data and pasting progress. Folders cannot be copied.
uint32_t OH_Pasteboard_GetChangeCount (OH_Pasteboard *pasteboard) Obtains the number of times that the pasteboard data changes.

Type Description

OH_Pasteboard

typedef struct OH_Pasteboard OH_Pasteboard

Description

Defines a struct for the pasteboard object to operate the system pasteboard.

Since: 13

OH_PasteboardObserver

typedef struct OH_PasteboardObserver OH_PasteboardObserver

Description

Defines a struct for the pasteboard observer.

Since: 13

PASTEBOARD_ErrCode

typedef enum PASTEBOARD_ErrCode PASTEBOARD_ErrCode

Description

Defines an enum for the error codes.

Since: 13

Pasteboard_Finalize

typedef void(* Pasteboard_Finalize) (void *context)

Description

Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed.

Since: 13

Parameters

Name Description
context Pointer to the context to release.

Pasteboard_Notify

typedef void(* Pasteboard_Notify) (void *context, Pasteboard_NotifyType type)

Description

Defines a callback to be invoked when the pasteboard content changes.

Since: 13

Parameters

Name Description
context Context, which is passed in by the OH_PasteboardObserver_SetData function.
type Data change type. For details, see Pasteboard_NotifyType.

Pasteboard_NotifyType

typedef enum Pasteboard_NotifyType Pasteboard_NotifyType

Description

Defines an enum for the data change types of the pasteboard.

Since: 13

Pasteboard_FileConflictOptions

typedef enum Pasteboard_FileConflictOptions Pasteboard_FileConflictOptions

Description

Defines an enum for the file conflict options. The default value is PASTEBOARD_OVERWRITE.

Since: 15

Pasteboard_ProgressIndicator

typedef enum Pasteboard_ProgressIndicator Pasteboard_ProgressIndicator

Description

Defines an enum for progress indicator options. You can use the default progress indicator as required.

Since: 15

Pasteboard_ProgressInfo

typedef struct Pasteboard_ProgressInfo Pasteboard_ProgressInfo

Description

Defines a struct for the progress information. This information is reported only when Pasteboard_ProgressIndicator is set to NONE.

Since: 15

OH_Pasteboard_ProgressListener

typedef void (*OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo);

Description

Defines a callback to be invoked to obtain the progress information when the default progress indicator is not used.

Since: 15

Parameters

Name Type Description
progressInfo Pasteboard_ProgressInfo Defines the progress information. This information is reported only when Pasteboard_ProgressIndicator is set to NONE.

Pasteboard_GetDataParams

typedef struct Pasteboard_GetDataParams Pasteboard_GetDataParams;

Description

Defines a struct for the pasteboard parameters required for displaying progress, including progress indicator options, destination path, and file conflict options.

Since: 15

Enum Description

PASTEBOARD_ErrCode

enum PASTEBOARD_ErrCode

Description

Enumerates the error codes.

Since: 13

Value Description
ERR_OK The operation is successful.
ERR_PERMISSION_ERROR Permission verification failed.
ERR_INVALID_PARAMETER Invalid parameter.
ERR_DEVICE_NOT_SUPPORTED The device capability is not supported.
ERR_INNER_ERROR Internal error.
ERR_BUSY System busy.
ERR_PASTEBOARD_COPY_FILE_ERROR File copying failed.
ERR_PASTEBOARD_PROGRESS_START_ERROR Progress indicator creation fails when the application uses the system progress indicator.
ERR_PASTEBOARD_PROGRESS_ABNORMAL Progress reporting is abnormal when the application stops using the system progress indicator.
ERR_PASTEBOARD_GET_DATA_FAILED Obtaining pasteboard data failed.

Pasteboard_NotifyType

enum Pasteboard_NotifyType

Description

Enumerates the data change types of the pasteboard.

Since: 13

Value Description
NOTIFY_LOCAL_DATA_CHANGE The pasteboard data of the local device is changed.
NOTIFY_REMOTE_DATA_CHANGE The pasteboard data of a non-local device on the network is changed.

Pasteboard_FileConflictOptions

enum Pasteboard_FileConflictOptions

Description

Enumerates the file conflict options.

Since: 15

Value Description
PASTEBOARD_OVERWRITE Overwrites the file with the same name in the destination path.
PASTEBOARD_SKIP Skips the file with the same name in the destination path. If SKIP is set, the pasteboard data of the skipped file is not pasted to the application.

Pasteboard_ProgressIndicator

enum Pasteboard_ProgressIndicator

Description

Enumerates the progress indicator options. You can use the default progress indicator as required.

Since: 15

Value Description
PASTEBOARD_NONE The default progress indicator is not used.
PASTEBOARD_DEFAULT The default progress indicator is used.

Function Description

OH_Pasteboard_ClearData()

int OH_Pasteboard_ClearData (OH_Pasteboard * pasteboard)

Description

Clears data from the pasteboard.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_Pasteboard

PASTEBOARD_ErrCode

OH_Pasteboard_Create()

OH_Pasteboard* OH_Pasteboard_Create ()

Description

Creates an OH_Pasteboard instance and a pointer to it.

Since: 13

Returns

Returns a pointer to the OH_Pasteboard instance created if the operation is successful; returns nullptr otherwise.

See

OH_Pasteboard

OH_Pasteboard_Destroy()

void OH_Pasteboard_Destroy (OH_Pasteboard * pasteboard)

Description

Destroys an OH_Pasteboard instance.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.

See

OH_Pasteboard

OH_Pasteboard_GetData()

OH_UdmfData* OH_Pasteboard_GetData (OH_Pasteboard * pasteboard, int * status )

Description

Obtains data from the pasteboard.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
status Output parameter, indicating the error code of the operation. For details, see PASTEBOARD_ErrCode.

Returns

Returns the pointer to the OH_UdmfData instance obtained if the operation is successful; returns a null pointer otherwise.

See

OH_Pasteboard

OH_UdmfData

PASTEBOARD_ErrCode

OH_Pasteboard_GetDataSource()

int OH_Pasteboard_GetDataSource (OH_Pasteboard * pasteboard, char * source, unsigned int len )

Description

Obtains the pasteboard data source.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
source Output parameter, indicating the source string of the pasteboard data.
len Output parameter, indicating the length of the data source string.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_Pasteboard

PASTEBOARD_ErrCode

OH_Pasteboard_HasData()

bool OH_Pasteboard_HasData (OH_Pasteboard * pasteboard)

Description

Checks whether the pasteboard contains data.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.

Returns

Returns a Boolean value indicating whether the pasteboard contains data. The value true means the pasteboard contains data; the value false means the opposite.

See

OH_Pasteboard

OH_Pasteboard_HasType()

bool OH_Pasteboard_HasType (OH_Pasteboard * pasteboard, const char * type )

Description

Checks whether the pasteboard contains data of the specified type.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
type Data type to be checked.

Returns

Returns a Boolean value indicating whether the pasteboard contains data of the specified type. The value true means the pasteboard contains data of the specified type; the value false means the opposite.

See

OH_Pasteboard

OH_Pasteboard_IsRemoteData()

bool OH_Pasteboard_IsRemoteData (OH_Pasteboard * pasteboard)

Description

Checks whether the pasteboard data comes from remote devices.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.

Returns

Returns a Boolean value indicating whether the data is from a remote device. The value true means the data is from a remote device. The value false means the data is from the local device.

See

OH_Pasteboard

OH_Pasteboard_SetData()

int OH_Pasteboard_SetData (OH_Pasteboard * pasteboard, OH_UdmfData * data )

Description

Writes the unified data object to the pasteboard.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
data Pointer to the OH_UdmfData instance.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_Pasteboard

OH_UdmfData

PASTEBOARD_ErrCode

OH_Pasteboard_Subscribe()

int OH_Pasteboard_Subscribe (OH_Pasteboard * pasteboard, int type, const OH_PasteboardObserver * observer )

Description

Subscribes to the pasteboard observer.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
type Subscribed data change type of the pasteboard. For details, see Pasteboard_NotifyType.
observer Pointer to an OH_PasteboardObserver instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see OH_PasteboardObserver.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_Pasteboard

OH_PasteboardObserver

Pasteboard_NotifyType

PASTEBOARD_ErrCode

OH_Pasteboard_Unsubscribe()

int OH_Pasteboard_Unsubscribe (OH_Pasteboard * pasteboard, int type, const OH_PasteboardObserver * observer )

Description

Unsubscribes from the pasteboard observer.

Since: 13

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
type Subscribed data change type of the pasteboard. For details, see Pasteboard_NotifyType.
observer Pointer to an OH_PasteboardObserver instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see OH_PasteboardObserver.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_Pasteboard

OH_PasteboardObserver

Pasteboard_NotifyType

PASTEBOARD_ErrCode

OH_PasteboardObserver_Create()

OH_PasteboardObserver* OH_PasteboardObserver_Create ()

Description

Creates an OH_PasteboardObserver instance and a pointer to it.

Since: 13

Returns

Returns a pointer to the OH_PasteboardObserver instance created if the operation is successful; returns nullptr otherwise. If this pointer is no longer required, use OH_PasteboardObserver_Destroy to destroy it. Otherwise, memory leaks may occur.

See

OH_PasteboardObserver

OH_PasteboardObserver_Destroy()

int OH_PasteboardObserver_Destroy (OH_PasteboardObserver * observer)

Description

Destroys an OH_PasteboardObserver instance.

Since: 13

Parameters

Name Description
observer Pointer to an OH_PasteboardObserver instance.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_PasteboardObserver

PASTEBOARD_ErrCode

OH_PasteboardObserver_SetData()

int OH_PasteboardObserver_SetData (OH_PasteboardObserver * observer, void * context, const Pasteboard_Notify callback, const Pasteboard_Finalize finalize )

Description

Sets a callback for the pasteboard observer.

Since: 13

Parameters

Name Description
observer Pointer to an OH_PasteboardObserver instance.
context Pointer to the context data, which is passed to Pasteboard_Notify as the first parameter.
callback Callback to be invoked when the data changes. For details, see Pasteboard_Notify.
finalize Optional callback, which can be used to release context data when the pasteboard observer is destroyed. For details, see Pasteboard_Finalize.

Returns

Returns an error code. For details, see PASTEBOARD_ErrCode.
Returns ERR_OK if the operation is successful.
Returns ERR_INVALID_PARAMETER if an invalid parameter is passed in.

See

OH_PasteboardObserver

Pasteboard_Notify

PASTEBOARD_ErrCode

OH_Pasteboard_GetMimeTypes()

char ** OH_Pasteboard_GetMimeTypes (OH_Pasteboard * pasteboard, unsigned int * count)

Description

Obtains the MIME type from the pasteboard.

Since: 14

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
count Pointer to the number of uniform data types obtained.

Returns

Returns the MIME type obtained if the operation is successful; returns nullptr otherwise.

The lifecycle of the object returned by this API is managed by the input parameter object pasteboard. When the application calls OH_Pasteboard_Destroy to destroy pasteboard, the result returned by this API is released synchronously.

The pasteboard object saves only the latest result and the historical results obtained by the API become invalid.

See

OH_Pasteboard

OH_Pasteboard_GetDataParams_Create()

Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void);

Description

Creates a Pasteboard_GetDataParams instance and a pointer to it.

Since: 15

Returns

Returns a pointer to the Pasteboard_GetDataParams instance created if the operation is successful; returns nullptr otherwise. If this pointer is no longer required, use OH_Pasteboard_GetDataParams_Destroy to destroy it. Otherwise, memory leaks may occur.

See

Pasteboard_GetDataParams

OH_Pasteboard_GetDataParams_Destroy()

void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params)

Description

Destroys a Pasteboard_GetDataParams instance.

Since: 15

Parameters

Name Description
params Pointer to a Pasteboard_GetDataParams instance.

See

Pasteboard_GetDataParams

OH_Pasteboard_GetDataParams_SetProgressIndicator()

void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params,
    Pasteboard_ProgressIndicator progressIndicator)

Description

Sets the progress indication options in Pasteboard_GetDataParams. You can use the default progress indicator as required.

Since: 15

Parameters

Name Description
params Pointer to the context data.
progressIndicator Progress indicator options. You can use the default progress indicator as required.

See

Pasteboard_GetDataParams

Pasteboard_ProgressIndicator

OH_Pasteboard_GetDataParams_SetDestUri()

void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen)

Description

Sets the destination path in Pasteboard_GetDataParams for copying files. If file processing is not supported, this parameter is not required. If the application involves complex file processing policies or needs to distinguish file multipathing storage, you are advised not to set this parameter but let the application copies files by itself.

Since: 15

Parameters

Name Description
params Pointer to the context data.
destUri Destination path for copying files.
destUriLen Length of the destination path.

See

Pasteboard_GetDataParams

Pasteboard_ProgressIndicator

OH_Pasteboard_GetDataParams_SetFileConflictOptions()

void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params,
    Pasteboard_FileConflictOptions option)

Description

Sets the file copy conflict options in Pasteboard_GetDataParams. The default value is PASTEBOARD_OVERWRITE.

Since: 15

Parameters

Name Description
params Pointer to the context data.
option File copy conflict options The default value is PASTEBOARD_OVERWRITE.

See

Pasteboard_GetDataParams

Pasteboard_FileConflictOptions

OH_Pasteboard_GetDataParams_SetProgressListener()

void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params,
    const OH_Pasteboard_ProgressListener listener)

Description

Sets a progress listener in Pasteboard_GetDataParams.

Since: 15

Parameters

Name Description
params Pointer to the context data.
listener A listener for progress data changes. If the default progress indicator is not used, you can set this parameter to obtain the pasting progress.

See

Pasteboard_GetDataParams

OH_Pasteboard_ProgressListener

OH_Pasteboard_ProgressInfo_GetProgress()

int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo)

Description

Obtains the pasting progress using Pasteboard_ProgressInfo. Result can be obtained only when Pasteboard_ProgressIndicator is set to PASTEBOARD_NONE.

Since: 15

Parameters

Name Description
progressInfo Defines the progress information. This information is reported only when Pasteboard_ProgressIndicator is set to PASTEBOARD_NONE.

Returns

Returns progress percentage of a copy and paste task.

See

Pasteboard_ProgressInfo

OH_Pasteboard_ProgressCancel()

void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params);

Description

Cancels an ongoing copy and paste task using Pasteboard_GetDataParams. This parameter is valid only when Pasteboard_ProgressIndicator is set to PASTEBOARD_NONE.

Since: 15

Parameters

Name Description
params Pointer to the context data.

See

Pasteboard_GetDataParams

OH_Pasteboard_GetDataWithProgress()

OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params, int* status);

Description

Obtains the pasteboard content and progress. Folders cannot be copied.

Since: 15

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.
params Parameters required when an application uses the file copy capability provided by the pasteboard. For details, see Pasteboard_GetDataParams.
status Output parameter, indicating the error code of the operation. For details, see PASTEBOARD_ErrCode.

Returns

Returns the pointer to the OH_UdmfData instance obtained if the operation is successful; returns a null pointer otherwise.

See

Pasteboard_GetDataParams

OH_Pasteboard_GetChangeCount()

uint32_t OH_Pasteboard_GetChangeCount(OH_Pasteboard *pasteboard);

Description

Obtains the number of times that the pasteboard data changes.

Even though the pasteboard data expires, or the data becomes empty because of the called OH_Pasteboard_ClearData API, the number of data changes remains.

When the system is restarted, or the pasteboard service is restarted due to an exception, the number of pasteboard data changes counts from 0. In addition, copying the same data repeatedly is considered to change the data for multiple times. Therefore, each time the data is copied, the number of data changes increases.

Since: 18

Parameters

Name Description
pasteboard Pointer to an OH_Pasteboard instance.

Returns

Returns the result if this API is called successfully; otherwise, returns 0.

See

OH_Pasteboard

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Basic Services Kit

harmony 鸿蒙DeviceInfo

harmony 鸿蒙InitSync

harmony 鸿蒙OH_Print

harmony 鸿蒙OsAccount

harmony 鸿蒙Print_Margin

harmony 鸿蒙Print_PageSize

harmony 鸿蒙Print_PrintAttributes

harmony 鸿蒙Print_PrintDocCallback

harmony 鸿蒙Print_Range

0  赞