@@ -171,20 +171,24 @@ HANDLE LoadConptyDll(const Napi::CallbackInfo& info,
171171 return LoadLibraryExW (L" kernel32.dll" , 0 , 0 );
172172 }
173173 wchar_t currentDir[MAX_PATH];
174- DWORD result = GetCurrentDirectoryW (MAX_PATH, currentDir);
174+ HMODULE hModule = GetModuleHandleA (" conpty.node" );
175+ if (hModule == NULL ) {
176+ throw errorWithCode (info, " Failed to get conpty.node module handle" );
177+ }
178+ DWORD result = GetModuleFileNameW (hModule, currentDir, MAX_PATH);
175179 if (result == 0 ) {
176- throw errorWithCode (info, " Failed to get current directory " );
180+ throw errorWithCode (info, " Failed to get conpty.node module file name " );
177181 }
178- std::wstring currentDirStr (currentDir);
179-
180- std::wstring conptyDllPath = currentDirStr + L" \\ build \\ Release \\ conpty\\ conpty.dll" ;
182+ PathRemoveFileSpecW (currentDir);
183+ wchar_t conptyDllPath[MAX_PATH];
184+ PathCombineW ( conptyDllPath, currentDir, L" conpty\\ conpty.dll" ) ;
181185 if (!path_util::file_exists (conptyDllPath)) {
182- std::wstring errorMessage = L" Cannot find conpty.dll at " + conptyDllPath;
183- std::string errorMessageStr (errorMessage. begin (), errorMessage. end () );
186+ std::wstring errorMessage = L" Cannot find conpty.dll at " + std::wstring ( conptyDllPath) ;
187+ std::string errorMessageStr = path_util::wstring_to_string (errorMessage );
184188 throw errorWithCode (info, errorMessageStr.c_str ());
185189 }
186190
187- return LoadLibraryW (conptyDllPath. c_str () );
191+ return LoadLibraryW (conptyDllPath);
188192}
189193
190194HRESULT CreateNamedPipesAndPseudoConsole (const Napi::CallbackInfo& info,
0 commit comments