1# Resourcemanager 2 3 4## 概述 5 6提供c相关获取资源的接口。 7 8**起始版本:** 12 9 10 11## 汇总 12 13 14### 文件 15 16| 名称 | 描述 | 17| -------- | -------- | 18| [ohresmgr.h](ohresmgr_8h.md) | 提供资源管理native侧获取资源的能力。 | 19| [resmgr_common.h](resmgr__common_8h.md) | 提供接口所需要的枚举类型和结构体。 | 20 21 22### 结构体 23 24| 名称 | 描述 | 25| -------- | -------- | 26| struct [ResourceManager_Configuration](_resource_manager___configuration.md) | 设备状态的枚举。 | 27 28 29### 类型定义 30 31| 名称 | 描述 | 32| -------- | -------- | 33| typedef enum [ResourceManager_Direction](#resourcemanager_direction) [ResourceManager_Direction](#resourcemanager_direction) | 屏幕方向的枚举。 | 34| typedef enum [ResourceManager_ColorMode](#resourcemanager_colormode) [ResourceManager_ColorMode](#resourcemanager_colormode) | 颜色模式的枚举。 | 35| typedef enum [ResourceManager_DeviceType](#resourcemanager_devicetype) [ResourceManager_DeviceType](#resourcemanager_devicetype) | 设备类型的枚举。 | 36| typedef struct [ResourceManager_Configuration](_resource_manager___configuration.md) [ResourceManager_Configuration](#resourcemanager_configuration) | 设备状态的枚举。 | 37 38 39### 枚举 40 41| 名称 | 描述 | 42| -------- | -------- | 43| [ResourceManager_ErrorCode](#resourcemanager_errorcode) {<br/>SUCCESS = 0, ERROR_CODE_INVALID_INPUT_PARAMETER = 401, ERROR_CODE_RES_ID_NOT_FOUND = 9001001, ERROR_CODE_RES_NOT_FOUND_BY_ID = 9001002,<br/>ERROR_CODE_RES_NAME_NOT_FOUND = 9001003, ERROR_CODE_RES_NOT_FOUND_BY_NAME = 9001004, ERROR_CODE_RES_PATH_INVALID = 9001005, ERROR_CODE_RES_REF_TOO_MUCH = 9001006,<br/>ERROR_CODE_RES_ID_FORMAT_ERROR = 9001007, ERROR_CODE_RES_NAME_FORMAT_ERROR = 9001008, ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED = 9001009, ERROR_CODE_OVERLAY_RES_PATH_INVALID = 9001010,<br/>ERROR_CODE_OUT_OF_MEMORY = 9001100<br/>} | 资源管理错误码。 | 44| [ScreenDensity](#screendensity) {<br/>SCREEN_SDPI = 120, SCREEN_MDPI = 160, SCREEN_LDPI = 240, SCREEN_XLDPI = 320,<br/>SCREEN_XXLDPI = 480, SCREEN_XXXLDPI = 640<br/>} | 屏幕密度类型的枚举。 | 45| [ResourceManager_Direction](#resourcemanager_direction) { DIRECTION_VERTICAL = 0, DIRECTION_HORIZONTAL = 1 } | 屏幕方向的枚举。 | 46| [ResourceManager_ColorMode](#resourcemanager_colormode) { DARK = 0, LIGHT = 1 } | 颜色模式的枚举。 | 47| [ResourceManager_DeviceType](#resourcemanager_devicetype) {<br/>DEVICE_TYPE_PHONE = 0X00, DEVICE_TYPE_TABLET = 0x01, DEVICE_TYPE_CAR = 0x02, DEVICE_TYPE_PC = 0x03,<br/>DEVICE_TYPE_TV = 0x04, DEVICE_TYPE_WEARABLE = 0x06, DEVICE_TYPE_2IN1 = 0x07<br/>} | 设备类型的枚举。 | 48 49 50### 函数 51 52| 名称 | 描述 | 53| -------- | -------- | 54| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaBase64](#oh_resourcemanager_getmediabase64) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, char \*\*resultValue, uint64_t \*resultLen, uint32_t density=0) | 通过指定资源ID,获取屏幕密度对应的media资源的Base64码。 | 55| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaBase64Data](#oh_resourcemanager_getmediabase64data) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, char \*\*resultValue, uint64_t \*resultLen, uint32_t density) | 通过指定资源ID,获取屏幕密度对应的media资源的Base64码。 | 56| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaBase64ByName](#oh_resourcemanager_getmediabase64byname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, char \*\*resultValue, uint64_t \*resultLen, uint32_t density=0) | 通过指定资源名称,获取屏幕密度对应的media资源的Base64码。 | 57| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaBase64DataByName](#oh_resourcemanager_getmediabase64databyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, char \*\*resultValue, uint64_t \*resultLen, uint32_t density) | 通过指定资源名称,获取屏幕密度对应的media资源的Base64码。 | 58| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMedia](#oh_resourcemanager_getmedia) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, uint8_t \*\*resultValue, uint64_t \*resultLen, uint32_t density=0) | 通过指定资源ID,获取屏幕密度对应的media资源的内容。 | 59| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaData](#oh_resourcemanager_getmediadata) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, uint8_t \*\*resultValue, uint64_t \*resultLen, uint32_t density) | 通过指定资源ID,获取屏幕密度对应的media资源的内容。 | 60| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaByName](#oh_resourcemanager_getmediabyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, uint8_t \*\*resultValue, uint64_t \*resultLen, uint32_t density=0) | 通过指定资源名称,获取屏幕密度对应的media资源的内容。 | 61| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetMediaDataByName](#oh_resourcemanager_getmediadatabyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, uint8_t \*\*resultValue, uint64_t \*resultLen, uint32_t density) | 通过指定资源名称,获取屏幕密度对应的media资源的内容。 | 62| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetDrawableDescriptor](#oh_resourcemanager_getdrawabledescriptor) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, ArkUI_DrawableDescriptor \*\*drawableDescriptor, uint32_t density=0, uint32_t type=0) | 通过指定资源Id,获取屏幕密度对应的图标资源的DrawableDescriptor。 | 63| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetDrawableDescriptorData](#oh_resourcemanager_getdrawabledescriptordata) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, ArkUI_DrawableDescriptor \*\*drawableDescriptor, uint32_t density, uint32_t type) | 通过指定资源Id,获取屏幕密度对应的图标资源的DrawableDescriptor。 | 64| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetDrawableDescriptorByName](#oh_resourcemanager_getdrawabledescriptorbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, ArkUI_DrawableDescriptor \*\*drawableDescriptor, uint32_t density=0, uint32_t type=0) | 通过指定资源名称,获取屏幕密度对应的图标资源的DrawableDescriptor。 | 65| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetDrawableDescriptorDataByName](#oh_resourcemanager_getdrawabledescriptordatabyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, ArkUI_DrawableDescriptor \*\*drawableDescriptor, uint32_t density, uint32_t type) | 通过指定资源名称,获取屏幕密度对应的图标资源的DrawableDescriptor。 | 66| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetSymbol](#oh_resourcemanager_getsymbol) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, uint32_t \*resultValue) | 通过指定资源ID,获取对应的symbol资源。 | 67| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetSymbolByName](#oh_resourcemanager_getsymbolbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, uint32_t \*resultValue) | 通过指定资源名称,获取对应的symbol资源。 | 68| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetLocales](#oh_resourcemanager_getlocales) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, char \*\*\*resultValue, uint32_t \*resultLen, bool includeSystem=false) | 获取语言列表。 | 69| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetLocalesData](#oh_resourcemanager_getlocalesdata) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, char \*\*\*resultValue, uint32_t \*resultLen, bool includeSystem) | 获取语言列表。 | 70| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetConfiguration](#oh_resourcemanager_getconfiguration) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, [ResourceManager_Configuration](_resource_manager___configuration.md) \*configuration) | 获取设备配置。 | 71| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_ReleaseConfiguration](#oh_resourcemanager_releaseconfiguration) ([ResourceManager_Configuration](_resource_manager___configuration.md) \*configuration) | 释放OH_ResourceManager_GetConfiguration()方法申请的内存。 | 72| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetString](#oh_resourcemanager_getstring) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, char \*\*resultValue,...) | 通过指定资源ID,获取对应的string资源。 | 73| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetStringByName](#oh_resourcemanager_getstringbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, char \*\*resultValue,...) | 通过指定资源名称,获取对应的string资源。 | 74| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetStringArray](#oh_resourcemanager_getstringarray) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, char \*\*\*resultValue, uint32_t \*resultLen) | 通过指定资源ID,获取字符串数组。 | 75| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetStringArrayByName](#oh_resourcemanager_getstringarraybyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, char \*\*\*resultValue, uint32_t \*resultLen) | 通过指定资源名称,获取字符串数组。 | 76| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_ReleaseStringArray](#oh_resourcemanager_releasestringarray) (char \*\*\*resValue, uint32_t len) | 释放字符串数组内存。 | 77| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetPluralString](#oh_resourcemanager_getpluralstring) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, uint32_t num, char \*\*resultValue) | 通过指定资源ID,获取对应的单复数字符串。 | 78| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetPluralStringByName](#oh_resourcemanager_getpluralstringbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, uint32_t num, char \*\*resultValue) | 通过指定资源名称,获取对应的单复数字符串。 | 79| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetColor](#oh_resourcemanager_getcolor) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, uint32_t \*resultValue) | 通过指定资源ID,获取对应的颜色值。 | 80| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetColorByName](#oh_resourcemanager_getcolorbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, uint32_t \*resultValue) | 通过指定资源ID,获取对应的颜色值。 | 81| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetInt](#oh_resourcemanager_getint) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, int \*resultValue) | 通过指定资源ID,获取对应的int值。 | 82| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetIntByName](#oh_resourcemanager_getintbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, int \*resultValue) | 通过指定资源名称,获取对应的int值。 | 83| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetFloat](#oh_resourcemanager_getfloat) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, float \*resultValue) | 通过指定资源ID,获取对应的float值。 | 84| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetFloatByName](#oh_resourcemanager_getfloatbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, float \*resultValue) | 通过指定资源名称,获取对应的float值。 | 85| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetBool](#oh_resourcemanager_getbool) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, uint32_t resId, bool \*resultValue) | 通过指定资源ID,获取对应的bool值。 | 86| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_GetBoolByName](#oh_resourcemanager_getboolbyname) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*resName, bool \*resultValue) | 通过指定资源名称,获取对应的bool值。 | 87| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_AddResource](#oh_resourcemanager_addresource) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*path) | 在应用程序运行时添加overlay资源。 | 88| [ResourceManager_ErrorCode](#resourcemanager_errorcode) [OH_ResourceManager_RemoveResource](#oh_resourcemanager_removeresource) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*path) | 在应用程序运行时删除overlay资源。 | 89 90 91## 类型定义说明 92 93 94### ResourceManager_ColorMode 95 96``` 97typedef enum ResourceManager_ColorModeResourceManager_ColorMode 98``` 99 100**描述** 101 102颜色模式的枚举。 103 104**起始版本:** 12 105 106 107### ResourceManager_Configuration 108 109``` 110typedef struct ResourceManager_ConfigurationResourceManager_Configuration 111``` 112 113**描述** 114 115设备状态的枚举。 116 117**起始版本:** 12 118 119 120### ResourceManager_DeviceType 121 122``` 123typedef enum ResourceManager_DeviceTypeResourceManager_DeviceType 124``` 125 126**描述** 127 128设备类型的枚举。 129 130**起始版本:** 12 131 132 133### ResourceManager_Direction 134 135``` 136typedef enum ResourceManager_DirectionResourceManager_Direction 137``` 138 139**描述** 140 141屏幕方向的枚举。 142 143**起始版本:** 12 144 145 146## 枚举类型说明 147 148 149### ResourceManager_ColorMode 150 151``` 152enum ResourceManager_ColorMode 153``` 154 155**描述** 156 157颜色模式的枚举。 158 159**起始版本:** 12 160 161| 枚举值 | 描述 | 162| -------- | -------- | 163| DARK | 表示深色模式。 | 164| LIGHT | 表示浅色模式。 | 165 166 167### ResourceManager_DeviceType 168 169``` 170enum ResourceManager_DeviceType 171``` 172 173**描述** 174 175设备类型的枚举。 176 177**起始版本:** 12 178 179| 枚举值 | 描述 | 180| -------- | -------- | 181| DEVICE_TYPE_PHONE | 手机。 | 182| DEVICE_TYPE_TABLET | 平板。 | 183| DEVICE_TYPE_CAR | 汽车。 | 184| DEVICE_TYPE_PC | 电脑。 | 185| DEVICE_TYPE_TV | 电视。 | 186| DEVICE_TYPE_WEARABLE | 穿戴。 | 187| DEVICE_TYPE_2IN1 | 2in1设备。 | 188 189 190### ResourceManager_Direction 191 192``` 193enum ResourceManager_Direction 194``` 195 196**描述** 197 198屏幕方向的枚举。 199 200**起始版本:** 12 201 202| 枚举值 | 描述 | 203| -------- | -------- | 204| DIRECTION_VERTICAL | 表示垂直方向。 | 205| DIRECTION_HORIZONTAL | 表示水平方向。 | 206 207 208### ResourceManager_ErrorCode 209 210``` 211enum ResourceManager_ErrorCode 212``` 213 214**描述** 215 216资源管理错误码。 217 218**起始版本:** 12 219 220| 枚举值 | 描述 | 221| -------- | -------- | 222| SUCCESS | 成功。 | 223| ERROR_CODE_INVALID_INPUT_PARAMETER | 输入参数无效。 | 224| ERROR_CODE_RES_ID_NOT_FOUND | 无效的资源ID。 | 225| ERROR_CODE_RES_NOT_FOUND_BY_ID | 无效的资源名称。 | 226| ERROR_CODE_RES_NAME_NOT_FOUND | 没有根据资源ID找到匹配的资源。 | 227| ERROR_CODE_RES_NOT_FOUND_BY_NAME | 没有根据资源名称找到匹配的资源。 | 228| ERROR_CODE_RES_PATH_INVALID | 无效的相对路径。 | 229| ERROR_CODE_RES_REF_TOO_MUCH | 资源被循环引用。 | 230| ERROR_CODE_RES_ID_FORMAT_ERROR | 无法格式化基于资源ID获得的资源。 | 231| ERROR_CODE_RES_NAME_FORMAT_ERROR | 无法格式化基于资源名称获得的资源。 | 232| ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED | 访问系统资源失败。 | 233| ERROR_CODE_OVERLAY_RES_PATH_INVALID | 无效的overlay路径。 | 234| ERROR_CODE_OUT_OF_MEMORY | 内存溢出。 | 235 236 237### ScreenDensity 238 239``` 240enum ScreenDensity 241``` 242 243**描述** 244 245屏幕密度类型的枚举。 246 247**起始版本:** 12 248 249| 枚举值 | 描述 | 250| -------- | -------- | 251| SCREEN_SDPI | 表示小屏幕密度。 | 252| SCREEN_MDPI | 表示中屏幕密度。 | 253| SCREEN_LDPI | 表示大屏幕密度。 | 254| SCREEN_XLDPI | 表示特大屏幕密度。 | 255| SCREEN_XXLDPI | 表示超大屏幕密度。 | 256| SCREEN_XXXLDPI | 表示超特大屏幕密度。 | 257 258 259## 函数说明 260 261 262### OH_ResourceManager_AddResource() 263 264``` 265ResourceManager_ErrorCode OH_ResourceManager_AddResource (const NativeResourceManager * mgr, const char * path ) 266``` 267 268**描述** 269 270在应用程序运行时添加overlay资源。 271 272**起始版本:** 12 273 274**参数:** 275 276| 名称 | 描述 | 277| -------- | -------- | 278| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 279| path | 资源路径。 | 280 281**返回:** 282 283SUCCESS 0 - 成功。 284 285ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 286 287ERROR_CODE_OVERLAY_RES_PATH_INVALID 9001010 - 无效的资源路径。 288 289 290### OH_ResourceManager_GetBool() 291 292``` 293ResourceManager_ErrorCode OH_ResourceManager_GetBool (const NativeResourceManager * mgr, uint32_t resId, bool * resultValue ) 294``` 295 296**描述** 297 298通过指定资源ID,获取对应的bool值。 299 300**起始版本:** 12 301 302**参数:** 303 304| 名称 | 描述 | 305| -------- | -------- | 306| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 307| resId | 资源ID。 | 308| resultValue | 写入resultValue的结果。 | 309 310**返回:** 311 312SUCCESS 0 - 成功。 313 314ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 315 316ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 317 318ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 319 320ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 321 322 323### OH_ResourceManager_GetBoolByName() 324 325``` 326ResourceManager_ErrorCode OH_ResourceManager_GetBoolByName (const NativeResourceManager * mgr, const char * resName, bool * resultValue ) 327``` 328 329**描述** 330 331通过指定资源名称,获取对应的bool值。 332 333**起始版本:** 12 334 335**参数:** 336 337| 名称 | 描述 | 338| -------- | -------- | 339| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 340| resName | 资源名称。 | 341| resultValue | 写入resultValue的结果。 | 342 343**返回:** 344 345SUCCESS 0 - 成功。 346 347ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 348 349ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 350 351ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 352 353ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 354 355 356### OH_ResourceManager_GetColor() 357 358``` 359ResourceManager_ErrorCode OH_ResourceManager_GetColor (const NativeResourceManager * mgr, uint32_t resId, uint32_t * resultValue ) 360``` 361 362**描述** 363 364通过指定资源ID,获取对应的颜色值。 365 366**起始版本:** 12 367 368**参数:** 369 370| 名称 | 描述 | 371| -------- | -------- | 372| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 373| resId | 资源ID。 | 374| resultValue | 写入resultValue的结果。 | 375 376**返回:** 377 378SUCCESS 0 - 成功。 379 380ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 381 382ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 383 384ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 385 386ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 387 388 389### OH_ResourceManager_GetColorByName() 390 391``` 392ResourceManager_ErrorCode OH_ResourceManager_GetColorByName (const NativeResourceManager * mgr, const char * resName, uint32_t * resultValue ) 393``` 394 395**描述** 396 397通过指定资源ID,获取对应的颜色值。 398 399**起始版本:** 12 400 401**参数:** 402 403| 名称 | 描述 | 404| -------- | -------- | 405| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 406| resName | 资源名称。 | 407| resultValue | 写入resultValue的结果。 | 408 409**返回:** 410 411SUCCESS 0 - 成功。 412 413ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 414 415ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 416 417ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 418 419ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 420 421 422### OH_ResourceManager_GetConfiguration() 423 424``` 425ResourceManager_ErrorCode OH_ResourceManager_GetConfiguration (const NativeResourceManager * mgr, ResourceManager_Configuration * configuration ) 426``` 427 428**描述** 429 430获取设备配置。 431 432使用此接口后,需要调用OH_ResourceManager_ReleaseConfiguration()方法来释放内存。 如果使用malloc创建ResourceManager_Configuration对象,还需要调用free()方法来释放它。 433 434**起始版本:** 12 435 436**参数:** 437 438| 名称 | 描述 | 439| -------- | -------- | 440| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 441| configuration | 写入configuration的结果。 | 442 443**返回:** 444 445SUCCESS 0 - 成功。 446 447ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 448 449ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED 9001009 - 无法访问系统资源。 450 451ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 452 453 454### OH_ResourceManager_GetDrawableDescriptor() 455 456``` 457ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor (const NativeResourceManager * mgr, uint32_t resId, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density = 0, uint32_t type = 0 ) 458``` 459 460**描述** 461 462通过指定资源Id,获取屏幕密度对应的图标资源的DrawableDescriptor。 463 464**起始版本:** 12 465 466**参数:** 467 468| 名称 | 描述 | 469| -------- | -------- | 470| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 471| resId | 资源ID。 | 472| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 473| type | 可选参数,表示图标类型,0表示自身图标,1表示主题图标。 | 474| drawableDescriptor | 写入drawableDescriptor的结果。 | 475 476**返回:** 477 478SUCCESS 0 - 成功。 479 480ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 481 482ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 483 484ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 485 486 487### OH_ResourceManager_GetDrawableDescriptorByName() 488 489``` 490ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName (const NativeResourceManager * mgr, const char * resName, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density = 0, uint32_t type = 0 ) 491``` 492 493**描述** 494 495通过指定资源名称,获取屏幕密度对应的图标资源的DrawableDescriptor。 496 497**起始版本:** 12 498 499**参数:** 500 501| 名称 | 描述 | 502| -------- | -------- | 503| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 504| resName | 资源名称。 | 505| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 506| type | 可选参数,表示图标类型,0表示自身图标,1表示主题图标,2表示动态图标。 | 507| drawableDescriptor | 写入drawableDescriptor的结果。 | 508 509**返回:** 510 511SUCCESS 0 - 成功。 512 513ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 514 515ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 516 517ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 518 519 520### OH_ResourceManager_GetDrawableDescriptorData() 521 522``` 523ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorData (const NativeResourceManager * mgr, uint32_t resId, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density, uint32_t type ) 524``` 525 526**描述** 527 528通过指定资源Id,获取屏幕密度对应的图标资源的DrawableDescriptor。 529 530**起始版本:** 12 531 532**参数:** 533 534| 名称 | 描述 | 535| -------- | -------- | 536| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 537| resId | 资源ID。 | 538| drawableDescriptor | 写入drawableDescriptor的结果。 | 539| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 540| type | 可选参数,表示图标类型,0表示自身图标,1表示主题图标。如果该属性不是必需的,请将该参数设为0。 | 541 542**返回:** 543 544SUCCESS 0 - 成功。 545 546ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 547 548ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 549 550ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 551 552 553### OH_ResourceManager_GetDrawableDescriptorDataByName() 554 555``` 556ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorDataByName (const NativeResourceManager * mgr, const char * resName, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density, uint32_t type ) 557``` 558 559**描述** 560 561通过指定资源名称,获取屏幕密度对应的图标资源的DrawableDescriptor。 562 563**起始版本:** 12 564 565**参数:** 566 567| 名称 | 描述 | 568| -------- | -------- | 569| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 570| resName | 资源名称。 | 571| drawableDescriptor | 写入drawableDescriptor的结果。 | 572| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 573| type | 可选参数,表示图标类型,0表示自身图标,1表示主题图标。如果该属性不是必需的,请将该参数设为0。 | 574 575**返回:** 576 577SUCCESS 0 - 成功。 578 579ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 580 581ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 582 583ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 584 585 586### OH_ResourceManager_GetFloat() 587 588``` 589ResourceManager_ErrorCode OH_ResourceManager_GetFloat (const NativeResourceManager * mgr, uint32_t resId, float * resultValue ) 590``` 591 592**描述** 593 594通过指定资源ID,获取对应的float值。 595 596**起始版本:** 12 597 598**参数:** 599 600| 名称 | 描述 | 601| -------- | -------- | 602| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 603| resId | 资源ID。 | 604| resultValue | 写入resultValue的结果。 | 605 606**返回:** 607 608SUCCESS 0 - 成功。 609 610ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 611 612ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 613 614ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 615 616ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 617 618 619### OH_ResourceManager_GetFloatByName() 620 621``` 622ResourceManager_ErrorCode OH_ResourceManager_GetFloatByName (const NativeResourceManager * mgr, const char * resName, float * resultValue ) 623``` 624 625**描述** 626 627通过指定资源名称,获取对应的float值。 628 629**起始版本:** 12 630 631**参数:** 632 633| 名称 | 描述 | 634| -------- | -------- | 635| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 636| resName | 资源名称。 | 637| resultValue | 写入resultValue的结果。 | 638 639**返回:** 640 641SUCCESS 0 - 成功。 642 643ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 644 645ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 646 647ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 648 649ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 650 651 652### OH_ResourceManager_GetInt() 653 654``` 655ResourceManager_ErrorCode OH_ResourceManager_GetInt (const NativeResourceManager * mgr, uint32_t resId, int * resultValue ) 656``` 657 658**描述** 659 660通过指定资源ID,获取对应的int值。 661 662**起始版本:** 12 663 664**参数:** 665 666| 名称 | 描述 | 667| -------- | -------- | 668| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 669| resId | 资源ID。 | 670| resultValue | 写入resultValue的结果。 | 671 672**返回:** 673 674SUCCESS 0 - 成功。 675 676ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 677 678ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 679 680ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 681 682ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 683 684 685### OH_ResourceManager_GetIntByName() 686 687``` 688ResourceManager_ErrorCode OH_ResourceManager_GetIntByName (const NativeResourceManager * mgr, const char * resName, int * resultValue ) 689``` 690 691**描述** 692 693通过指定资源名称,获取对应的int值。 694 695**起始版本:** 12 696 697**参数:** 698 699| 名称 | 描述 | 700| -------- | -------- | 701| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 702| resName | 资源名称。 | 703| resultValue | 写入resultValue的结果。 | 704 705**返回:** 706 707SUCCESS 0 - 成功。 708 709ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 710 711ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 712 713ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 714 715ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 716 717 718### OH_ResourceManager_GetLocales() 719 720``` 721ResourceManager_ErrorCode OH_ResourceManager_GetLocales (const NativeResourceManager * mgr, char *** resultValue, uint32_t * resultLen, bool includeSystem = false ) 722``` 723 724**描述** 725 726获取语言列表。 727 728使用此接口后,需要调用OH_ResourceManager_ReleaseStringArray()方法来释放localinfo的内存。 729 730**起始版本:** 12 731 732**参数:** 733 734| 名称 | 描述 | 735| -------- | -------- | 736| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 737| resultValue | 写入resultValue的结果。 | 738| resultLen | 写入resultLen的locales长度。 | 739| includeSystem | 是否包含系统资源,默认值为false,当只有系统资源查询locales列表时它不起作用。 | 740 741**返回:** 742 743SUCCESS 0 - 成功。 744 745ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 746 747ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 748 749 750### OH_ResourceManager_GetLocalesData() 751 752``` 753ResourceManager_ErrorCode OH_ResourceManager_GetLocalesData (const NativeResourceManager * mgr, char *** resultValue, uint32_t * resultLen, bool includeSystem ) 754``` 755 756**描述** 757 758获取语言列表。 759 760使用此接口后,需要调用OH_ResourceManager_ReleaseStringArray()方法来释放localinfo的内存。 761 762**起始版本:** 12 763 764**参数:** 765 766| 名称 | 描述 | 767| -------- | -------- | 768| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 769| resultValue | 写入resultValue的结果。 | 770| resultLen | 写入resultLen的locales长度。 | 771| includeSystem | 是否包含系统资源,如果不需要此属性,请将此参数设置为 false。 | 772 773**返回:** 774 775SUCCESS 0 - 成功。 776 777ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 778 779ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 780 781 782### OH_ResourceManager_GetMedia() 783 784``` 785ResourceManager_ErrorCode OH_ResourceManager_GetMedia (const NativeResourceManager * mgr, uint32_t resId, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 786``` 787 788**描述** 789 790通过指定资源ID,获取屏幕密度对应的media资源的内容。 791 792**起始版本:** 12 793 794**参数:** 795 796| 名称 | 描述 | 797| -------- | -------- | 798| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 799| resId | 资源ID。 | 800| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 801| resultValue | 写入resultValue的结果。 | 802| resultLen | 写入resultLen的media长度。 | 803 804**返回:** 805 806SUCCESS 0 - 成功。 807 808ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 809 810ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 811 812ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 813 814ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 815 816 817### OH_ResourceManager_GetMediaBase64() 818 819``` 820ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64 (const NativeResourceManager * mgr, uint32_t resId, char ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 821``` 822 823**描述** 824 825通过指定资源ID,获取屏幕密度对应的media资源的Base64码。 826 827**起始版本:** 12 828 829**参数:** 830 831| 名称 | 描述 | 832| -------- | -------- | 833| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 834| resId | 资源ID。 | 835| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 836| resultValue | 写入resultValue的结果。 | 837| resultLen | 写入resultLen的media长度。 | 838 839**返回:** 840 841SUCCESS 0 - 成功。 842 843ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 844 845ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 846 847ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 848 849ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 850 851 852### OH_ResourceManager_GetMediaBase64ByName() 853 854``` 855ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName (const NativeResourceManager * mgr, const char * resName, char ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 856``` 857 858**描述** 859 860通过指定资源名称,获取屏幕密度对应的media资源的Base64码。 861 862**起始版本:** 12 863 864**参数:** 865 866| 名称 | 描述 | 867| -------- | -------- | 868| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 869| resName | 资源名称。 | 870| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 871| resultValue | 写入resultValue的结果。 | 872| resultLen | 写入resultLen的media长度。 | 873 874**返回:** 875 876SUCCESS 0 - 成功。 877 878ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 879 880ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 881 882ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 883 884ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 885 886 887### OH_ResourceManager_GetMediaBase64Data() 888 889``` 890ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64Data (const NativeResourceManager * mgr, uint32_t resId, char ** resultValue, uint64_t * resultLen, uint32_t density ) 891``` 892 893**描述** 894 895通过指定资源ID,获取屏幕密度对应的media资源的Base64码。 896 897**起始版本:** 12 898 899**参数:** 900 901| 名称 | 描述 | 902| -------- | -------- | 903| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 904| resId | 资源ID。 | 905| resultValue | 写入resultValue的结果。 | 906| resultLen | 写入resultLen的media长度。 | 907| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 908 909**返回:** 910 911SUCCESS 0 - 成功。 912 913ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 914 915ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 916 917ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 918 919ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 920 921 922### OH_ResourceManager_GetMediaBase64DataByName() 923 924``` 925ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64DataByName (const NativeResourceManager * mgr, const char * resName, char ** resultValue, uint64_t * resultLen, uint32_t density ) 926``` 927 928**描述** 929 930通过指定资源名称,获取屏幕密度对应的media资源的Base64码。 931 932**起始版本:** 12 933 934**参数:** 935 936| 名称 | 描述 | 937| -------- | -------- | 938| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 939| resName | 资源名称。 | 940| resultValue | 写入resultValue的结果。 | 941| resultLen | 写入resultLen的media长度。 | 942| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 943 944**返回:** 945 946SUCCESS 0 - 成功。 947 948ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 949 950ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 951 952ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 953 954ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 955 956 957### OH_ResourceManager_GetMediaByName() 958 959``` 960ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName (const NativeResourceManager * mgr, const char * resName, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 961``` 962 963**描述** 964 965通过指定资源名称,获取屏幕密度对应的media资源的内容。 966 967**起始版本:** 12 968 969**参数:** 970 971| 名称 | 描述 | 972| -------- | -------- | 973| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 974| resName | 资源名称。 | 975| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),默认值为0,表示使用当前系统dpi的密度。 | 976| resultValue | 写入resultValue的结果。 | 977| resultLen | 写入resultLen的media长度。 | 978 979**返回:** 980 981SUCCESS 0 - 成功。 982 983ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 984 985ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 986 987ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 988 989ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 990 991 992### OH_ResourceManager_GetMediaData() 993 994``` 995ResourceManager_ErrorCode OH_ResourceManager_GetMediaData (const NativeResourceManager * mgr, uint32_t resId, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density ) 996``` 997 998**描述** 999 1000通过指定资源ID,获取屏幕密度对应的media资源的内容。 1001 1002**起始版本:** 12 1003 1004**参数:** 1005 1006| 名称 | 描述 | 1007| -------- | -------- | 1008| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1009| resId | 资源ID。 | 1010| resultValue | 写入resultValue的结果。 | 1011| resultLen | 写入resultLen的media长度。 | 1012| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 1013 1014**返回:** 1015 1016SUCCESS 0 - 成功。 1017 1018ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1019 1020ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 1021 1022ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 1023 1024ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1025 1026 1027### OH_ResourceManager_GetMediaDataByName() 1028 1029``` 1030ResourceManager_ErrorCode OH_ResourceManager_GetMediaDataByName (const NativeResourceManager * mgr, const char * resName, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density ) 1031``` 1032 1033**描述** 1034 1035通过指定资源名称,获取屏幕密度对应的media资源的内容。 1036 1037**起始版本:** 12 1038 1039**参数:** 1040 1041| 名称 | 描述 | 1042| -------- | -------- | 1043| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1044| resName | 资源名称。 | 1045| resultValue | 写入resultValue的结果。 | 1046| resultLen | 写入resultLen的media长度。 | 1047| density | 可选参数,取值范围参考[ScreenDensity](#screendensity),值为0表示使用当前系统dpi的密度。如果不需要此属性,请将此参数设置为0。 | 1048 1049**返回:** 1050 1051SUCCESS 0 - 成功。 1052 1053ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1054 1055ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 1056 1057ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 1058 1059ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1060 1061 1062### OH_ResourceManager_GetPluralString() 1063 1064``` 1065ResourceManager_ErrorCode OH_ResourceManager_GetPluralString (const NativeResourceManager * mgr, uint32_t resId, uint32_t num, char ** resultValue ) 1066``` 1067 1068**描述** 1069 1070通过指定资源ID,获取对应的单复数字符串。 1071 1072使用此接口后,需要调用free()方法来释放字符串的内存。 1073 1074**起始版本:** 12 1075 1076**参数:** 1077 1078| 名称 | 描述 | 1079| -------- | -------- | 1080| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1081| resId | 资源ID。 | 1082| num | 数量值。 | 1083| resultValue | 写入resultValue的结果。 | 1084 1085**返回:** 1086 1087SUCCESS 0 - 成功。 1088 1089ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1090 1091ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 1092 1093ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 1094 1095ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1096 1097ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1098 1099 1100### OH_ResourceManager_GetPluralStringByName() 1101 1102``` 1103ResourceManager_ErrorCode OH_ResourceManager_GetPluralStringByName (const NativeResourceManager * mgr, const char * resName, uint32_t num, char ** resultValue ) 1104``` 1105 1106**描述** 1107 1108通过指定资源名称,获取对应的单复数字符串。 1109 1110使用此接口后,需要调用free()方法来释放字符串的内存。 1111 1112**起始版本:** 12 1113 1114**参数:** 1115 1116| 名称 | 描述 | 1117| -------- | -------- | 1118| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1119| resName | 资源名称。 | 1120| num | 数量值。 | 1121| resultValue | 写入resultValue的结果。 | 1122 1123**返回:** 1124 1125SUCCESS 0 - 成功。 1126 1127ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1128 1129ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 1130 1131ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 1132 1133ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1134 1135ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1136 1137 1138### OH_ResourceManager_GetString() 1139 1140``` 1141ResourceManager_ErrorCode OH_ResourceManager_GetString (const NativeResourceManager * mgr, uint32_t resId, char ** resultValue, ... ) 1142``` 1143 1144**描述** 1145 1146通过指定资源ID,获取对应的string资源。 1147 1148获取普通string资源使用OH_ResourceManager_GetString(mgr, resId, resultValue)接口。 获取带有d、s、f占位符的格式化资源使用OH_ResourceManager_GetString(mgr, resId, resultValue, 10, "format", 10.10)接口。 使用此接口后,需要调用free()方法来释放字符串的内存。 1149 1150**起始版本:** 12 1151 1152**参数:** 1153 1154| 名称 | 描述 | 1155| -------- | -------- | 1156| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1157| resId | 资源ID。 | 1158| resultValue | 写入resultValue的结果。 | 1159| ... | 格式化字符串资源参数,可变参数,支持const char\*、int、float类型。 | 1160 1161**返回:** 1162 1163SUCCESS 0 - 成功。 1164 1165ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1166 1167ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 1168 1169ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 1170 1171ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1172 1173ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1174 1175 1176### OH_ResourceManager_GetStringArray() 1177 1178``` 1179ResourceManager_ErrorCode OH_ResourceManager_GetStringArray (const NativeResourceManager * mgr, uint32_t resId, char *** resultValue, uint32_t * resultLen ) 1180``` 1181 1182**描述** 1183 1184通过指定资源ID,获取字符串数组。 1185 1186使用此接口后,需要调用OH_ResourceManager_ReleaseStringArray()接口来释放字符串数组内存。 1187 1188**起始版本:** 12 1189 1190**参数:** 1191 1192| 名称 | 描述 | 1193| -------- | -------- | 1194| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1195| resId | 资源ID。 | 1196| resultValue | 写入resultValue的结果。 | 1197| resultLen | 写入resultLen的StringArray长度。 | 1198 1199**返回:** 1200 1201SUCCESS 0 - 成功。 1202 1203ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1204 1205ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 1206 1207ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 1208 1209ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1210 1211ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1212 1213 1214### OH_ResourceManager_GetStringArrayByName() 1215 1216``` 1217ResourceManager_ErrorCode OH_ResourceManager_GetStringArrayByName (const NativeResourceManager * mgr, const char * resName, char *** resultValue, uint32_t * resultLen ) 1218``` 1219 1220**描述** 1221 1222通过指定资源名称,获取字符串数组。 1223 1224使用此接口后,需要调用OH_ResourceManager_ReleaseStringArray()接口来释放字符串数组内存。 1225 1226**起始版本:** 12 1227 1228**参数:** 1229 1230| 名称 | 描述 | 1231| -------- | -------- | 1232| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1233| resName | 资源名称。 | 1234| resultValue | 写入resultValue的结果。 | 1235| resultLen | 写入resultLen的StringArray长度。 | 1236 1237**返回:** 1238 1239SUCCESS 0 - 成功。 1240 1241ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1242 1243ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 1244 1245ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 1246 1247ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1248 1249ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1250 1251 1252### OH_ResourceManager_GetStringByName() 1253 1254``` 1255ResourceManager_ErrorCode OH_ResourceManager_GetStringByName (const NativeResourceManager * mgr, const char * resName, char ** resultValue, ... ) 1256``` 1257 1258**描述** 1259 1260通过指定资源名称,获取对应的string资源。 1261 1262获取普通string资源使用OH_ResourceManager_GetString(mgr, resName, resultValue)接口。 获取带有%d、%s、%f占位符的格式化资源使用OH_ResourceManager_GetString(mgr, resName, resultValue, 10, "format", 10.10)接口。 使用此接口后,需要调用free()方法来释放字符串的内存。 1263 1264**起始版本:** 12 1265 1266**参数:** 1267 1268| 名称 | 描述 | 1269| -------- | -------- | 1270| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1271| resName | 资源名称。 | 1272| resultValue | 写入resultValue的结果。 | 1273| ... | 格式化字符串资源参数,可变参数,支持const char\*、int、float类型。 | 1274 1275**返回:** 1276 1277SUCCESS 0 - 成功。 1278 1279ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1280 1281ERROR_CODE_RES_ID_NOT_FOUND 9001003 - 无效的资源名称。 1282 1283ERROR_CODE_RES_NOT_FOUND_BY_ID 9001004 - 没有根据资源名称找到匹配的资源。 1284 1285ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1286 1287ERROR_CODE_OUT_OF_MEMORY 9001100 - 内存溢出。 1288 1289 1290### OH_ResourceManager_GetSymbol() 1291 1292``` 1293ResourceManager_ErrorCode OH_ResourceManager_GetSymbol (const NativeResourceManager * mgr, uint32_t resId, uint32_t * resultValue ) 1294``` 1295 1296**描述** 1297 1298通过指定资源ID,获取对应的symbol资源。 1299 1300**起始版本:** 12 1301 1302**参数:** 1303 1304| 名称 | 描述 | 1305| -------- | -------- | 1306| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1307| resId | 资源ID。 | 1308| resultValue | 写入resultValue的结果。 | 1309 1310**返回:** 1311 1312SUCCESS 0 - 成功。 1313 1314ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1315 1316ERROR_CODE_RES_ID_NOT_FOUND 9001001 - 无效的资源ID。 1317 1318ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - 没有根据资源ID找到匹配的资源。 1319 1320ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1321 1322 1323### OH_ResourceManager_GetSymbolByName() 1324 1325``` 1326ResourceManager_ErrorCode OH_ResourceManager_GetSymbolByName (const NativeResourceManager * mgr, const char * resName, uint32_t * resultValue ) 1327``` 1328 1329**描述** 1330 1331通过指定资源名称,获取对应的symbol资源。 1332 1333**起始版本:** 12 1334 1335**参数:** 1336 1337| 名称 | 描述 | 1338| -------- | -------- | 1339| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1340| resName | 资源名称。 | 1341| resultValue | 写入resultValue的结果。 | 1342 1343**返回:** 1344 1345SUCCESS 0 - 成功。 1346 1347ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1348 1349ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - 无效的资源名称。 1350 1351ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - 没有根据资源名称找到匹配的资源。 1352 1353ERROR_CODE_RES_REF_TOO_MUCH 9001006 - 资源被循环引用。 1354 1355 1356### OH_ResourceManager_ReleaseConfiguration() 1357 1358``` 1359ResourceManager_ErrorCode OH_ResourceManager_ReleaseConfiguration (ResourceManager_Configuration * configuration) 1360``` 1361 1362**描述** 1363 1364释放OH_ResourceManager_GetConfiguration()方法申请的内存。 1365 1366**起始版本:** 12 1367 1368**参数:** 1369 1370| 名称 | 描述 | 1371| -------- | -------- | 1372| configuration | 需要释放内存的configuration对象。 | 1373 1374**返回:** 1375 1376SUCCESS 0 - 成功。 1377 1378ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1379 1380 1381### OH_ResourceManager_ReleaseStringArray() 1382 1383``` 1384ResourceManager_ErrorCode OH_ResourceManager_ReleaseStringArray (char *** resValue, uint32_t len ) 1385``` 1386 1387**描述** 1388 1389释放字符串数组内存。 1390 1391**起始版本:** 12 1392 1393**参数:** 1394 1395| 名称 | 描述 | 1396| -------- | -------- | 1397| resValue | 需要释放的字符串数组。 | 1398| len | 字符串数组长度。 | 1399 1400**返回:** 1401 1402SUCCESS 0 - 成功。 1403 1404ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1405 1406 1407### OH_ResourceManager_RemoveResource() 1408 1409``` 1410ResourceManager_ErrorCode OH_ResourceManager_RemoveResource (const NativeResourceManager * mgr, const char * path ) 1411``` 1412 1413**描述** 1414 1415在应用程序运行时删除overlay资源。 1416 1417**起始版本:** 12 1418 1419**参数:** 1420 1421| 名称 | 描述 | 1422| -------- | -------- | 1423| mgr | 指向[NativeResourceManager](rawfile.md#nativeresourcemanager)的指针,此指针通过[OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager)方法获取。 | 1424| path | 资源路径。 | 1425 1426**返回:** 1427 1428SUCCESS 0 - 成功。 1429 1430ERROR_CODE_INVALID_INPUT_PARAMETER 401 - 输入参数无效。可能的原因:1.参数类型不正确;2.参数验证失败。 1431 1432ERROR_CODE_OVERLAY_RES_PATH_INVALID 9001010 - 无效的资源路径。