Skip to content

Commit

Permalink
ci: up
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jun 27, 2024
1 parent b5afdc0 commit e731771
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/win32-api/src/util/winspool/GetPrinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const funcName: keyof LibWinspool = 'GetPrinterW'
/**
* @link https://learn.microsoft.com/zh-cn/windows/win32/printdocs/getprinter
*/
export async function GetPrinter<Level extends PRINTER_INFO_LEVEL>(options: GetPrinterOptions<Level>): Promise<PRINTER_INFO_X_Type<Level>> {
export async function GetPrinter<Level extends PRINTER_INFO_LEVEL>(options: GetPrinterOptions<Level>): Promise<PRINTER_INFO_X_Type<Level> | null> {
const { hPrinter, Level, maxLength = 1024 } = options

const lib = load([funcName])
Expand All @@ -31,7 +31,10 @@ export async function GetPrinter<Level extends PRINTER_INFO_LEVEL>(options: GetP
)
const pcb = pcbNeeded.readUInt32LE()
if (! ret) {
throw new Error(`maxLength is too small, increase to value grater than ${pcb}`)
if (pcb > maxLength) {
throw new Error(`maxLength is too small, increase to value grater than ${pcb}`)
}
return null
}

return pPrinter
Expand Down

0 comments on commit e731771

Please sign in to comment.