{"record":{"id":"16667e59347f283f","repo":"deepseek-ai/deepseek-harness","slug":"cocreateinstance-fileopendialog-failed-hresult-0","errorCode":null,"errorMessage":"CoCreateInstance(FileOpenDialog) failed: HRESULT 0x${(created >>> 0).toString(16)}","messagePattern":"CoCreateInstance\\(FileOpenDialog\\) failed: HRESULT 0x(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/host/directory-picker-native/src/win32-dialog-bindings.ts","lineNumber":144,"sourceCode":"        // legacy 5.1 tree over a cosmetic concern.\n        return\n      }\n      for (const context of DPI_AWARENESS_CONTEXTS) {\n        if (setContext(context) !== null) return\n      }\n      // Unreachable in practice (SYSTEM_AWARE is accepted wherever the symbol\n      // exists); if a host ever refuses everything, the dialog still works —\n      // just without a DPI opt-in.\n    },\n    coInitializeSta: () => coInitializeEx(null, COINIT_APARTMENTTHREADED) as number,\n    coUninitialize: () => {\n      coUninitialize()\n    },\n    currentThreadId: () => getCurrentThreadId() as number,\n    createFolderDialog: (): Win32FolderDialog => {\n      const out = Buffer.alloc(pointerSize)\n      const created = coCreateInstance(CLSID_FILE_OPEN_DIALOG, null, CLSCTX_INPROC_SERVER, IID_IFILE_OPEN_DIALOG, out) as number\n      if (created < 0) throw new Error(`CoCreateInstance(FileOpenDialog) failed: HRESULT 0x${(created >>> 0).toString(16)}`)\n      const dialog = koffi.decode(out, 'void *')\n      return {\n        setOptions: options => method(dialog, SLOT_SET_OPTIONS, protoSetOptions)(options),\n        setTitle: title => method(dialog, SLOT_SET_TITLE, protoSetTitle)(title),\n        show: () => method(dialog, SLOT_SHOW, protoShow)(null),\n        resultPath: () => {\n          const itemOut: unknown[] = [null]\n          const gotItem = method(dialog, SLOT_GET_RESULT, protoGetResult)(itemOut)\n          if (gotItem < 0) return { hr: gotItem }\n          const item = itemOut[0]\n          try {\n            const nameOut: unknown[] = [null]\n            const gotName = method(item, SLOT_GET_DISPLAY_NAME, protoGetDisplayName)(SIGDN_FILESYSPATH, nameOut)\n            if (gotName < 0) return { hr: gotName }\n            const path = readUtf16(koffi, nameOut[0])\n            coTaskMemFree(nameOut[0])\n            return { hr: gotName, path }\n          } finally {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/host/directory-picker-native/src/win32-dialog-bindings.ts#L126-L162","documentation":"Error \"CoCreateInstance(FileOpenDialog) failed: HRESULT 0x${(created >>> 0).toString(16)}\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/host/directory-picker-native/src/win32-dialog-bindings.ts:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}