Browse Source

update winos docs

ruki 2 weeks ago
parent
commit
8ddd91ecc2

+ 73 - 0
docs/api/scripts/builtin-modules/winos.md

@@ -52,6 +52,79 @@ win81 = "6.3"
 win10 = "10.0"
 ```
 
+## winos.processes
+
+- Get current system process list
+
+#### Function Prototype
+
+::: tip API
+```lua
+winos.processes()
+```
+:::
+
+#### Parameter Description
+
+No parameters required for this function.
+
+#### Return Value
+
+Returns an array, each element is a process info table:
+
+| Field | Description |
+|-------|-------------|
+| name | Process executable name |
+| pid | Process id |
+| parent_pid | Parent process id |
+
+Returns nil on non-Windows platforms.
+
+#### Usage
+
+```lua
+local processes = winos.processes()
+if processes then
+    for _, p in ipairs(processes) do
+        print(p.pid, p.parent_pid, p.name)
+    end
+end
+```
+
+## winos.set_error_mode
+
+- Set Windows process error mode
+
+#### Function Prototype
+
+::: tip API
+```lua
+winos.set_error_mode(mode: <integer>)
+```
+:::
+
+#### Parameter Description
+
+| Parameter | Description |
+|-----------|-------------|
+| mode | Process error mode value (Windows API `SetErrorMode`) |
+
+#### Return Value
+
+Returns the previous error mode value.
+
+#### Usage
+
+Disable system error dialogs (e.g. critical errors, GP fault, open-file error dialogs):
+
+```lua
+local SEM_FAILCRITICALERRORS     = 0x0001
+local SEM_NOGPFAULTERRORBOX      = 0x0002
+local SEM_NOOPENFILEERRORBOX     = 0x8000
+
+local oldmode = winos.set_error_mode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX)
+```
+
 ## winos.registry_keys
 
 - Get the list of registry builds

+ 73 - 0
docs/zh/api/scripts/builtin-modules/winos.md

@@ -53,6 +53,79 @@ win81    = "6.3"
 win10    = "10.0"
 ```
 
+## winos.processes
+
+- 获取当前系统进程列表
+
+#### 函数原型
+
+::: tip API
+```lua
+winos.processes()
+```
+:::
+
+#### 参数说明
+
+此函数不需要参数。
+
+#### 返回值
+
+返回一个数组,每个元素是一个进程信息表:
+
+| 字段 | 描述 |
+|------|------|
+| name | 进程可执行文件名 |
+| pid | 进程 id |
+| parent_pid | 父进程 id |
+
+非 Windows 平台返回 nil。
+
+#### 用法说明
+
+```lua
+local processes = winos.processes()
+if processes then
+    for _, p in ipairs(processes) do
+        print(p.pid, p.parent_pid, p.name)
+    end
+end
+```
+
+## winos.set_error_mode
+
+- 设置 Windows 进程错误模式
+
+#### 函数原型
+
+::: tip API
+```lua
+winos.set_error_mode(mode: <integer>)
+```
+:::
+
+#### 参数说明
+
+| 参数 | 描述 |
+|------|------|
+| mode | 进程错误模式值(对应 Windows API `SetErrorMode`) |
+
+#### 返回值
+
+返回之前的错误模式值。
+
+#### 用法说明
+
+禁用系统错误弹窗(例如:关键错误、GP fault、打开文件失败对话框等):
+
+```lua
+local SEM_FAILCRITICALERRORS     = 0x0001
+local SEM_NOGPFAULTERRORBOX      = 0x0002
+local SEM_NOOPENFILEERRORBOX     = 0x8000
+
+local oldmode = winos.set_error_mode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX)
+```
+
 ## winos.registry_keys
 
 - 获取注册表建列表