Add current directory to path so pref dlls and nspr are looked for in

the dll directory, not the application directory.
This commit is contained in:
scullin%netscape.com 1998-11-04 03:04:10 +00:00
Родитель 993e891171
Коммит 118478d446
1 изменённых файлов: 26 добавлений и 3 удалений

Просмотреть файл

@ -21,6 +21,8 @@
#include <olectl.h>
#include <tchar.h>
#include "factory.h"
#include "plstr.h"
#include "prmem.h"
#pragma data_seg(".text")
#define INITGUID
@ -41,9 +43,30 @@ extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance,
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
break;
case DLL_PROCESS_ATTACH: {
g_hInst = hInstance;
// Get dll directory
char binpath[_MAX_PATH];
::GetModuleFileName(g_hInst, binpath, _MAX_PATH);
char *lastslash = PL_strrchr(binpath, '\\');
if (lastslash) *lastslash = '\0';
// Get existing search path
int len = GetEnvironmentVariable("PATH", NULL, 0);
char *newpath = (char *) PR_Malloc(sizeof(char) * (len +
PL_strlen(binpath) +
2)); // ';' + '\0'
GetEnvironmentVariable("PATH", newpath, len + 1);
PL_strcat(newpath, ";");
PL_strcat(newpath, binpath);
// Set new search path
SetEnvironmentVariable("PATH", newpath);
// Clean up
PR_Free(newpath);
}
break;
case DLL_PROCESS_DETACH:
break;