ENGINE-305: attempt to get GnuPG paths for Gpg4Win 3.x correct diphoton_M1
authorKrista Bennett <krista@pep-project.org>
Tue, 31 Oct 2017 11:18:23 +0100
branchdiphoton_M1
changeset 2259bac866c8b2c4
parent 2258 340598e126a2
child 2260 1c2211119c4a
ENGINE-305: attempt to get GnuPG paths for Gpg4Win 3.x correct
src/platform_windows.cpp
     1.1 --- a/src/platform_windows.cpp	Fri Oct 27 17:21:25 2017 +0200
     1.2 +++ b/src/platform_windows.cpp	Tue Oct 31 11:18:23 2017 +0100
     1.3 @@ -159,6 +159,26 @@
     1.4          return NULL;
     1.5  
     1.6  	HMODULE module = LoadLibrary(utf16_string(filename).c_str());
     1.7 +
     1.8 +    if (module == NULL) {
     1.9 +        SetDllDirectory(NULL);
    1.10 +        
    1.11 +        int chars_remaining = PATH_BUF_SIZE - strlen(path) - 1;
    1.12 +        int add_len = strlen(TEXT("\\bin");
    1.13 +        if (add_len > chars_remaining)
    1.14 +            return NULL;
    1.15 +            
    1.16 +        strncat(path, TEXT("\\bin"), add_len);
    1.17 +        
    1.18 +        SetDllDirectory(TEXT(""));
    1.19 +        _result = SetDllDirectory(path);
    1.20 +        assert(_result != 0);
    1.21 +        if (_result == 0)
    1.22 +            return NULL;
    1.23 +
    1.24 +    	module = LoadLibrary(utf16_string(filename).c_str());
    1.25 +    }
    1.26 +    
    1.27      SetDllDirectory(NULL);
    1.28  	if (module == NULL)
    1.29  		return NULL;