The preference DLLs contain COM objects. Their registry keys are set to
have relative paths. This normally works fine, unless the current working directory is other than that of the default program directory where the pref DLLs are normally located. This could happen by executing the program from a different directory, or by saving a file to a directory other than the default program directory. In order to fix this, we need to push to the program directory just prior to loading a preference COM object, and then pop back. git-svn-id: svn://10.0.0.236/trunk@2002 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2605,4 +2605,29 @@ extern "C" PRBool FE_MakeNetscapeDefault(void) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Use this to create some COM objects, as we need to switch to the
|
||||
// directory where the .EXE sits if the current directory isn't
|
||||
// the same, as the pref COM DLLs have relative paths in the
|
||||
// registry.
|
||||
HRESULT FEU_CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv)
|
||||
{
|
||||
HRESULT hRetval = NULL;
|
||||
|
||||
char aOrigDir[MAX_PATH + 1];
|
||||
DWORD dwCheck = GetCurrentDirectory(sizeof(aOrigDir), aOrigDir);
|
||||
ASSERT(dwCheck);
|
||||
|
||||
char aProgramDir[MAX_PATH + 1];
|
||||
FE_GetProgramDirectory(aProgramDir, sizeof(aProgramDir));
|
||||
|
||||
BOOL bCheck = SetCurrentDirectory(aProgramDir);
|
||||
ASSERT(bCheck);
|
||||
|
||||
hRetval = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
|
||||
|
||||
BOOL bRestoreCheck = SetCurrentDirectory(aOrigDir);
|
||||
ASSERT(bRestoreCheck);
|
||||
|
||||
return(hRetval);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user