Dialer plugin does not have to unload WinInet

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6648 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2015-11-30 14:00:40 +00:00
parent 726bf760cd
commit 3d0be38e91

View file

@ -16,8 +16,6 @@ BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved
* LOADER * * LOADER *
\*************/ \*************/
HMODULE g_hWinInet = NULL;
HMODULE NSISCALL LoadSystemLibrary(LPCSTR name) { HMODULE NSISCALL LoadSystemLibrary(LPCSTR name) {
LPCTSTR fmt = sizeof(*fmt) > 1 ? TEXT("%s%S.dll") : TEXT("%s%s.dll"); // The module name is always ANSI LPCTSTR fmt = sizeof(*fmt) > 1 ? TEXT("%s%S.dll") : TEXT("%s%s.dll"); // The module name is always ANSI
BYTE bytebuf[(MAX_PATH+1+20+1+3+!0) * sizeof(*fmt)]; // 20+4 is more than enough for BYTE bytebuf[(MAX_PATH+1+20+1+3+!0) * sizeof(*fmt)]; // 20+4 is more than enough for
@ -32,17 +30,10 @@ HMODULE NSISCALL LoadSystemLibrary(LPCSTR name) {
} }
FARPROC GetWinInetFunc(LPCSTR funcname) { FARPROC GetWinInetFunc(LPCSTR funcname) {
g_hWinInet = LoadSystemLibrary("WININET"); HMODULE hWinInet = LoadSystemLibrary("WININET");
if (g_hWinInet) return hWinInet ? GetProcAddress(hWinInet, funcname) : (FARPROC) hWinInet;
return GetProcAddress(g_hWinInet, funcname);
return NULL;
} }
void FreeWinInet() {
if (g_hWinInet)
FreeLibrary(g_hWinInet);
g_hWinInet = NULL;
}
/*************\ /*************\
* FUNCTIONS * * FUNCTIONS *
@ -62,8 +53,6 @@ NSISFunction(AutodialOnline) {
pushstring(_T("online")); pushstring(_T("online"));
else else
pushstring(_T("offline")); pushstring(_T("offline"));
FreeWinInet();
} }
NSISFunction(AutodialUnattended) { NSISFunction(AutodialUnattended) {
@ -80,8 +69,6 @@ NSISFunction(AutodialUnattended) {
pushstring(_T("online")); pushstring(_T("online"));
else else
pushstring(_T("offline")); pushstring(_T("offline"));
FreeWinInet();
} }
NSISFunction(AttemptConnect) { NSISFunction(AttemptConnect) {
@ -98,8 +85,6 @@ NSISFunction(AttemptConnect) {
pushstring(_T("online")); pushstring(_T("online"));
else else
pushstring(_T("offline")); pushstring(_T("offline"));
FreeWinInet();
} }
NSISFunction(GetConnectedState) { NSISFunction(GetConnectedState) {
@ -118,8 +103,6 @@ NSISFunction(GetConnectedState) {
pushstring(_T("online")); pushstring(_T("online"));
else else
pushstring(_T("offline")); pushstring(_T("offline"));
FreeWinInet();
} }
NSISFunction(AutodialHangup) { NSISFunction(AutodialHangup) {
@ -136,6 +119,4 @@ NSISFunction(AutodialHangup) {
pushstring(_T("success")); pushstring(_T("success"));
else else
pushstring(_T("failure")); pushstring(_T("failure"));
FreeWinInet();
} }