1# start_options.h 2 3## Overview 4 5The file declares the [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) struct for application startup parameters and the functions for setting and obtaining data. 6 7**File to include**: <AbilityKit/ability_runtime/start_options.h> 8 9**Library**: libability_runtime.so 10 11**System capability**: SystemCapability.Ability.AbilityRuntime.Core 12 13**Since**: 17 14 15**Related module**: [AbilityRuntime](capi-abilityruntime.md) 16 17## Summary 18 19### Structs 20 21| Name| typedef Keyword| Description| 22| -- | -- | -- | 23| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) | AbilityRuntime_StartOptions | StartOptions struct.| 24 25### Functions 26 27| Name| Description| 28| -- | -- | 29| [AbilityRuntime_StartOptions* OH_AbilityRuntime_CreateStartOptions(void)](#oh_abilityruntime_createstartoptions) | Creates an AbilityRuntime_StartOptions object.| 30| [AbilityRuntime_ErrorCode OH_AbilityRuntime_DestroyStartOptions(AbilityRuntime_StartOptions **startOptions)](#oh_abilityruntime_destroystartoptions) | Destroys an AbilityRuntime_StartOptions object.| 31| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowMode(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_WindowMode windowMode)](#oh_abilityruntime_setstartoptionswindowmode) | Sets the window mode for starting an ability.| 32| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowMode(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_WindowMode &windowMode)](#oh_abilityruntime_getstartoptionswindowmode) | Obtains the window mode for starting an ability.| 33| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsDisplayId(AbilityRuntime_StartOptions *startOptions,int32_t displayId)](#oh_abilityruntime_setstartoptionsdisplayid) | Sets the ID of the display where the window is launched when the ability is started.| 34| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsDisplayId(AbilityRuntime_StartOptions *startOptions,int32_t &displayId)](#oh_abilityruntime_getstartoptionsdisplayid) | Obtains the ID of the display where the window is launched when the ability is started.| 35| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWithAnimation(AbilityRuntime_StartOptions *startOptions,bool withAnimation)](#oh_abilityruntime_setstartoptionswithanimation) | Sets whether to use animation effects when an ability is started.| 36| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWithAnimation(AbilityRuntime_StartOptions *startOptions,bool &withAnimation)](#oh_abilityruntime_getstartoptionswithanimation) | Checks whether animation effects are used when an ability is started.| 37| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowLeft(AbilityRuntime_StartOptions *startOptions,int32_t windowLeft)](#oh_abilityruntime_setstartoptionswindowleft) | Sets the left position of the window when the ability is started, in px.| 38| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowLeft(AbilityRuntime_StartOptions *startOptions,int32_t &windowLeft)](#oh_abilityruntime_getstartoptionswindowleft) | Obtains the left position of the window when the ability is started, in px.| 39| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowTop(AbilityRuntime_StartOptions *startOptions,int32_t windowTop)](#oh_abilityruntime_setstartoptionswindowtop) | Sets the top position of the window when the ability is started, in px.| 40| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowTop(AbilityRuntime_StartOptions *startOptions,int32_t &windowTop)](#oh_abilityruntime_getstartoptionswindowtop) | Obtains the top position of the window when the ability is started, in px.| 41| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowHeight(AbilityRuntime_StartOptions *startOptions,int32_t windowHeight)](#oh_abilityruntime_setstartoptionswindowheight) | Sets the height of the window when the ability is started, in px.| 42| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowHeight(AbilityRuntime_StartOptions *startOptions,int32_t &windowHeight)](#oh_abilityruntime_getstartoptionswindowheight) | Obtains the height of the window when the ability is started, in px.| 43| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowWidth(AbilityRuntime_StartOptions *startOptions,int32_t windowWidth)](#oh_abilityruntime_setstartoptionswindowwidth) | Sets the width of the window when the ability is started, in px.| 44| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowWidth(AbilityRuntime_StartOptions *startOptions,int32_t &windowWidth)](#oh_abilityruntime_getstartoptionswindowwidth) | Obtains the width of the window when the ability is started, in px.| 45| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartVisibility(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_StartVisibility startVisibility)](#oh_abilityruntime_setstartoptionsstartvisibility) | Sets the visibility of the window and dock bar icons when the ability is started.| 46| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartVisibility(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_StartVisibility &startVisibility)](#oh_abilityruntime_getstartoptionsstartvisibility) | Obtains the visibility of the window and dock bar icons when the ability is started.| 47| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartWindowIcon(AbilityRuntime_StartOptions *startOptions,OH_PixelmapNative *startWindowIcon)](#oh_abilityruntime_setstartoptionsstartwindowicon) | Sets the startup icon of the window when the ability is started. The maximum size of an image used as the startup icon is 600 MB.| 48| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartWindowIcon(AbilityRuntime_StartOptions *startOptions,OH_PixelmapNative **startWindowIcon)](#oh_abilityruntime_getstartoptionsstartwindowicon) | Obtains the startup icon of the window when the ability is started.| 49| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartWindowBackgroundColor(AbilityRuntime_StartOptions *startOptions, const char *startWindowBackgroundColor)](#oh_abilityruntime_setstartoptionsstartwindowbackgroundcolor) | Sets the background color of the window when the ability is started. If this function is not called, the value of **startWindowBackground** configured under **abilities** in the **module.json5** file corresponding to the UIAbility is used by default.| 50| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartWindowBackgroundColor(AbilityRuntime_StartOptions *startOptions, char **startWindowBackgroundColor, size_t &size)](#oh_abilityruntime_getstartoptionsstartwindowbackgroundcolor) | Obtains the background color of the window when the ability is started.| 51| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsSupportedWindowModes(AbilityRuntime_StartOptions *startOptions, AbilityRuntime_SupportedWindowMode *supportedWindowModes,size_t size)](#oh_abilityruntime_setstartoptionssupportedwindowmodes) | Sets the window modes supported by the ability when it is started. If this function is not called, the value of **supportWindowMode** configured under **abilities** in the **module.json5** file corresponding to the UIAbility is used by default.| 52| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsSupportedWindowModes(AbilityRuntime_StartOptions *startOptions, AbilityRuntime_SupportedWindowMode **supportedWindowModes,size_t &size)](#oh_abilityruntime_getstartoptionssupportedwindowmodes) | Obtains the window modes supported by the ability when it is started.| 53| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMinWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t minWindowWidth)](#oh_abilityruntime_setstartoptionsminwindowwidth) | Sets the minimum width of the window when the ability is started, in vp.| 54| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMinWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t &minWindowWidth)](#oh_abilityruntime_getstartoptionsminwindowwidth) | Obtains the minimum width of the window when the ability is started, in vp.| 55| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMaxWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t maxWindowWidth)](#oh_abilityruntime_setstartoptionsmaxwindowwidth) | Sets the maximum width of the window when the ability is started, in vp.| 56| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMaxWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t &maxWindowWidth)](#oh_abilityruntime_getstartoptionsmaxwindowwidth) | Obtains the maximum width of the window when the ability is started, in vp.| 57| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMinWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t minWindowHeight)](#oh_abilityruntime_setstartoptionsminwindowheight) | Sets the minimum height of the window when the ability is started, in vp.| 58| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMinWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t &minWindowHeight)](#oh_abilityruntime_getstartoptionsminwindowheight) | Obtains the minimum height of the window when the ability is started, in vp.| 59| [AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMaxWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t maxWindowHeight)](#oh_abilityruntime_setstartoptionsmaxwindowheight) | Sets the maximum height of the window when the ability is started, in vp.| 60| [AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMaxWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t &maxWindowHeight)](#oh_abilityruntime_getstartoptionsmaxwindowheight) | Obtains the maximum height of the window when the ability is started, in vp.| 61 62## Function Description 63 64### OH_AbilityRuntime_CreateStartOptions() 65 66``` 67AbilityRuntime_StartOptions* OH_AbilityRuntime_CreateStartOptions(void) 68``` 69 70**Description** 71 72Creates an [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) object. 73 74**Since**: 17 75 76**Returns** 77 78| Type| Description| 79| -- | -- | 80| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md)* | Pointer to the AbilityRuntime_StartOptions object created.| 81 82**Example** 83 84```cpp 85#include <AbilityKit/ability_runtime/start_options.h> 86 87void createStartOptionsTest() 88{ 89 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 90 if (options == nullptr) { 91 // Record error logs and other service processing. 92 return; 93 } 94 95 // Destroy options to prevent memory leakage. 96 OH_AbilityRuntime_DestroyStartOptions(&options); 97} 98``` 99 100### OH_AbilityRuntime_DestroyStartOptions() 101 102``` 103AbilityRuntime_ErrorCode OH_AbilityRuntime_DestroyStartOptions(AbilityRuntime_StartOptions **startOptions) 104``` 105 106**Description** 107 108Destroys an [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) object. 109 110**Since**: 17 111 112**Parameters** 113 114| Name| Description| 115| -- | -- | 116| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) **startOptions | Double pointer to the AbilityRuntime_StartOptions object.| 117 118**Returns** 119 120| Type| Description| 121| -- | -- | 122| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 123 124**Example** 125 126```cpp 127#include <AbilityKit/ability_runtime/start_options.h> 128 129void destroyStartOptionsTest() 130{ 131 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 132 if (options == nullptr) { 133 // Record error logs and other service processing. 134 return; 135 } 136 137 // Destroy options to prevent memory leakage. 138 OH_AbilityRuntime_DestroyStartOptions(&options); 139} 140``` 141 142### OH_AbilityRuntime_SetStartOptionsWindowMode() 143 144``` 145AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowMode(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_WindowMode windowMode) 146``` 147 148**Description** 149 150Sets the window mode for starting an ability. 151 152**Since**: 17 153 154 155**Parameters** 156 157| Name| Description| 158| -- | -- | 159| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 160| [AbilityRuntime_WindowMode](capi-context-constant-h.md#abilityruntime_windowmode) windowMode | Window mode. For details about the available options, see **AbilityRuntime_WindowMode**.| 161 162**Returns** 163 164| Type| Description| 165| -- | -- | 166| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **WindowMode** is invalid.| 167 168**Example** 169 170```cpp 171#include <AbilityKit/ability_runtime/start_options.h> 172 173void demo() 174{ 175 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 176 if (options == nullptr) { 177 // Record error logs and other service processing. 178 return; 179 } 180 181 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWindowMode(options, 182 ABILITY_RUNTIME_WINDOW_MODE_FULL_SCREEN); 183 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 184 // Record error logs and other service processing. 185 } 186 // Destroy options to prevent memory leakage. 187 OH_AbilityRuntime_DestroyStartOptions(&options); 188} 189``` 190 191### OH_AbilityRuntime_GetStartOptionsWindowMode() 192 193``` 194AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowMode(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_WindowMode &windowMode) 195``` 196 197**Description** 198 199Obtains the window mode for starting an ability. 200 201**Since**: 17 202 203**Parameters** 204 205| Name| Description| 206| -- | -- | 207| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 208| [AbilityRuntime_WindowMode](capi-context-constant-h.md#abilityruntime_windowmode) windowMode | Window mode. For details about the available options, see **AbilityRuntime_WindowMode**.| 209 210**Returns** 211 212| Type| Description| 213| -- | -- | 214| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 215 216**Example** 217 218```cpp 219#include <AbilityKit/ability_runtime/start_options.h> 220 221void demo() 222{ 223 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 224 if (options == nullptr) { 225 // Record error logs and other service processing. 226 return; 227 } 228 229 AbilityRuntime_WindowMode windowMode = ABILITY_RUNTIME_WINDOW_MODE_UNDEFINED; 230 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWindowMode(options, windowMode); 231 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 232 // Record error logs and other service processing. 233 } 234 // Destroy options to prevent memory leakage. 235 OH_AbilityRuntime_DestroyStartOptions(&options); 236} 237``` 238 239### OH_AbilityRuntime_SetStartOptionsDisplayId() 240 241``` 242AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsDisplayId(AbilityRuntime_StartOptions *startOptions,int32_t displayId) 243``` 244 245**Description** 246 247Sets the ID of the display where the window is launched when the ability is started. 248 249**Since**: 17 250 251**Parameters** 252 253| Name| Description| 254| -- | -- | 255| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 256| int32_t displayId | Display ID.| 257 258**Returns** 259 260| Type| Description| 261| -- | -- | 262| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 263 264**Example** 265 266```cpp 267#include <AbilityKit/ability_runtime/start_options.h> 268 269void demo() 270{ 271 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 272 if (options == nullptr) { 273 // Record error logs and other service processing. 274 return; 275 } 276 277 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsDisplayId(options, 1); 278 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 279 // Record error logs and other service processing. 280 } 281 // Destroy options to prevent memory leakage. 282 OH_AbilityRuntime_DestroyStartOptions(&options); 283} 284``` 285 286### OH_AbilityRuntime_GetStartOptionsDisplayId() 287 288``` 289AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsDisplayId(AbilityRuntime_StartOptions *startOptions,int32_t &displayId) 290``` 291 292**Description** 293 294Obtains the ID of the display where the window is launched when the ability is started. 295 296**Since**: 17 297 298**Parameters** 299 300| Name| Description| 301| -- | -- | 302| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 303| int32_t &displayId | Display ID.| 304 305**Returns** 306 307| Type| Description| 308| -- | -- | 309| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 310 311**Example** 312 313```cpp 314#include <AbilityKit/ability_runtime/start_options.h> 315 316void demo() 317{ 318 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 319 if (options == nullptr) { 320 // Record error logs and other service processing. 321 return; 322 } 323 324 int32_t displayId = 0; 325 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsDisplayId(options, displayId); 326 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 327 // Record error logs and other service processing. 328 } 329 // Destroy options to prevent memory leakage. 330 OH_AbilityRuntime_DestroyStartOptions(&options); 331} 332``` 333 334### OH_AbilityRuntime_SetStartOptionsWithAnimation() 335 336``` 337AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWithAnimation(AbilityRuntime_StartOptions *startOptions,bool withAnimation) 338``` 339 340**Description** 341 342Sets whether to use animation effects when an ability is started. 343 344**Since**: 17 345 346**Parameters** 347 348| Name| Description| 349| -- | -- | 350| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 351| bool withAnimation | Whether to use animation effects.<br>**true** to use, **false** otherwise.| 352 353**Returns** 354 355| Type| Description| 356| -- | -- | 357| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 358 359**Example** 360 361```cpp 362#include <AbilityKit/ability_runtime/start_options.h> 363 364void demo() 365{ 366 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 367 if (options == nullptr) { 368 // Record error logs and other service processing. 369 return; 370 } 371 372 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWithAnimation(options, true); 373 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 374 // Record error logs and other service processing. 375 } 376 // Destroy options to prevent memory leakage. 377 OH_AbilityRuntime_DestroyStartOptions(&options); 378} 379``` 380 381### OH_AbilityRuntime_GetStartOptionsWithAnimation() 382 383``` 384AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWithAnimation(AbilityRuntime_StartOptions *startOptions,bool &withAnimation) 385``` 386 387**Description** 388 389Checks whether animation effects are used when an ability is started. 390 391**Since**: 17 392 393**Parameters** 394 395| Name| Description| 396| -- | -- | 397| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 398| bool &withAnimation | Check result for whether animation effects are used.<br>**true** if used, **false** otherwise.| 399 400**Returns** 401 402| Type| Description| 403| -- | -- | 404| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 405 406**Example** 407 408```cpp 409#include <AbilityKit/ability_runtime/start_options.h> 410 411void demo() 412{ 413 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 414 if (options == nullptr) { 415 // Record error logs and other service processing. 416 return; 417 } 418 419 bool withAnimation = false; 420 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWithAnimation(options, withAnimation); 421 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 422 // Record error logs and other service processing. 423 } 424 // Destroy options to prevent memory leakage. 425 OH_AbilityRuntime_DestroyStartOptions(&options); 426} 427``` 428 429### OH_AbilityRuntime_SetStartOptionsWindowLeft() 430 431``` 432AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowLeft(AbilityRuntime_StartOptions *startOptions,int32_t windowLeft) 433``` 434 435**Description** 436 437Sets the left position of the window when the ability is started, in px. 438 439**Since**: 17 440 441**Parameters** 442 443| Name| Description| 444| -- | -- | 445| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 446| int32_t windowLeft | Left position of the window, in px.| 447 448**Returns** 449 450| Type| Description| 451| -- | -- | 452| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 453 454**Example** 455 456```cpp 457#include <AbilityKit/ability_runtime/start_options.h> 458 459void demo() 460{ 461 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 462 if (options == nullptr) { 463 // Record error logs and other service processing. 464 return; 465 } 466 467 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWindowLeft(options, 200); 468 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 469 // Record error logs and other service processing. 470 } 471 // Destroy options to prevent memory leakage. 472 OH_AbilityRuntime_DestroyStartOptions(&options); 473} 474``` 475 476### OH_AbilityRuntime_GetStartOptionsWindowLeft() 477 478``` 479AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowLeft(AbilityRuntime_StartOptions *startOptions,int32_t &windowLeft) 480``` 481 482**Description** 483 484Obtains the left position of the window when the ability is started, in px. 485 486**Since**: 17 487 488**Parameters** 489 490| Name| Description| 491| -- | -- | 492| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 493| int32_t &windowLeft | Left position of the window, in px.| 494 495**Returns** 496 497| Type| Description| 498| -- | -- | 499| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 500 501**Example** 502 503```cpp 504#include <AbilityKit/ability_runtime/start_options.h> 505 506void demo() 507{ 508 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 509 if (options == nullptr) { 510 // Record error logs and other service processing. 511 return; 512 } 513 514 int32_t windowLeft = 0; 515 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWindowLeft(options, windowLeft); 516 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 517 // Record error logs and other service processing. 518 } 519 // Destroy options to prevent memory leakage. 520 OH_AbilityRuntime_DestroyStartOptions(&options); 521} 522``` 523 524### OH_AbilityRuntime_SetStartOptionsWindowTop() 525 526``` 527AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowTop(AbilityRuntime_StartOptions *startOptions,int32_t windowTop) 528``` 529 530**Description** 531 532Sets the top position of the window when the ability is started, in px. 533 534**Since**: 17 535 536**Parameters** 537 538| Name| Description| 539| -- | -- | 540| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 541| int32_t windowTop | Top position of the window, in px.| 542 543**Returns** 544 545| Type| Description| 546| -- | -- | 547| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 548 549**Example** 550 551```cpp 552#include <AbilityKit/ability_runtime/start_options.h> 553 554void demo() 555{ 556 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 557 if (options == nullptr) { 558 // Record error logs and other service processing. 559 return; 560 } 561 562 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWindowTop(options, 500); 563 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 564 // Record error logs and other service processing. 565 } 566 // Destroy options to prevent memory leakage. 567 OH_AbilityRuntime_DestroyStartOptions(&options); 568} 569``` 570 571### OH_AbilityRuntime_GetStartOptionsWindowTop() 572 573``` 574AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowTop(AbilityRuntime_StartOptions *startOptions,int32_t &windowTop) 575``` 576 577**Description** 578 579Obtains the top position of the window when the ability is started, in px. 580 581**Since**: 17 582 583**Parameters** 584 585| Name| Description| 586| -- | -- | 587| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 588| int32_t &windowTop | Top position of the window, in px.| 589 590**Returns** 591 592| Type| Description| 593| -- | -- | 594| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 595 596**Example** 597 598```cpp 599#include <AbilityKit/ability_runtime/start_options.h> 600 601void demo() 602{ 603 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 604 if (options == nullptr) { 605 // Record error logs and other service processing. 606 return; 607 } 608 609 int32_t windowTop = 0; 610 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWindowTop(options, windowTop); 611 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 612 // Record error logs and other service processing. 613 } 614 // Destroy options to prevent memory leakage. 615 OH_AbilityRuntime_DestroyStartOptions(&options); 616} 617``` 618 619### OH_AbilityRuntime_SetStartOptionsWindowHeight() 620 621``` 622AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowHeight(AbilityRuntime_StartOptions *startOptions,int32_t windowHeight) 623``` 624 625**Description** 626 627Sets the height of the window when the ability is started, in px. 628 629**Since**: 17 630 631**Parameters** 632 633| Name| Description| 634| -- | -- | 635| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 636| int32_t windowHeight | Window height, in px.| 637 638**Returns** 639 640| Type| Description| 641| -- | -- | 642| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 643 644**Example** 645 646```cpp 647#include <AbilityKit/ability_runtime/start_options.h> 648 649void demo() 650{ 651 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 652 if (options == nullptr) { 653 // Record error logs and other service processing. 654 return; 655 } 656 657 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWindowHeight(options, 500); 658 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 659 // Record error logs and other service processing. 660 } 661 // Destroy options to prevent memory leakage. 662 OH_AbilityRuntime_DestroyStartOptions(&options); 663} 664``` 665 666### OH_AbilityRuntime_GetStartOptionsWindowHeight() 667 668``` 669AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowHeight(AbilityRuntime_StartOptions *startOptions,int32_t &windowHeight) 670``` 671 672**Description** 673 674Obtains the height of the window when the ability is started, in px. 675 676**Since**: 17 677 678**Parameters** 679 680| Name| Description| 681| -- | -- | 682| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 683| int32_t &windowHeight | Window height, in px.| 684 685**Returns** 686 687| Type| Description| 688| -- | -- | 689| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 690 691**Example** 692 693```cpp 694#include <AbilityKit/ability_runtime/start_options.h> 695 696void demo() 697{ 698 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 699 if (options == nullptr) { 700 // Record error logs and other service processing. 701 return; 702 } 703 704 int32_t windowHeight = 0; 705 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWindowHeight(options, windowHeight); 706 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 707 // Record error logs and other service processing. 708 } 709 // Destroy options to prevent memory leakage. 710 OH_AbilityRuntime_DestroyStartOptions(&options); 711} 712``` 713 714### OH_AbilityRuntime_SetStartOptionsWindowWidth() 715 716``` 717AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsWindowWidth(AbilityRuntime_StartOptions *startOptions,int32_t windowWidth) 718``` 719 720**Description** 721 722Sets the width of the window when the ability is started, in px. 723 724**Since**: 17 725 726**Parameters** 727 728| Name| Description| 729| -- | -- | 730| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 731| int32_t windowWidth | Window width, in px.| 732 733**Returns** 734 735| Type| Description| 736| -- | -- | 737| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 738 739**Example** 740 741```cpp 742#include <AbilityKit/ability_runtime/start_options.h> 743 744void demo() 745{ 746 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 747 if (options == nullptr) { 748 // Record error logs and other service processing. 749 return; 750 } 751 752 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsWindowWidth(options, 500); 753 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 754 // Record error logs and other service processing. 755 } 756 // Destroy options to prevent memory leakage. 757 OH_AbilityRuntime_DestroyStartOptions(&options); 758} 759``` 760 761### OH_AbilityRuntime_GetStartOptionsWindowWidth() 762 763``` 764AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsWindowWidth(AbilityRuntime_StartOptions *startOptions,int32_t &windowWidth) 765``` 766 767**Description** 768 769Obtains the width of the window when the ability is started, in px. 770 771**Since**: 17 772 773**Parameters** 774 775| Name| Description| 776| -- | -- | 777| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 778| int32_t &windowWidth | Window width, in px.| 779 780**Returns** 781 782| Type| Description| 783| -- | -- | 784| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 785 786**Example** 787 788```cpp 789#include <AbilityKit/ability_runtime/start_options.h> 790 791void demo() 792{ 793 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 794 if (options == nullptr) { 795 // Record error logs and other service processing. 796 return; 797 } 798 799 int32_t windowWidth = 0; 800 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsWindowWidth(options, windowWidth); 801 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 802 // Record error logs and other service processing. 803 } 804 // Destroy options to prevent memory leakage. 805 OH_AbilityRuntime_DestroyStartOptions(&options); 806} 807``` 808 809### OH_AbilityRuntime_SetStartOptionsStartVisibility() 810 811``` 812AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartVisibility(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_StartVisibility startVisibility) 813``` 814 815**Description** 816 817Sets the visibility of the window and dock bar icons when the ability is started. 818 819**Since**: 17 820 821**Parameters** 822 823| Name| Description| 824| -- | -- | 825| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to the StartOptions struct.| 826| [AbilityRuntime_StartVisibility](capi-context-constant-h.md#abilityruntime_startvisibility) startVisibility | Visibility. For details about the available options, see **AbilityRuntime_StartVisibility**.| 827 828**Returns** 829 830| Type| Description| 831| -- | -- | 832| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The setting is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **startVisibility** is not an enumerated value of **AbilityRuntime_StartVisibility**.| 833 834**Example** 835 836```cpp 837#include <AbilityKit/ability_runtime/start_options.h> 838 839void demo() 840{ 841 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 842 if (options == nullptr) { 843 // Record error logs and other service processing. 844 return; 845 } 846 847 AbilityRuntime_StartVisibility visibility = AbilityRuntime_StartVisibility::ABILITY_RUNTIME_SHOW_UPON_START; 848 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsStartVisibility(options, visibility); 849 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 850 // Record error logs and other service processing. 851 } 852 // Destroy options to prevent memory leakage. 853 OH_AbilityRuntime_DestroyStartOptions(&options); 854} 855``` 856 857### OH_AbilityRuntime_GetStartOptionsStartVisibility() 858 859``` 860AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartVisibility(AbilityRuntime_StartOptions *startOptions,AbilityRuntime_StartVisibility &startVisibility) 861``` 862 863**Description** 864 865Obtains the visibility of the window and dock bar icons when the ability is started. 866 867**Since**: 17 868 869**Parameters** 870 871| Name| Description| 872| -- | -- | 873| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to the StartOptions struct.| 874| [bilityRuntime_StartVisibility](capi-context-constant-h.md#abilityruntime_startvisibility) &startVisibility | Visibility. For details about the available options, see **AbilityRuntime_StartVisibility**.| 875 876**Returns** 877 878| Type| Description| 879| -- | -- | 880| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The retrieval is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **startVisibility** is empty.| 881 882**Example** 883 884```cpp 885#include <AbilityKit/ability_runtime/start_options.h> 886 887void demo() 888{ 889 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 890 if (options == nullptr) { 891 // Record error logs and other service processing. 892 return; 893 } 894 895 AbilityRuntime_StartVisibility visibility; 896 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsStartVisibility(options, visibility); 897 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 898 // Record error logs and other service processing. 899 } 900 // Destroy options to prevent memory leakage. 901 OH_AbilityRuntime_DestroyStartOptions(&options); 902} 903``` 904 905### OH_AbilityRuntime_SetStartOptionsStartWindowIcon() 906 907``` 908AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartWindowIcon(AbilityRuntime_StartOptions *startOptions,OH_PixelmapNative *startWindowIcon) 909``` 910 911**Description** 912 913Sets the startup icon of the window when the ability is started. The maximum size of an image used as the startup icon is 600 MB. 914 915**Since**: 17 916 917**Parameters** 918 919| Name| Description| 920| -- | -- | 921| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 922| OH_PixelmapNative *startWindowIcon | Pointer to the startup icon of the window. The maximum size of an image used as the startup icon is 600 MB.| 923 924**Returns** 925 926| Type| Description| 927| -- | -- | 928| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **OH_PixelmapNative** is not nullptr.| 929 930**Example** 931 932```cpp 933#include <AbilityKit/ability_runtime/start_options.h> 934 935void demo() 936{ 937 uint8_t data[96]; 938 size_t dataSize = 96; 939 for (int i = 0; i < dataSize; i++) { 940 data[i] = i + 1; 941 } 942 943 // Create a parameter structure instance and set parameters. 944 OH_Pixelmap_InitializationOptions *createOpts = nullptr; 945 OH_PixelmapInitializationOptions_Create(&createOpts); 946 OH_PixelmapInitializationOptions_SetWidth(createOpts, 6); 947 OH_PixelmapInitializationOptions_SetHeight(createOpts, 4); 948 OH_PixelmapInitializationOptions_SetPixelFormat(createOpts, PIXEL_FORMAT_RGBA_8888); 949 OH_PixelmapInitializationOptions_SetAlphaType(createOpts, PIXELMAP_ALPHA_TYPE_UNKNOWN); 950 951 // Create a Pixelmap instance. 952 OH_PixelmapNative *startWindowIcon = nullptr; 953 Image_ErrorCode errCode = OH_PixelmapNative_CreatePixelmap(data, dataSize, createOpts, &startWindowIcon); 954 if (errCode != IMAGE_SUCCESS) { 955 // Record error logs and other service processing. 956 957 // Destroy createOpts to prevent memory leakage. 958 OH_PixelmapInitializationOptions_Release(createOpts); 959 return; 960 } 961 962 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 963 if (options == nullptr) { 964 // Record error logs and other service processing. 965 966 // Destroy createOpts to prevent memory leakage. 967 OH_PixelmapInitializationOptions_Release(createOpts); 968 969 // Destroy startWindowIcon to prevent memory leakage. 970 OH_PixelmapNative_Release(startWindowIcon); 971 return; 972 } 973 974 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsStartWindowIcon(options, startWindowIcon); 975 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 976 // Record error logs and other service processing. 977 } 978 // Destroy createOpts to prevent memory leakage. 979 OH_PixelmapInitializationOptions_Release(createOpts); 980 981 // Destroy startWindowIcon to prevent memory leakage. 982 OH_PixelmapNative_Release(startWindowIcon); 983 984 // Destroy options to prevent memory leakage. 985 OH_AbilityRuntime_DestroyStartOptions(&options); 986} 987``` 988 989### OH_AbilityRuntime_GetStartOptionsStartWindowIcon() 990 991``` 992AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartWindowIcon(AbilityRuntime_StartOptions *startOptions,OH_PixelmapNative **startWindowIcon) 993``` 994 995**Description** 996 997Obtains the startup icon of the window when the ability is started. 998 999**Since**: 17 1000 1001**Parameters** 1002 1003| Name| Description| 1004| -- | -- | 1005| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1006| OH_PixelmapNative **startWindowIcon | Double pointer to the startup icon of the window.| 1007 1008**Returns** 1009 1010| Type| Description| 1011| -- | -- | 1012| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** or **StartWindowBackgroundColor** is nullptr.| 1013 1014**Example** 1015 1016```cpp 1017#include <AbilityKit/ability_runtime/start_options.h> 1018 1019void demo() 1020{ 1021 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1022 if (options == nullptr) { 1023 // Record error logs and other service processing. 1024 return; 1025 } 1026 1027 OH_PixelmapNative *startWindowIcon = nullptr; 1028 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsStartWindowIcon(options, &startWindowIcon); 1029 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1030 // Record error logs and other service processing. 1031 } 1032 1033 // Destroy startWindowIcon to prevent memory leakage. 1034 OH_PixelmapNative_Release(startWindowIcon); 1035 1036 // Destroy options to prevent memory leakage. 1037 OH_AbilityRuntime_DestroyStartOptions(&options); 1038} 1039``` 1040 1041### OH_AbilityRuntime_SetStartOptionsStartWindowBackgroundColor() 1042 1043``` 1044AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsStartWindowBackgroundColor(AbilityRuntime_StartOptions *startOptions, const char *startWindowBackgroundColor) 1045``` 1046 1047**Description** 1048 1049Sets the background color of the window when the ability is started. If this property is not set, the value of **startWindowBackground** configured under [abilities](../../quick-start/module-configuration-file.md#abilities) in the [module.json5](../../quick-start/module-configuration-file.md) file corresponding to the UIAbility is used by default. 1050 1051**Since**: 17 1052 1053**Parameters** 1054 1055| Name| Description| 1056| -- | -- | 1057| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1058| const char *startWindowBackgroundColor | Pointer to the background color of the window. The value is in ARGB format, for example, **#E5FFFFFF**.| 1059 1060**Returns** 1061 1062| Type| Description| 1063| -- | -- | 1064| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **StartWindowBackgroundColor** is not nullptr.| 1065 1066**Example** 1067 1068```cpp 1069#include <AbilityKit/ability_runtime/start_options.h> 1070 1071void demo() 1072{ 1073 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1074 if (options == nullptr) { 1075 // Record error logs and other service processing. 1076 return; 1077 } 1078 1079 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsStartWindowBackgroundColor(options, "#00000000"); 1080 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1081 // Record error logs and other service processing. 1082 } 1083 1084 // Destroy options to prevent memory leakage. 1085 OH_AbilityRuntime_DestroyStartOptions(&options); 1086} 1087``` 1088 1089### OH_AbilityRuntime_GetStartOptionsStartWindowBackgroundColor() 1090 1091``` 1092AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsStartWindowBackgroundColor(AbilityRuntime_StartOptions *startOptions, char **startWindowBackgroundColor, size_t &size) 1093``` 1094 1095**Description** 1096 1097Obtains the background color of the window when the ability is started. 1098 1099**Since**: 17 1100 1101 1102**Parameters** 1103 1104| Name| Description| 1105| -- | -- | 1106| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1107| char **startWindowBackgroundColor | Double pointer to the background color of the window. The value is in ARGB format, for example, **#E5FFFFFF**.| 1108| size_t &size | Size of the background color.| 1109 1110**Returns** 1111 1112| Type| Description| 1113| -- | -- | 1114| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** or **SupportedWindowModes** is nullptr, or **Size** is **0**.<br>**ABILITY_RUNTIME_ERROR_CODE_INTERNAL**: An internal error that cannot be rectified, such as internal malloc error or string copy function error, occurs.| 1115 1116**Example** 1117 1118```cpp 1119#include <cstdlib> 1120 1121#include <AbilityKit/ability_runtime/start_options.h> 1122 1123void demo() 1124{ 1125 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1126 if (options == nullptr) { 1127 // Record error logs and other service processing. 1128 return; 1129 } 1130 1131 char *startWindowBackgroundColor = nullptr; 1132 size_t size = 0; 1133 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsStartWindowBackgroundColor(options, 1134 &startWindowBackgroundColor, size); 1135 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1136 // Record error logs and other service processing. 1137 } 1138 1139 if (startWindowBackgroundColor != nullptr) { 1140 // Destroy startWindowBackgroundColor to prevent memory leakage. 1141 free(startWindowBackgroundColor); 1142 startWindowBackgroundColor = nullptr; 1143 } 1144 1145 // Destroy options to prevent memory leakage. 1146 OH_AbilityRuntime_DestroyStartOptions(&options); 1147} 1148``` 1149 1150### OH_AbilityRuntime_SetStartOptionsSupportedWindowModes() 1151 1152``` 1153AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsSupportedWindowModes(AbilityRuntime_StartOptions *startOptions, AbilityRuntime_SupportedWindowMode *supportedWindowModes,size_t size) 1154``` 1155 1156**Description** 1157 1158Sets the window modes supported by the ability when it is started. 1159 1160 1161**Since**: 17 1162 1163**Parameters** 1164 1165| Name| Description| 1166| -- | -- | 1167| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1168| [AbilityRuntime_SupportedWindowMode](capi-context-constant-h.md#abilityruntime_supportedwindowmode) *supportedWindowModes | Pointer to the window modes supported. For details about the available options, see **AbilityRuntime_SupportedWindowMode**.| 1169| size_t size | Size of the window modes supported.| 1170 1171**Returns** 1172 1173| Type| Description| 1174| -- | -- | 1175| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** or **SupportedWindowModes** is nullptr, or **Size** is **0**.| 1176 1177**Example** 1178 1179```cpp 1180#include <AbilityKit/ability_runtime/start_options.h> 1181 1182void demo() 1183{ 1184 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1185 if (options == nullptr) { 1186 // Record error logs and other service processing. 1187 return; 1188 } 1189 1190 size_t supportedWindowModesSize = 3; 1191 AbilityRuntime_SupportedWindowMode supportedWindowModes[3] = { 1192 ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FULL_SCREEN, 1193 ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_SPLIT, 1194 ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FLOATING, 1195 }; 1196 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsSupportedWindowModes(options, 1197 supportedWindowModes, supportedWindowModesSize); 1198 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1199 // Record error logs and other service processing. 1200 } 1201 1202 // Destroy options to prevent memory leakage. 1203 OH_AbilityRuntime_DestroyStartOptions(&options); 1204} 1205``` 1206 1207### OH_AbilityRuntime_GetStartOptionsSupportedWindowModes() 1208 1209``` 1210AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsSupportedWindowModes(AbilityRuntime_StartOptions *startOptions, AbilityRuntime_SupportedWindowMode **supportedWindowModes,size_t &size) 1211``` 1212 1213**Description** 1214 1215Obtains the window modes supported by the ability when it is started. 1216 1217**Since**: 17 1218 1219**Parameters** 1220 1221| Name| Description| 1222| -- | -- | 1223| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1224| [AbilityRuntime_SupportedWindowMode](capi-context-constant-h.md#abilityruntime_supportedwindowmode) **supportedWindowModes | Double pointer to the window modes supported. For details about the available options, see **AbilityRuntime_SupportedWindowMode**.| 1225| size | Size of the window modes supported.| 1226 1227**Returns** 1228 1229| Type| Description| 1230| -- | -- | 1231| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr, or **SupportWindowMode** is not nullptr.<br>**ABILITY_RUNTIME_ERROR_CODE_INTERNAL**: An internal error that cannot be rectified, such as internal malloc error, occurs.| 1232 1233**Example** 1234 1235```cpp 1236#include <cstdlib> 1237 1238#include <AbilityKit/ability_runtime/start_options.h> 1239 1240void demo() 1241{ 1242 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1243 if (options == nullptr) { 1244 // Record error logs and other service processing. 1245 return; 1246 } 1247 1248 AbilityRuntime_SupportedWindowMode *supportedWindowModes = nullptr; 1249 size_t size = 0; 1250 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsSupportedWindowModes(options, 1251 &supportedWindowModes, size); 1252 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1253 // Record error logs and other service processing. 1254 } 1255 1256 if (supportedWindowModes != nullptr) { 1257 // Destroy supportedWindowModes to prevent memory leakage. 1258 free(supportedWindowModes); 1259 } 1260 1261 // Destroy options to prevent memory leakage. 1262 OH_AbilityRuntime_DestroyStartOptions(&options); 1263} 1264``` 1265 1266### OH_AbilityRuntime_SetStartOptionsMinWindowWidth() 1267 1268``` 1269AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMinWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t minWindowWidth) 1270``` 1271 1272**Description** 1273 1274Sets the minimum width of the window when the ability is started, in vp. 1275 1276**Since**: 17 1277 1278 1279**Parameters** 1280 1281| Name| Description| 1282| -- | -- | 1283| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1284| int32_t minWindowWidth | Minimum width of the window, in vp.| 1285 1286**Returns** 1287 1288| Type| Description| 1289| -- | -- | 1290| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1291 1292**Example** 1293 1294```cpp 1295#include <AbilityKit/ability_runtime/start_options.h> 1296 1297void demo() 1298{ 1299 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1300 if (options == nullptr) { 1301 // Record error logs and other service processing. 1302 return; 1303 } 1304 1305 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsMinWindowWidth(options, 100); 1306 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1307 // Record error logs and other service processing. 1308 } 1309 1310 // Destroy options to prevent memory leakage. 1311 OH_AbilityRuntime_DestroyStartOptions(&options); 1312} 1313``` 1314 1315### OH_AbilityRuntime_GetStartOptionsMinWindowWidth() 1316 1317``` 1318AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMinWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t &minWindowWidth) 1319``` 1320 1321**Description** 1322 1323Obtains the minimum width of the window when the ability is started, in vp. 1324 1325**Since**: 17 1326 1327**Parameters** 1328 1329| Name| Description| 1330| -- | -- | 1331| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1332| int32_t &minWindowWidth | Minimum width of the window, in vp.| 1333 1334**Returns** 1335 1336| Type| Description| 1337| -- | -- | 1338| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1339 1340**Example** 1341 1342```cpp 1343#include <AbilityKit/ability_runtime/start_options.h> 1344 1345void demo() 1346{ 1347 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1348 if (options == nullptr) { 1349 // Record error logs and other service processing. 1350 return; 1351 } 1352 1353 int32_t minWindowWidth = 0; 1354 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsMinWindowWidth(options, minWindowWidth); 1355 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1356 // Record error logs and other service processing. 1357 } 1358 1359 // Destroy options to prevent memory leakage. 1360 OH_AbilityRuntime_DestroyStartOptions(&options); 1361} 1362``` 1363 1364### OH_AbilityRuntime_SetStartOptionsMaxWindowWidth() 1365 1366``` 1367AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMaxWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t maxWindowWidth) 1368``` 1369 1370**Description** 1371 1372Sets the maximum width of the window when the ability is started, in vp. 1373 1374**Since**: 17 1375 1376 1377**Parameters** 1378 1379| Name| Description| 1380| -- | -- | 1381| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1382| int32_t maxWindowWidth | Maximum width of the window, in vp.| 1383 1384**Returns** 1385 1386| Type| Description| 1387| -- | -- | 1388| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1389 1390**Example** 1391 1392```cpp 1393#include <AbilityKit/ability_runtime/start_options.h> 1394 1395void demo() 1396{ 1397 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1398 if (options == nullptr) { 1399 // Record error logs and other service processing. 1400 return; 1401 } 1402 1403 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsMaxWindowWidth(options, 100); 1404 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1405 // Record error logs and other service processing. 1406 } 1407 1408 // Destroy options to prevent memory leakage. 1409 OH_AbilityRuntime_DestroyStartOptions(&options); 1410} 1411``` 1412 1413### OH_AbilityRuntime_GetStartOptionsMaxWindowWidth() 1414 1415``` 1416AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMaxWindowWidth(AbilityRuntime_StartOptions *startOptions, int32_t &maxWindowWidth) 1417``` 1418 1419**Description** 1420 1421Obtains the maximum width of the window when the ability is started, in vp. 1422 1423**Since**: 17 1424 1425 1426**Parameters** 1427 1428| Name| Description| 1429| -- | -- | 1430| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1431| int32_t &maxWindowWidth | Maximum width of the window, in vp.| 1432 1433**Returns** 1434 1435| Type| Description| 1436| -- | -- | 1437| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1438 1439**Example** 1440 1441```cpp 1442#include <AbilityKit/ability_runtime/start_options.h> 1443 1444void demo() 1445{ 1446 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1447 if (options == nullptr) { 1448 // Record error logs and other service processing. 1449 return; 1450 } 1451 1452 int32_t maxWindowWidth = 0; 1453 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsMaxWindowWidth(options, maxWindowWidth); 1454 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1455 // Record error logs and other service processing. 1456 } 1457 1458 // Destroy options to prevent memory leakage. 1459 OH_AbilityRuntime_DestroyStartOptions(&options); 1460} 1461``` 1462 1463### OH_AbilityRuntime_SetStartOptionsMinWindowHeight() 1464 1465``` 1466AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMinWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t minWindowHeight) 1467``` 1468 1469**Description** 1470 1471Sets the minimum height of the window when the ability is started, in vp. 1472 1473**Since**: 17 1474 1475**Parameters** 1476 1477| Name| Description| 1478| -- | -- | 1479| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1480| int32_t minWindowHeight | Minimum height of the window, in vp.| 1481 1482**Returns** 1483 1484| Type| Description| 1485| -- | -- | 1486| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1487 1488**Example** 1489 1490```cpp 1491#include <AbilityKit/ability_runtime/start_options.h> 1492 1493void demo() 1494{ 1495 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1496 if (options == nullptr) { 1497 // Record error logs and other service processing. 1498 return; 1499 } 1500 1501 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsMinWindowHeight(options, 100); 1502 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1503 // Record error logs and other service processing. 1504 } 1505 1506 // Destroy options to prevent memory leakage. 1507 OH_AbilityRuntime_DestroyStartOptions(&options); 1508} 1509``` 1510 1511### OH_AbilityRuntime_GetStartOptionsMinWindowHeight() 1512 1513``` 1514AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMinWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t &minWindowHeight) 1515``` 1516 1517**Description** 1518 1519Obtains the minimum height of the window when the ability is started, in vp. 1520 1521**Since**: 17 1522 1523 1524**Parameters** 1525 1526| Name| Description| 1527| -- | -- | 1528| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1529| int32_t &minWindowHeight | Minimum height of the window, in vp.| 1530 1531**Returns** 1532 1533| Type| Description| 1534| -- | -- | 1535| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1536 1537**Example** 1538 1539```cpp 1540#include <AbilityKit/ability_runtime/start_options.h> 1541 1542void demo() 1543{ 1544 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1545 if (options == nullptr) { 1546 // Record error logs and other service processing. 1547 return; 1548 } 1549 1550 int32_t minWindowHeight = 0; 1551 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsMinWindowHeight(options, minWindowHeight); 1552 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1553 // Record error logs and other service processing. 1554 } 1555 1556 // Destroy options to prevent memory leakage. 1557 OH_AbilityRuntime_DestroyStartOptions(&options); 1558} 1559``` 1560 1561### OH_AbilityRuntime_SetStartOptionsMaxWindowHeight() 1562 1563``` 1564AbilityRuntime_ErrorCode OH_AbilityRuntime_SetStartOptionsMaxWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t maxWindowHeight) 1565``` 1566 1567**Description** 1568 1569Sets the maximum height of the window when the ability is started, in vp. 1570 1571**Since**: 17 1572 1573 1574**Parameters** 1575 1576| Name| Description| 1577| -- | -- | 1578| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1579| int32_t maxWindowHeight | Maximum height of the window, in vp.| 1580 1581**Returns** 1582 1583| Type| Description| 1584| -- | -- | 1585| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1586 1587**Example** 1588 1589```cpp 1590#include <AbilityKit/ability_runtime/start_options.h> 1591 1592void demo() 1593{ 1594 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1595 if (options == nullptr) { 1596 // Record error logs and other service processing. 1597 return; 1598 } 1599 1600 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_SetStartOptionsMaxWindowHeight(options, 100); 1601 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1602 // Record error logs and other service processing. 1603 } 1604 1605 // Destroy options to prevent memory leakage. 1606 OH_AbilityRuntime_DestroyStartOptions(&options); 1607} 1608``` 1609 1610### OH_AbilityRuntime_GetStartOptionsMaxWindowHeight() 1611 1612``` 1613AbilityRuntime_ErrorCode OH_AbilityRuntime_GetStartOptionsMaxWindowHeight(AbilityRuntime_StartOptions *startOptions, int32_t &maxWindowHeight) 1614``` 1615 1616**Description** 1617 1618Obtains the maximum height of the window when the ability is started, in vp. 1619 1620**Since**: 17 1621 1622 1623**Parameters** 1624 1625| Name| Description| 1626| -- | -- | 1627| [AbilityRuntime_StartOptions](capi-abilityruntime-startoptions.md) *startOptions | Pointer to an AbilityRuntime_StartOptions object.| 1628| int32_t &maxWindowHeight | Maximum height of the window, in vp.| 1629 1630**Returns** 1631 1632| Type| Description| 1633| -- | -- | 1634| [AbilityRuntime_ErrorCode](capi-ability-runtime-common-h.md#abilityruntime_errorcode) | **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR**: The call is successful.<br>**ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID**: The input parameter **StartOptions** is nullptr.| 1635 1636**Example** 1637 1638```cpp 1639#include <AbilityKit/ability_runtime/start_options.h> 1640 1641void demo() 1642{ 1643 AbilityRuntime_StartOptions* options = OH_AbilityRuntime_CreateStartOptions(); 1644 if (options == nullptr) { 1645 // Record error logs and other service processing. 1646 return; 1647 } 1648 1649 int32_t maxWindowHeight = 0; 1650 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_GetStartOptionsMaxWindowHeight(options, maxWindowHeight); 1651 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 1652 // Record error logs and other service processing. 1653 } 1654 1655 // Destroy options to prevent memory leakage. 1656 OH_AbilityRuntime_DestroyStartOptions(&options); 1657} 1658``` 1659