summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-03 15:27:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-03 15:27:06 (GMT)
commitd329be0030f6800be40dc3606491b8880814d336 (patch)
treeeae05bcb0f55d1af06cb30d2735d6329ed87a379 /win
parentcfdf3d1f29001198f2afdea91a595527acdc2802 (diff)
parent1c8d056c93bd79b5356acb7646a97a97deb710b5 (diff)
downloadtcl-d329be0030f6800be40dc3606491b8880814d336.zip
tcl-d329be0030f6800be40dc3606491b8880814d336.tar.gz
tcl-d329be0030f6800be40dc3606491b8880814d336.tar.bz2
Use GetModuleHandle() in stead of LoadLibrary() when the handle is needed for an already loaded dll.
Fix filesystem-1.52 (only works correctly on UNIX)
Diffstat (limited to 'win')
-rw-r--r--win/tclWinInit.c20
-rw-r--r--win/tclWinInt.h2
-rw-r--r--win/tclWinPipe.c4
-rw-r--r--win/tclWinReg.c10
4 files changed, 13 insertions, 23 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index f13e314..98c7ed5 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -80,10 +80,7 @@ typedef struct {
/*
* Windows version dependend functions
*/
-static TclWinProcs _tclWinProcs = {
- NULL
-};
-TclWinProcs *tclWinProcs = &_tclWinProcs;
+TclWinProcs tclWinProcs;
/*
* The following arrays contain the human readable strings for the Windows
@@ -141,7 +138,7 @@ TclpInitPlatform(void)
{
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 2);
- HINSTANCE hInstance;
+ HMODULE handle;
tclPlatform = TCL_PLATFORM_WINDOWS;
@@ -164,12 +161,10 @@ TclpInitPlatform(void)
/*
* Fill available functions depending on windows version
*/
- hInstance = LoadLibraryW(L"kernel32");
- if (hInstance != NULL) {
- _tclWinProcs.cancelSynchronousIo =
- (BOOL (WINAPI *)(HANDLE)) GetProcAddress(hInstance,
+ handle = GetModuleHandle(TEXT("KERNEL32"));
+ tclWinProcs.cancelSynchronousIo =
+ (BOOL (WINAPI *)(HANDLE)) GetProcAddress(handle,
"CancelSynchronousIo");
- }
}
/*
@@ -556,16 +551,13 @@ TclpSetVariables(
TclGetProcessGlobalValue(&defaultLibraryDir), TCL_GLOBAL_ONLY);
if (!osInfoInitialized) {
- HANDLE handle = LoadLibraryW(L"NTDLL");
+ HMODULE handle = GetModuleHandle(TEXT("NTDLL"));
int(__stdcall *getversion)(void *) =
(int(__stdcall *)(void *)) GetProcAddress(handle, "RtlGetVersion");
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
if (!getversion || getversion(&osInfo)) {
GetVersionExW(&osInfo);
}
- if (handle) {
- FreeLibrary(handle);
- }
osInfoInitialized = 1;
}
GetSystemInfo(&sys.info);
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index 76f5f68..43799d0 100644
--- a/win/tclWinInt.h
+++ b/win/tclWinInt.h
@@ -38,7 +38,7 @@ typedef struct TclWinProcs {
BOOL (WINAPI *cancelSynchronousIo)(HANDLE);
} TclWinProcs;
-MODULE_SCOPE TclWinProcs *tclWinProcs;
+MODULE_SCOPE TclWinProcs tclWinProcs;
/*
* Some versions of Borland C have a define for the OSVERSIONINFO for
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 4a1e75a..3e7e5eb 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -3329,8 +3329,8 @@ TclPipeThreadStop(
/*
* Cancel all sync-IO of this thread (may be blocked there).
*/
- if (tclWinProcs->cancelSynchronousIo) {
- tclWinProcs->cancelSynchronousIo(hThread);
+ if (tclWinProcs.cancelSynchronousIo) {
+ tclWinProcs.cancelSynchronousIo(hThread);
}
/*
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 5f7fd31..de48b9b 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -1197,14 +1197,12 @@ RecursiveDeleteKey(
*/
if (mode && !checkExProc) {
- HINSTANCE dllH;
+ HMODULE handle;
checkExProc = 1;
- dllH = LoadLibrary(TEXT("advapi32.dll"));
- if (dllH) {
- regDeleteKeyExProc = (FARPROC)
- GetProcAddress(dllH, "RegDeleteKeyExW");
- }
+ handle = GetModuleHandle(TEXT("ADVAPI32"));
+ regDeleteKeyExProc = (FARPROC)
+ GetProcAddress(handle, "RegDeleteKeyExW");
}
if (mode && regDeleteKeyExProc) {
result = regDeleteKeyExProc(startKey, keyName, mode, 0);