summaryrefslogtreecommitdiffstats
path: root/win/tclWin32Dll.c
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1998-04-29 17:10:26 (GMT)
committerstanton <stanton@noemail.net>1998-04-29 17:10:26 (GMT)
commita331546c354a563ac0877292f5ceb59ccf3349c5 (patch)
treeb15deaf776141290d611f97a9282358798b346c3 /win/tclWin32Dll.c
parent51e324c9f43c7cc0a6038f91a06395c0395efa52 (diff)
downloadtcl-a331546c354a563ac0877292f5ceb59ccf3349c5.zip
tcl-a331546c354a563ac0877292f5ceb59ccf3349c5.tar.gz
tcl-a331546c354a563ac0877292f5ceb59ccf3349c5.tar.bz2
added TclWinInit and TclpFinalize
FossilOrigin-Name: b9d8955be11d70b6d76957eb5cf0db120ff292e4
Diffstat (limited to 'win/tclWin32Dll.c')
-rw-r--r--win/tclWin32Dll.c127
1 files changed, 80 insertions, 47 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 3abc97e..92dae25 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -104,72 +104,105 @@ DllMain(hInst, reason, reserved)
DWORD reason; /* Reason this function is being called. */
LPVOID reserved; /* Not used. */
{
- OSVERSIONINFO os;
-
switch (reason) {
case DLL_PROCESS_ATTACH:
-
- /*
- * Registration of UT need to be done only once for first
- * attaching process. At that time set the tclWin32s flag
- * to indicate if the DLL is executing under Win32s or not.
- */
-
if (tclProcessesAttached++) {
return FALSE; /* Not the first initialization. */
}
- tclInstance = hInst;
- os.dwOSVersionInfoSize = sizeof(os);
- GetVersionEx(&os);
- tclPlatformId = os.dwPlatformId;
-
- /*
- * The following code stops Windows 3.x from automatically putting
- * up Sharing Violation dialogs, e.g, when someone tries to
- * access a file that is locked or a drive with no disk in it.
- * Tcl already returns the appropriate error to the caller, and they
- * can decide to put up their own dialog in response to that failure.
- *
- * Under 95 and NT, the system doesn't automatically put up dialogs
- * when the above operations fail.
- */
-
- if (tclPlatformId == VER_PLATFORM_WIN32s) {
- SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS);
- }
-
+ TclWinInit(hInst);
return TRUE;
case DLL_PROCESS_DETACH:
tclProcessesAttached--;
if (tclProcessesAttached == 0) {
+ Tcl_Finalize();
+ }
+ break;
+ }
- /*
- * Unregister the Tcl thunk.
- */
-
- if (UTUnRegister != NULL) {
- UTUnRegister(hInst);
- }
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclWinInit --
+ *
+ * This function initializes the internal state of the tcl library.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Initializes the 16-bit thunking library, and the tclPlatformId
+ * variable.
+ *
+ *----------------------------------------------------------------------
+ */
- /*
- * Cleanup any dynamically loaded libraries.
- */
+void
+TclWinInit(hInst)
+ HINSTANCE hInst; /* Library instance handle. */
+{
+ OSVERSIONINFO os;
- UnloadLibraries();
+ tclInstance = hInst;
+ os.dwOSVersionInfoSize = sizeof(os);
+ GetVersionEx(&os);
+ tclPlatformId = os.dwPlatformId;
+
+ /*
+ * The following code stops Windows 3.x from automatically putting
+ * up Sharing Violation dialogs, e.g, when someone tries to
+ * access a file that is locked or a drive with no disk in it.
+ * Tcl already returns the appropriate error to the caller, and they
+ * can decide to put up their own dialog in response to that failure.
+ *
+ * Under 95 and NT, the system doesn't automatically put up dialogs
+ * when the above operations fail.
+ */
+
+ if (tclPlatformId == VER_PLATFORM_WIN32s) {
+ SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpFinalize --
+ *
+ * Clean up the Windows specific library state.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Unloads any DLLs and cleans up the thunking library, if
+ * necessary.
+ *
+ *----------------------------------------------------------------------
+ */
- /*
- * And finally finalize our use of Tcl.
- */
+void
+TclpFinalize()
+{
+ /*
+ * Unregister the Tcl thunk.
+ */
- Tcl_Finalize();
- }
- break;
+ if (UTUnRegister != NULL) {
+ UTUnRegister(tclInstance);
+ UTUnRegister = NULL;
}
- return TRUE;
+ /*
+ * Cleanup any dynamically loaded libraries.
+ */
+
+ UnloadLibraries();
}
/*