From 865ea5e678412f23106c8374c3113169e35439f9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Sep 2019 13:53:39 +0000 Subject: More Win32 API impovals. --- generic/tclZipfs.c | 7 ++++++- win/tclWinConsole.c | 4 ++-- win/tclWinDde.c | 16 ++++++++-------- win/tclWinFile.c | 2 +- win/tclWinPipe.c | 2 +- win/tclWinReg.c | 2 +- win/tclWinSock.c | 16 ++++++++-------- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index e0d08a7..2467588 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -1161,7 +1161,7 @@ ZipFSOpenArchive( ZIPFS_POSIX_ERROR(interp, "invalid file size"); goto error; } - zf->mountHandle = CreateFileMapping((HANDLE) handle, 0, PAGE_READONLY, + zf->mountHandle = CreateFileMappingW((HANDLE) handle, 0, PAGE_READONLY, 0, zf->length, 0); if (zf->mountHandle == INVALID_HANDLE_VALUE) { ZIPFS_POSIX_ERROR(interp, "file mapping failed"); @@ -4926,7 +4926,12 @@ TclZipfs_AppHook( { char *archive; +#ifdef _WIN32 + (void)argvPtr; + Tcl_FindExecutable(NULL); +#else Tcl_FindExecutable((*argvPtr)[0]); +#endif archive = (char *) Tcl_GetNameOfExecutable(); TclZipfs_Init(NULL); diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index e7b87a7..dbec52b 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -229,7 +229,7 @@ ReadConsoleBytes( * will run and take whatever action it deems appropriate. */ do { - result = ReadConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, + result = ReadConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, NULL); } while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED); if (nbytesread != NULL) { @@ -248,7 +248,7 @@ WriteConsoleBytes( DWORD ntchars; BOOL result; - result = WriteConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, + result = WriteConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, NULL); if (nbyteswritten != NULL) { *nbyteswritten = ntchars * sizeof(WCHAR); diff --git a/win/tclWinDde.c b/win/tclWinDde.c index 1eded82..6fa9cc2 100644 --- a/win/tclWinDde.c +++ b/win/tclWinDde.c @@ -251,7 +251,7 @@ Initialize(void) if (ddeInstance == 0) { Tcl_MutexLock(&ddeMutex); if (ddeInstance == 0) { - if (DdeInitialize(&ddeInstance, (PFNCALLBACK) DdeServerProc, + if (DdeInitializeW(&ddeInstance, (PFNCALLBACK) DdeServerProc, CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS | CBF_FAIL_POKES, 0) != DMLERR_NO_ERROR) { ddeInstance = 0; @@ -1107,16 +1107,16 @@ DdeClientWindowProc( (DdeEnumServices *) lpcs->lpCreateParams; #ifdef _WIN64 - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) es); + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) es); #else - SetWindowLong(hwnd, GWL_USERDATA, (LONG) es); + SetWindowLongW(hwnd, GWL_USERDATA, (LONG) es); #endif return (LRESULT) 0L; } case WM_DDE_ACK: return DdeServicesOnAck(hwnd, wParam, lParam); default: - return DefWindowProc(hwnd, uMsg, wParam, lParam); + return DefWindowProcW(hwnd, uMsg, wParam, lParam); } } @@ -1134,9 +1134,9 @@ DdeServicesOnAck( Tcl_DString dString; #ifdef _WIN64 - es = (DdeEnumServices *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + es = (DdeEnumServices *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); #else - es = (DdeEnumServices *) GetWindowLong(hwnd, GWL_USERDATA); + es = (DdeEnumServices *) GetWindowLongW(hwnd, GWL_USERDATA); #endif if (((es->service == (ATOM)0) || (es->service == service)) @@ -1179,7 +1179,7 @@ DdeServicesOnAck( * Tell the server we are no longer interested. */ - PostMessage(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L); + PostMessageW(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L); return 0L; } @@ -1191,7 +1191,7 @@ DdeEnumWindowsCallback( DWORD_PTR dwResult = 0; DdeEnumServices *es = (DdeEnumServices *) lParam; - SendMessageTimeout(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd, + SendMessageTimeoutW(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd, MAKELONG(es->service, es->topic), SMTO_ABORTIFHUNG, 1000, &dwResult); return TRUE; diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 3259ff7..0682d74 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -2207,7 +2207,7 @@ NativeDev( p = strchr(p + 1, '\\'); if (p == NULL) { /* - * Add terminating backslash to fullpath or GetVolumeInformation() + * Add terminating backslash to fullpath or GetVolumeInformationW() * won't work. */ diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index ed4bc22..26f0b3e 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1207,7 +1207,7 @@ HasConsole(void) { HANDLE handle; - handle = CreateFileA("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, + handle = CreateFileW(L"CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle != INVALID_HANDLE_VALUE) { diff --git a/win/tclWinReg.c b/win/tclWinReg.c index b715209..068e5d7 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.c @@ -1449,7 +1449,7 @@ BroadcastValue( * Use the ignore the result. */ - result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, + result = SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM) 0, (LPARAM) wstr, SMTO_ABORTIFHUNG, (UINT) timeout, &sendResult); Tcl_DStringFree(&ds); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 7a5c282..bb6c690 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -310,7 +310,7 @@ static ProcessGlobalValue hostName = */ #define SendSelectMessage(tsdPtr, message, payload) \ - SendMessage((tsdPtr)->hwnd, SOCKET_SELECT, \ + SendMessageW((tsdPtr)->hwnd, SOCKET_SELECT, \ (WPARAM) (message), (LPARAM) (payload)) @@ -501,7 +501,7 @@ TclpFinalizeSockets(void) if (tsdPtr->socketThread != NULL) { if (tsdPtr->hwnd != NULL) { - PostMessage(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0); + PostMessageW(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0); /* * Wait for the thread to exit. This ensures that we are @@ -2534,11 +2534,11 @@ InitSockets(void) tsdPtr->socketList = NULL; tsdPtr->hwnd = NULL; tsdPtr->threadId = Tcl_GetCurrentThread(); - tsdPtr->readyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + tsdPtr->readyEvent = CreateEventW(NULL, FALSE, FALSE, NULL); if (tsdPtr->readyEvent == NULL) { goto initFailure; } - tsdPtr->socketListLock = CreateEvent(NULL, FALSE, TRUE, NULL); + tsdPtr->socketListLock = CreateEventW(NULL, FALSE, TRUE, NULL); if (tsdPtr->socketListLock == NULL) { goto initFailure; } @@ -3205,7 +3205,7 @@ SocketThread( /* * Process all messages on the socket window until WM_QUIT. This threads * exits only when instructed to do so by the call to - * PostMessage(SOCKET_TERMINATE) in TclpFinalizeSockets(). + * PostMessageW(SOCKET_TERMINATE) in TclpFinalizeSockets(). */ while (GetMessageW(&msg, NULL, 0, 0) > 0) { @@ -3256,7 +3256,7 @@ SocketProc( #ifdef _WIN64 GetWindowLongPtrW(hwnd, GWLP_USERDATA); #else - GetWindowLong(hwnd, GWL_USERDATA); + GetWindowLongW(hwnd, GWL_USERDATA); #endif switch (message) { @@ -3271,10 +3271,10 @@ SocketProc( */ #ifdef _WIN64 - SetWindowLongPtr(hwnd, GWLP_USERDATA, + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) ((LPCREATESTRUCT)lParam)->lpCreateParams); #else - SetWindowLong(hwnd, GWL_USERDATA, + SetWindowLongW(hwnd, GWL_USERDATA, (LONG) ((LPCREATESTRUCT)lParam)->lpCreateParams); #endif break; -- cgit v0.12