@@ -160,18 +160,22 @@ static bool getTerminalFromEnv(FFTerminalResult* result) {
160160static bool detectDefaultTerminal (FFTerminalResult * result ) {
161161 wchar_t regPath [128 ] = L"SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\" ;
162162 wchar_t * uuid = regPath + strlen ("SOFTWARE\\Classes\\PackagedCom\\ClassIndex\\" );
163- DWORD bufSize = 80 ;
164- if (RegGetValueW (HKEY_CURRENT_USER , L"Console\\%%Startup" , L"DelegationTerminal" , RRF_RT_REG_SZ , NULL , uuid , & bufSize ) == ERROR_SUCCESS ) {
163+ FF_AUTO_CLOSE_FD HANDLE hkcu = NULL ;
164+ if (ffRegOpenKeyForRead (HKEY_CURRENT_USER , L"Console\\%%Startup" , & hkcu , NULL ) &&
165+ ffRegReadData (hkcu , L"DelegationTerminal" , & (FFArgBuffer ) {
166+ .data = uuid ,
167+ .length = (uint32_t ) (sizeof (regPath ) - (size_t ) (uuid - regPath ) * sizeof (wchar_t )),
168+ }, NULL )) {
165169 if (wcscmp (uuid , L"{00000000-0000-0000-0000-000000000000}" ) == 0 || // Let Windows decide
166170 wcscmp (uuid , L"{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}" ) == 0 ) // Conhost
167171 {
168172 goto conhost ;
169173 }
170174
171- FF_AUTO_CLOSE_FD HANDLE hKey = NULL ;
172- if (ffRegOpenKeyForRead (HKEY_LOCAL_MACHINE , regPath , & hKey , NULL )) {
175+ FF_AUTO_CLOSE_FD HANDLE hklm = NULL ;
176+ if (ffRegOpenKeyForRead (HKEY_LOCAL_MACHINE , regPath , & hklm , NULL )) {
173177 FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate ();
174- if (ffRegGetSubKey (hKey , 0 , & path , NULL )) {
178+ if (ffRegGetSubKey (hklm , 0 , & path , NULL )) {
175179 if (ffStrbufStartsWithS (& path , "Microsoft.WindowsTerminal" )) {
176180 ffStrbufSetS (& result -> processName , "WindowsTerminal.exe" );
177181 ffStrbufSetS (& result -> prettyName , "WindowsTerminal" );
0 commit comments