summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
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/tclWinInit.c
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/tclWinInit.c')
-rw-r--r--win/tclWinInit.c20
1 files changed, 6 insertions, 14 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);