1e41f4b71Sopenharmony_ci# @ohos.app.ability.ChildProcessArgs 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci传递到子进程的参数。[childProcessManager](js-apis-app-ability-childProcessManager.md)启动子进程时,可以通过ChildProcessArgs传递参数到子进程中。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 12开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> 本模块接口仅可在Stage模型下使用。 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## 导入模块 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```ts 14e41f4b71Sopenharmony_ciimport { ChildProcessArgs } from '@kit.AbilityKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## 属性 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 22e41f4b71Sopenharmony_ci| ----------- | -------------------- | ---- | ------------------------------------------------------------ | 23e41f4b71Sopenharmony_ci| entryParams | string | 否 | 开发者自定义参数,透传到子进程中。可以在[ChildProcess.onStart](js-apis-app-ability-childProcess.md#childprocessonstart)方法中通过args.entryParams获取,entryParams支持传输的最大数据量为150KB。| 24e41f4b71Sopenharmony_ci| fds | Record<string, number> | 否 | 文件描述符句柄集合,用于主进程和子进程通信,通过key-value的形式传入到子进程中,其中key为自定义字符串,value为文件描述符句柄。可以在[ChildProcess.onStart](js-apis-app-ability-childProcess.md#childprocessonstart)方法中通过args.fds获取fd句柄。<br/><b>说明:</b> <br>- fds最多支持16组,每组key的最大长度为20字符。<br>- 传递到子进程中句柄数字可能会变,但是指向的文件是一致的。| 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**示例:** 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci```ts 31e41f4b71Sopenharmony_ci// 主进程中: 32e41f4b71Sopenharmony_ciimport { common, ChildProcessArgs, childProcessManager } from '@kit.AbilityKit'; 33e41f4b71Sopenharmony_ciimport fs from '@ohos.file.fs'; 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_cilet context = getContext(this) as common.UIAbilityContext; 36e41f4b71Sopenharmony_cilet path = context.filesDir + "/test.txt"; 37e41f4b71Sopenharmony_cilet file = fs.openSync(path, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE); 38e41f4b71Sopenharmony_cilet args: ChildProcessArgs = { 39e41f4b71Sopenharmony_ci entryParams: "testParam", 40e41f4b71Sopenharmony_ci fds: { 41e41f4b71Sopenharmony_ci "key1": file.fd 42e41f4b71Sopenharmony_ci } 43e41f4b71Sopenharmony_ci}; 44e41f4b71Sopenharmony_cichildProcessManager.startArkChildProcess("entry/./ets/process/DemoProcess.ets", args); 45e41f4b71Sopenharmony_ci``` 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci```ts 48e41f4b71Sopenharmony_ci// 子进程中: 49e41f4b71Sopenharmony_ciimport { ChildProcess, ChildProcessArgs } from '@kit.AbilityKit'; 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ciexport default class DemoProcess extends ChildProcess { 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci onStart(args?: ChildProcessArgs) { 54e41f4b71Sopenharmony_ci let entryParams = args?.entryParams; 55e41f4b71Sopenharmony_ci let fd = args?.fds?.key1; 56e41f4b71Sopenharmony_ci // .. 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci} 59e41f4b71Sopenharmony_ci``` 60