summaryrefslogtreecommitdiffstats
path: root/win/tclWinReg.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-10-18 23:58:18 (GMT)
committerhobbs <hobbs>2002-10-18 23:58:18 (GMT)
commitb5af65e9d69a52d972ebbcb19fcd5bebd1bdc884 (patch)
treef578423d541f524d5318a0b5e268890697eebffb /win/tclWinReg.c
parent7913e154bd7705f376f1d3991b4050b4ab69b442 (diff)
downloadtcl-b5af65e9d69a52d972ebbcb19fcd5bebd1bdc884.zip
tcl-b5af65e9d69a52d972ebbcb19fcd5bebd1bdc884.tar.gz
tcl-b5af65e9d69a52d972ebbcb19fcd5bebd1bdc884.tar.bz2
* doc/registry.n: Added support for broadcasting changes to
* tests/registry.test: the registry Environment. Noted proper code * win/tclWinReg.c: in the docs. [Patch #625453]
Diffstat (limited to 'win/tclWinReg.c')
-rw-r--r--win/tclWinReg.c79
1 files changed, 76 insertions, 3 deletions
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 6505878..f806fc3 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinReg.c,v 1.17 2002/01/29 03:18:46 hobbs Exp $
+ * RCS: @(#) $Id: tclWinReg.c,v 1.18 2002/10/18 23:58:18 hobbs Exp $
*/
#include <tclPort.h>
@@ -159,6 +159,8 @@ static RegWinProcs unicodeProcs = {
*/
static void AppendSystemError(Tcl_Interp *interp, DWORD error);
+static int BroadcastValue(Tcl_Interp *interp, int objc,
+ Tcl_Obj * CONST objv[]);
static DWORD ConvertDWORD(DWORD type, DWORD value);
static int DeleteKey(Tcl_Interp *interp, Tcl_Obj *keyNameObj);
static int DeleteValue(Tcl_Interp *interp, Tcl_Obj *keyNameObj,
@@ -256,9 +258,12 @@ RegistryObjCmd(
char *errString;
static CONST char *subcommands[] = {
- "delete", "get", "keys", "set", "type", "values", (char *) NULL
+ "broadcast", "delete", "get", "keys", "set", "type", "values",
+ (char *) NULL
+ };
+ enum SubCmdIdx {
+ BroadcastIdx, DeleteIdx, GetIdx, KeysIdx, SetIdx, TypeIdx, ValuesIdx
};
- enum SubCmdIdx { DeleteIdx, GetIdx, KeysIdx, SetIdx, TypeIdx, ValuesIdx };
if (objc < 2) {
Tcl_WrongNumArgs(interp, objc, objv, "option ?arg arg ...?");
@@ -271,6 +276,9 @@ RegistryObjCmd(
}
switch (index) {
+ case BroadcastIdx: /* broadcast */
+ return BroadcastValue(interp, objc, objv);
+ break;
case DeleteIdx: /* delete */
if (objc == 3) {
return DeleteKey(interp, objv[2]);
@@ -1299,6 +1307,71 @@ SetValue(
/*
*----------------------------------------------------------------------
*
+ * BroadcastValue --
+ *
+ * This function broadcasts a WM_SETTINGCHANGE message to indicate
+ * to other programs that we have changed the contents of a registry
+ * value.
+ *
+ * Results:
+ * Returns a normal Tcl result.
+ *
+ * Side effects:
+ * Will cause other programs to reload their system settings.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+BroadcastValue(
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj * CONST objv[]) /* Argument values. */
+{
+ DWORD result, sendResult;
+ UINT timeout = 3000;
+ int len;
+ char *str;
+ Tcl_Obj *objPtr;
+
+ if ((objc != 3) && (objc != 5)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "keyName ?-timeout millisecs?");
+ return TCL_ERROR;
+ }
+
+ if (objc > 3) {
+ str = Tcl_GetStringFromObj(objv[3], &len);
+ if ((len < 2) || (*str != '-') || strncmp(str, "-timeout", len)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "keyName ?-timeout millisecs?");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIntFromObj(interp, objv[4], (int *) &timeout) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
+
+ str = Tcl_GetStringFromObj(objv[2], &len);
+ if (len = 0) {
+ str = NULL;
+ }
+
+ /*
+ * Use the ignore the result.
+ */
+ result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
+ (WPARAM) 0, (LPARAM) str, SMTO_ABORTIFHUNG, timeout, &sendResult);
+
+ objPtr = Tcl_NewObj();
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(result));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(sendResult));
+ Tcl_SetObjResult(interp, objPtr);
+
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* AppendSystemError --
*
* This routine formats a Windows system error message and places