openharmony 鸿蒙 capi-os-account-h

2026-08-25 浏览 (1)

os_account.h

Overview

Defines the APIs for accessing and managing system account information.

Library: libos_account_ndk.so

Header file: <BasicServicesKit/os_account.h>

System capability: SystemCapability.Account.OsAccount

Since: 12

Related module: OsAccount

Summary

Functions

NameDescription
OsAccount_ErrCode OH_OsAccount_GetName(char *buffer, size_t buffer_size)Obtains the name of the system account, to which the caller process belongs.
OsAccount_ErrCode OH_OsAccount_GetNameByLocalId(int32_t localId, char *name, size_t name_size)Obtains the name of the target system account based on its local ID.

Function Description

OH_OsAccount_GetName()

OsAccount_ErrCode OH_OsAccount_GetName(char *buffer, size_t buffer_size)

Description

Obtains the name of the system account, to which the caller process belongs.

System capability: SystemCapability.Account.OsAccount

Since: 12

Parameters

NameDescription
char *bufferName character array. Its minimum length is the system account name plus the terminator (\0). Its maximum length is defined by LOGIN_NAME_MAX.
size_t buffer_sizeLength of the system account name.

Returns

TypeDescription
OsAccount_ErrCodeOS_ACCOUNT_ERR_OK: The operation is successful.
OS_ACCOUNT_ERR_INTERNAL_ERROR: An internal error occurs.
OS_ACCOUNT_ERR_INVALID_PARAMETER: The buffer is a null pointer, or the length of the system account name (excluding \0) is greater than or equal to the value of buffer_size.

OH_OsAccount_GetNameByLocalId()

OsAccount_ErrCode OH_OsAccount_GetNameByLocalId(int32_t localId, char *name, size_t name_size)

Description

Obtains the name of the target system account based on its local ID.

Required permissions: ohos.permission.GET_LOCAL_ACCOUNT_IDENTIFIERS

Since: 26.0.0

Parameters

NameDescription
int32_t localIdLocal ID of the target system account.
char *nameName character array, which must contain the system account name and terminator (\0). The maximum length is defined by LOGIN_NAME_MAX whose value is 256.
size_t name_sizeLength of the system account name.

Returns

TypeDescription
OsAccount_ErrCodeOS_ACCOUNT_ERR_OK: The operation is successful.
OS_ACCOUNT_ERR_PERMISSION_DENIED: Permission is denied.
OS_ACCOUNT_ERR_INTERNAL_ERROR: An internal error occurs.
OS_ACCOUNT_ERR_INVALID_PARAMETER: The name is null pointer or the length of the system account name (including \0) is greater than the value of name_size.
OS_ACCOUNT_ERR_ACCOUNT_NOT_FOUND: The account is not found.
OS_ACCOUNT_ERR_RESTRICTED_ACCOUNT: The account is restricted and cannot be queried.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 errorcode-zlib

openharmony 鸿蒙 capi-oh-scan-scan-picturescanprogress

openharmony 鸿蒙 js-apis-screen-lock

openharmony 鸿蒙 capi-os-account-common-h

openharmony 鸿蒙 js-apis-screen-lock-sys

openharmony 鸿蒙 capi-oh-print-print-propertylist

openharmony 鸿蒙 capi-oh-scan

openharmony 鸿蒙 js-apis-system-device

openharmony 鸿蒙 errorcode-intelligentVoice

openharmony 鸿蒙 js-apis-request-sys

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/qjJQFPoW