Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.809
diff -u -u -r1.809 ChangeLog
--- ChangeLog	2002/01/21 22:50:49	1.809
+++ ChangeLog	2002/01/23 01:26:50
@@ -1,3 +1,20 @@
+2002-01-21  Don Porter <dgp@users.sourceforge.net>
+
+	* doc/Encoding.3:
+	* generic/tcl.decls (Tcl_WinUtfToTChar,Tcl_WinTCharToUtf):
+	* win/tclWin32Dll.c (Tcl_WinUtfToTChar,Tcl_WinTCharToUtf):
+	Updated interfaces in win/tclWin32Dll.c according to TIP 27.
+	* generic/tclPlatDecls.h: make genstubs
+	* generic/tclIOUtil.c (TclpNativeToNormalized):
+	* win/tclWinFCmd.c (TclpObjNormalizePath):
+	* win/tclWinFile.c (TclpFindExecutable,TclpMatchInDirectory,
+	  NativeIsExec,NativeStat):
+	* win/tclWinLoad.c (TclpLoadFile):
+	* win/tclWinPipe.c (TclpOpenFile,ApplicationType):
+	* win/tclWinReg.c (regConnectRegistryProc,RecursiveDeleteKey,DeleteKey,
+	  GetKeyNames,GetType,GetValue,OpenSubKey,SetValue):
+	* win/tclWinSerial.c (SerialSetOptionProc): Update callers.
+
 2002-01-21  David Gravereaux <davygrvy@pobox.com>
 
 	* generic/tclLoadNone.c: TclpLoadFile() didn't match proto of
Index: doc/Encoding.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/Encoding.3,v
retrieving revision 1.7
diff -u -u -r1.7 Encoding.3
--- doc/Encoding.3	1999/10/13 00:32:05	1.7
+++ doc/Encoding.3	2002/01/23 01:26:51
@@ -35,10 +35,10 @@
 \fBTcl_UtfToExternal\fR(\fIinterp, encoding, src, srcLen, flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr, 
 	dstCharsPtr\fR)
 .sp
-char *
+CONST char *
 \fBTcl_WinTCharToUtf\fR(\fItsrc, srcLen, dstPtr\fR)
 .sp
-TCHAR *
+CONST TCHAR *
 \fBTcl_WinUtfToTChar\fR(\fIsrc, srcLen, dstPtr\fR)
 .sp
 char *
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.76
diff -u -u -r1.76 tcl.decls
--- generic/tcl.decls	2002/01/21 16:15:03	1.76
+++ generic/tcl.decls	2002/01/23 01:26:51
@@ -1710,10 +1710,12 @@
 # Added in Tcl 8.1
 
 declare 0 win {
-    TCHAR * Tcl_WinUtfToTChar(CONST char *str, int len, Tcl_DString *dsPtr)
+    CONST TCHAR * Tcl_WinUtfToTChar(CONST char *str, int len, \
+	    Tcl_DString *dsPtr)
 }
 declare 1 win {
-    char * Tcl_WinTCharToUtf(CONST TCHAR *str, int len, Tcl_DString *dsPtr)
+    CONST char * Tcl_WinTCharToUtf(CONST TCHAR *str, int len, \
+	    Tcl_DString *dsPtr)
 }
 
 ##################
Index: generic/tclIOUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIOUtil.c,v
retrieving revision 1.30
diff -u -u -r1.30 tclIOUtil.c
--- generic/tclIOUtil.c	2002/01/17 04:37:33	1.30
+++ generic/tclIOUtil.c	2002/01/23 01:26:53
@@ -4114,9 +4114,9 @@
     Tcl_Obj *objPtr;
     
 #ifdef __WIN32__
-    Tcl_WinTCharToUtf((char*)clientData, -1, &ds);
+    Tcl_WinTCharToUtf((CONST char*)clientData, -1, &ds);
 #else
-    Tcl_ExternalToUtfDString(NULL, (char*)clientData, -1, &ds);
+    Tcl_ExternalToUtfDString(NULL, (CONST char*)clientData, -1, &ds);
 #endif
     objPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds),Tcl_DStringLength(&ds));
     Tcl_DStringFree(&ds);
Index: generic/tclPlatDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPlatDecls.h,v
retrieving revision 1.12
diff -u -u -r1.12 tclPlatDecls.h
--- generic/tclPlatDecls.h	2001/09/09 22:45:13	1.12
+++ generic/tclPlatDecls.h	2002/01/23 01:26:55
@@ -34,10 +34,10 @@
 
 #ifdef __WIN32__
 /* 0 */
-EXTERN TCHAR *		Tcl_WinUtfToTChar _ANSI_ARGS_((CONST char * str, 
+EXTERN CONST TCHAR *	Tcl_WinUtfToTChar _ANSI_ARGS_((CONST char * str, 
 				int len, Tcl_DString * dsPtr));
 /* 1 */
-EXTERN char *		Tcl_WinTCharToUtf _ANSI_ARGS_((CONST TCHAR * str, 
+EXTERN CONST char *	Tcl_WinTCharToUtf _ANSI_ARGS_((CONST TCHAR * str, 
 				int len, Tcl_DString * dsPtr));
 #endif /* __WIN32__ */
 #ifdef MAC_TCL
@@ -78,8 +78,8 @@
     struct TclPlatStubHooks *hooks;
 
 #ifdef __WIN32__
-    TCHAR * (*tcl_WinUtfToTChar) _ANSI_ARGS_((CONST char * str, int len, Tcl_DString * dsPtr)); /* 0 */
-    char * (*tcl_WinTCharToUtf) _ANSI_ARGS_((CONST TCHAR * str, int len, Tcl_DString * dsPtr)); /* 1 */
+    CONST TCHAR * (*tcl_WinUtfToTChar) _ANSI_ARGS_((CONST char * str, int len, Tcl_DString * dsPtr)); /* 0 */
+    CONST char * (*tcl_WinTCharToUtf) _ANSI_ARGS_((CONST TCHAR * str, int len, Tcl_DString * dsPtr)); /* 1 */
 #endif /* __WIN32__ */
 #ifdef MAC_TCL
     void (*tcl_MacSetEventProc) _ANSI_ARGS_((Tcl_MacConvertEventPtr procPtr)); /* 0 */
Index: win/tclWin32Dll.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWin32Dll.c,v
retrieving revision 1.11
diff -u -u -r1.11 tclWin32Dll.c
--- win/tclWin32Dll.c	2001/11/19 17:45:12	1.11
+++ win/tclWin32Dll.c	2002/01/23 01:26:57
@@ -490,7 +490,7 @@
  *---------------------------------------------------------------------------
  */
 
-TCHAR *
+CONST TCHAR *
 Tcl_WinUtfToTChar(string, len, dsPtr)
     CONST char *string;		/* Source string in UTF-8. */
     int len;			/* Source string length in bytes, or < 0 for
@@ -502,7 +502,7 @@
 	    string, len, dsPtr);
 }
 
-char *
+CONST char *
 Tcl_WinTCharToUtf(string, len, dsPtr)
     CONST TCHAR *string;	/* Source string in Unicode when running
 				 * NT, ANSI when running 95. */
Index: win/tclWinFCmd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFCmd.c,v
retrieving revision 1.19
diff -u -u -r1.19 tclWinFCmd.c
--- win/tclWinFCmd.c	2002/01/18 14:17:06	1.19
+++ win/tclWinFCmd.c	2002/01/23 01:26:57
@@ -1888,7 +1888,7 @@
 	Tcl_DStringFree(&ds);
     } else {
 	/* We're on WinNT or 2000 or XP */
-	char *nativePath;
+	CONST char *nativePath;
 #if 0
 	/* 
 	 * We don't use this simpler version, because the speed
Index: win/tclWinFile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFile.c,v
retrieving revision 1.21
diff -u -u -r1.21 tclWinFile.c
--- win/tclWinFile.c	2002/01/18 14:17:06	1.21
+++ win/tclWinFile.c	2002/01/23 01:26:57
@@ -80,7 +80,7 @@
      */
 
     (*tclWinProcs->getModuleFileNameProc)(NULL, wName, MAX_PATH);
-    Tcl_WinTCharToUtf((TCHAR *) wName, -1, &ds);
+    Tcl_WinTCharToUtf((CONST TCHAR *) wName, -1, &ds);
 
     tclNativeExecutableName = ckalloc((unsigned) (Tcl_DStringLength(&ds) + 1));
     strcpy(tclNativeExecutableName, Tcl_DStringValue(&ds));
@@ -132,7 +132,7 @@
     Tcl_DString ds;
     Tcl_DString dsOrig;
     Tcl_Obj *fileNamePtr;
-    TCHAR *nativeName;
+    CONST TCHAR *nativeName;
     int matchSpecialDots;
     
     /*
@@ -269,15 +269,15 @@
 
     for (found = 1; found != 0; 
 	    found = (*tclWinProcs->findNextFileProc)(handle, &data)) {
-	TCHAR *nativeMatchResult;
-	char *name, *fname;
+	CONST TCHAR *nativeMatchResult;
+	CONST char *name, *fname;
 	
 	int typeOk = 1;
 	
 	if (tclWinProcs->useWide) {
-	    nativeName = (TCHAR *) data.w.cFileName;
+	    nativeName = (CONST TCHAR *) data.w.cFileName;
 	} else {
-	    nativeName = (TCHAR *) data.a.cFileName;
+	    nativeName = (CONST TCHAR *) data.a.cFileName;
 	}
 	name = Tcl_WinTCharToUtf(nativeName, -1, &ds);
 
@@ -642,8 +642,7 @@
 NativeIsExec(nativePath)
     CONST TCHAR *nativePath;
 {
-    CONST char *p;
-    char *path;
+    CONST char *p, *path;
     Tcl_DString ds;
     
     /* 
@@ -936,7 +935,7 @@
 	if ((fullPath[0] == '\\') && (fullPath[1] == '\\')) {
 	    CONST char *p;
 	    DWORD dw;
-	    TCHAR *nativeVol;
+	    CONST TCHAR *nativeVol;
 	    Tcl_DString volString;
 
 	    p = strchr(fullPath + 2, '\\');
@@ -996,7 +995,7 @@
 	if ((fullPath[0] == '\\') && (fullPath[1] == '\\')) {
 	    CONST char *p;
 	    DWORD dw;
-	    TCHAR *nativeVol;
+	    CONST TCHAR *nativeVol;
 	    Tcl_DString volString;
 
 	    p = strchr(fullPath + 2, '\\');
Index: win/tclWinLoad.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinLoad.c,v
retrieving revision 1.10
diff -u -u -r1.10 tclWinLoad.c
--- win/tclWinLoad.c	2002/01/09 19:09:28	1.10
+++ win/tclWinLoad.c	2002/01/23 01:26:57
@@ -55,7 +55,7 @@
 				 * this file. */
 {
     HINSTANCE handle;
-    TCHAR *nativeName;
+    CONST TCHAR *nativeName;
     Tcl_DString ds;
 
     char *fileName = Tcl_GetString(pathPtr);
Index: win/tclWinPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinPipe.c,v
retrieving revision 1.21
diff -u -u -r1.21 tclWinPipe.c
--- win/tclWinPipe.c	2002/01/15 17:55:31	1.21
+++ win/tclWinPipe.c	2002/01/23 01:26:58
@@ -578,7 +578,7 @@
     HANDLE handle;
     DWORD accessMode, createMode, shareMode, flags;
     Tcl_DString ds;
-    TCHAR *nativePath;
+    CONST TCHAR *nativePath;
     
     /*
      * Map the access bits to the NT access mode.
@@ -1360,7 +1360,7 @@
     DWORD attr, read;
     IMAGE_DOS_HEADER header;
     Tcl_DString nameBuf, ds;
-    TCHAR *nativeName;
+    CONST TCHAR *nativeName;
     WCHAR nativeFullPath[MAX_PATH];
     static char extensions[][5] = {"", ".com", ".exe", ".bat"};
 
Index: win/tclWinReg.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinReg.c,v
retrieving revision 1.14
diff -u -u -r1.14 tclWinReg.c
--- win/tclWinReg.c	2002/01/18 14:07:40	1.14
+++ win/tclWinReg.c	2002/01/23 01:26:58
@@ -80,7 +80,7 @@
 typedef struct RegWinProcs {
     int useWide;
 
-    LONG (WINAPI *regConnectRegistryProc)(TCHAR *, HKEY, PHKEY);
+    LONG (WINAPI *regConnectRegistryProc)(CONST TCHAR *, HKEY, PHKEY);
     LONG (WINAPI *regCreateKeyExProc)(HKEY, CONST TCHAR *, DWORD, TCHAR *,
 	    DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *, DWORD *); 
     LONG (WINAPI *regDeleteKeyProc)(HKEY, CONST TCHAR *);
@@ -106,7 +106,7 @@
 static RegWinProcs asciiProcs = {
     0,
 
-    (LONG (WINAPI *)(TCHAR *, HKEY, PHKEY)) RegConnectRegistryA,
+    (LONG (WINAPI *)(CONST TCHAR *, HKEY, PHKEY)) RegConnectRegistryA,
     (LONG (WINAPI *)(HKEY, CONST TCHAR *, DWORD, TCHAR *,
 	    DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *,
 	    DWORD *)) RegCreateKeyExA, 
@@ -131,7 +131,7 @@
 static RegWinProcs unicodeProcs = {
     1,
 
-    (LONG (WINAPI *)(TCHAR *, HKEY, PHKEY)) RegConnectRegistryW,
+    (LONG (WINAPI *)(CONST TCHAR *, HKEY, PHKEY)) RegConnectRegistryW,
     (LONG (WINAPI *)(HKEY, CONST TCHAR *, DWORD, TCHAR *,
 	    DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *,
 	    DWORD *)) RegCreateKeyExW, 
@@ -179,7 +179,8 @@
 static int		ParseKeyName(Tcl_Interp *interp, char *name,
 			    char **hostNamePtr, HKEY *rootKeyPtr,
 			    char **keyNamePtr);
-static DWORD		RecursiveDeleteKey(HKEY hStartKey, TCHAR * pKeyName);
+static DWORD		RecursiveDeleteKey(HKEY hStartKey,
+			    CONST TCHAR * pKeyName);
 static int		RegistryObjCmd(ClientData clientData,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj * CONST objv[]);
@@ -352,6 +353,7 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     Tcl_Obj *keyNameObj)	/* Name of key to delete. */
 {
+    CONST TCHAR *nativeTail;
     char *tail, *buffer, *hostName, *keyName;
     HKEY rootKey, subkey;
     DWORD result;
@@ -405,8 +407,8 @@
      * Now we recursively delete the key and everything below it.
      */
 
-    tail = Tcl_WinUtfToTChar(tail, -1, &buf);
-    result = RecursiveDeleteKey(subkey, tail);
+    nativeTail = Tcl_WinUtfToTChar(tail, -1, &buf);
+    result = RecursiveDeleteKey(subkey, nativeTail);
     Tcl_DStringFree(&buf);
 
     if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
@@ -505,7 +507,8 @@
 {
     HKEY key;
     DWORD index;
-    char buffer[MAX_PATH+1], *pattern, *name;
+    TCHAR buffer[MAX_PATH+1];
+    char *pattern, *name;
     Tcl_Obj *resultPtr;
     int result = TCL_OK;
     Tcl_DString ds;
@@ -533,7 +536,7 @@
     resultPtr = Tcl_GetObjResult(interp);
     for (index = 0; (*regWinProcs->regEnumKeyProc)(key, index, buffer,
 	    MAX_PATH+1) == ERROR_SUCCESS; index++) {
-	Tcl_WinTCharToUtf((TCHAR *) buffer, -1, &ds);
+	Tcl_WinTCharToUtf(buffer, -1, &ds);
 	name = Tcl_DStringValue(&ds);
 	if (pattern && !Tcl_StringMatch(name, pattern)) {
 	    Tcl_DStringFree(&ds);
@@ -581,6 +584,7 @@
     Tcl_DString ds;
     char *valueName;
     int length;
+    CONST TCHAR *nativeValue;
 
     /*
      * Attempt to open the key for reading.
@@ -598,8 +602,8 @@
     resultPtr = Tcl_GetObjResult(interp);
 
     valueName = Tcl_GetStringFromObj(valueNameObj, &length);
-    valueName = Tcl_WinUtfToTChar(valueName, length, &ds);
-    result = (*regWinProcs->regQueryValueExProc)(key, valueName, NULL, &type,
+    nativeValue = Tcl_WinUtfToTChar(valueName, length, &ds);
+    result = (*regWinProcs->regQueryValueExProc)(key, nativeValue, NULL, &type,
 	    NULL, NULL);
     Tcl_DStringFree(&ds);
     RegCloseKey(key);
@@ -655,6 +659,7 @@
     Tcl_Obj *resultPtr;
     Tcl_DString data, buf;
     int nameLen;
+    CONST TCHAR *nativeValue;
 
     /*
      * Attempt to open the key for reading.
@@ -682,9 +687,9 @@
     resultPtr = Tcl_GetObjResult(interp);
 
     valueName = Tcl_GetStringFromObj(valueNameObj, &nameLen);
-    valueName = Tcl_WinUtfToTChar(valueName, nameLen, &buf);
+    nativeValue = Tcl_WinUtfToTChar(valueName, nameLen, &buf);
 
-    result = (*regWinProcs->regQueryValueExProc)(key, valueName, NULL, &type,
+    result = (*regWinProcs->regQueryValueExProc)(key, nativeValue, NULL, &type,
 	    (BYTE *) Tcl_DStringValue(&data), &length);
     while (result == ERROR_MORE_DATA) {
 	/*
@@ -694,7 +699,7 @@
 	 */
 	length *= 2;
         Tcl_DStringSetLength(&data, (int) length);
-        result = (*regWinProcs->regQueryValueExProc)(key, valueName, NULL,
+        result = (*regWinProcs->regQueryValueExProc)(key, nativeValue, NULL,
 		&type, (BYTE *) Tcl_DStringValue(&data), &length);
     }
     Tcl_DStringFree(&buf);
@@ -938,23 +943,24 @@
 
 static DWORD
 OpenSubKey(
-    char *hostName,		/* Host to access, or NULL for local. */
+    CONST char *hostName,	/* Host to access, or NULL for local. */
     HKEY rootKey,		/* Root registry key. */
-    char *keyName,		/* Subkey name. */
+    CONST char *keyName,	/* Subkey name. */
     REGSAM mode,		/* Access mode. */
     int flags,			/* 0 or REG_CREATE. */
     HKEY *keyPtr)		/* Returned HKEY. */
 {
     DWORD result;
     Tcl_DString buf;
+    CONST TCHAR *nativeHost, nativeKey;
 
     /*
      * Attempt to open the root key on a remote host if necessary.
      */
 
     if (hostName) {
-	hostName = Tcl_WinUtfToTChar(hostName, -1, &buf);
-	result = (*regWinProcs->regConnectRegistryProc)(hostName, rootKey,
+	nativeHost = Tcl_WinUtfToTChar(hostName, -1, &buf);
+	result = (*regWinProcs->regConnectRegistryProc)(nativeHost, rootKey,
 		&rootKey);
 	Tcl_DStringFree(&buf);
 	if (result != ERROR_SUCCESS) {
@@ -967,10 +973,10 @@
      * that this key must be closed by the caller.
      */
 
-    keyName = Tcl_WinUtfToTChar(keyName, -1, &buf);
+    nativeKey = Tcl_WinUtfToTChar(keyName, -1, &buf);
     if (flags & REG_CREATE) {
 	DWORD create;
-	result = (*regWinProcs->regCreateKeyExProc)(rootKey, keyName, 0, "",
+	result = (*regWinProcs->regCreateKeyExProc)(rootKey, nativeKey, 0, "",
 		REG_OPTION_NON_VOLATILE, mode, NULL, keyPtr, &create);
     } else {
 	if (rootKey == HKEY_PERFORMANCE_DATA) {
@@ -982,7 +988,7 @@
 	    *keyPtr = HKEY_PERFORMANCE_DATA;
 	    result = ERROR_SUCCESS;
 	} else {
-	    result = (*regWinProcs->regOpenKeyExProc)(rootKey, keyName, 0,
+	    result = (*regWinProcs->regOpenKeyExProc)(rootKey, nativeKey, 0,
 		    mode, keyPtr);
 	}
     }
@@ -1103,7 +1109,7 @@
 static DWORD
 RecursiveDeleteKey(
     HKEY startKey,		/* Parent of key to be deleted. */
-    char *keyName)		/* Name of key to be deleted in external
+    CONST TCHAR *keyName)	/* Name of key to be deleted in external
 				 * encoding, not UTF. */
 {
     DWORD result, size, maxSize;
@@ -1140,13 +1146,14 @@
 	 */
 
 	size = maxSize;
-	result=(*regWinProcs->regEnumKeyExProc)(hKey, 0,
+	result=(*regWinProcs->regEnumKeyExProc)(hKey, 0, (TCHAR *)
 		Tcl_DStringValue(&subkey), &size, NULL, NULL, NULL, NULL);
 	if (result == ERROR_NO_MORE_ITEMS) {
 	    result = (*regWinProcs->regDeleteKeyProc)(startKey, keyName);
 	    break;
 	} else if (result == ERROR_SUCCESS) {
-	    result = RecursiveDeleteKey(hKey, Tcl_DStringValue(&subkey));
+	    result = RecursiveDeleteKey(hKey,
+		    (CONST TCHAR *) Tcl_DStringValue(&subkey));
 	}
     }
     Tcl_DStringFree(&subkey);
@@ -1186,6 +1193,7 @@
     char *valueName;
     Tcl_Obj *resultPtr;
     Tcl_DString nameBuf;
+    CONST TCHAR *native;
 
     if (typeObj == NULL) {
 	type = REG_SZ;
@@ -1201,7 +1209,7 @@
     }
 
     valueName = Tcl_GetStringFromObj(valueNameObj, &length);
-    valueName = Tcl_WinUtfToTChar(valueName, length, &nameBuf);
+    native = Tcl_WinUtfToTChar(valueName, length, &nameBuf);
     resultPtr = Tcl_GetObjResult(interp);
 
     if (type == REG_DWORD || type == REG_DWORD_BIG_ENDIAN) {
@@ -1213,7 +1221,7 @@
 	}
 
 	value = ConvertDWORD(type, value);
-	result = (*regWinProcs->regSetValueExProc)(key, valueName, 0, type,
+	result = (*regWinProcs->regSetValueExProc)(key, native, 0, type,
 		(BYTE*) &value, sizeof(DWORD));
     } else if (type == REG_MULTI_SZ) {
 	Tcl_DString data, buf;
@@ -1248,16 +1256,15 @@
 
 	Tcl_WinUtfToTChar(Tcl_DStringValue(&data), Tcl_DStringLength(&data)+1,
 		&buf);
-	result = (*regWinProcs->regSetValueExProc)(key, valueName, 0, type,
+	result = (*regWinProcs->regSetValueExProc)(key, native, 0, type,
 		(BYTE *) Tcl_DStringValue(&buf),
 		(DWORD) Tcl_DStringLength(&buf));
 	Tcl_DStringFree(&data);
 	Tcl_DStringFree(&buf);
     } else if (type == REG_SZ || type == REG_EXPAND_SZ) {
 	Tcl_DString buf;
-	char *data = Tcl_GetStringFromObj(dataObj, &length);
-
-	data = Tcl_WinUtfToTChar(data, length, &buf);
+	CONST char *data = Tcl_GetStringFromObj(dataObj, &length);
+	CONST TCHAR *native = Tcl_WinUtfToTChar(data, length, &buf);
 
 	/*
 	 * Include the null in the length, padding if needed for Unicode.
@@ -1268,8 +1275,8 @@
 	}
 	length = Tcl_DStringLength(&buf) + 1;
 
-	result = (*regWinProcs->regSetValueExProc)(key, valueName, 0, type,
-		(BYTE*)data, (DWORD) length);
+	result = (*regWinProcs->regSetValueExProc)(key, native, 0, type,
+		(BYTE*)native, (DWORD) length);
 	Tcl_DStringFree(&buf);
     } else {
 	char *data;
@@ -1279,7 +1286,7 @@
 	 */
 
 	data = Tcl_GetByteArrayFromObj(dataObj, &length);
-	result = (*regWinProcs->regSetValueExProc)(key, valueName, 0, type,
+	result = (*regWinProcs->regSetValueExProc)(key, native, 0, type,
 		(BYTE *)data, (DWORD) length);
     }
     Tcl_DStringFree(&nameBuf);
Index: win/tclWinSerial.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinSerial.c,v
retrieving revision 1.18
diff -u -u -r1.18 tclWinSerial.c
--- win/tclWinSerial.c	2002/01/15 17:55:31	1.18
+++ win/tclWinSerial.c	2002/01/23 01:26:58
@@ -1531,7 +1531,7 @@
     BOOL result, flag;
     size_t len, vlen;
     Tcl_DString ds;
-    TCHAR *native;
+    CONST TCHAR *native;
     int argc;
     char **argv;
     
