From 57cf54aae9b84690dc0820e5bb0501fa33beaf06 Mon Sep 17 00:00:00 2001 From: Ratin Gao Date: Mon, 2 Dec 2024 15:46:14 +0800 Subject: [PATCH] Update --- .../KNSoft.MakeLifeEasier.vcxproj | 4 +-- Source/KNSoft.MakeLifeEasier/String/Core.h | 9 ++++++ Source/KNSoft.MakeLifeEasier/UI/Message.h | 31 +++++++++++++++++++ Source/KNSoft.MakeLifeEasier/UI/Window.h | 12 +++++++ Source/KNSoft.MakeLifeEasier/packages.config | 2 +- Source/Test/Test.vcxproj | 4 +-- Source/Test/packages.config | 2 +- 7 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Source/KNSoft.MakeLifeEasier/KNSoft.MakeLifeEasier.vcxproj b/Source/KNSoft.MakeLifeEasier/KNSoft.MakeLifeEasier.vcxproj index 688fcc9..cfe0d18 100644 --- a/Source/KNSoft.MakeLifeEasier/KNSoft.MakeLifeEasier.vcxproj +++ b/Source/KNSoft.MakeLifeEasier/KNSoft.MakeLifeEasier.vcxproj @@ -270,7 +270,7 @@ - + @@ -278,6 +278,6 @@ - + \ No newline at end of file diff --git a/Source/KNSoft.MakeLifeEasier/String/Core.h b/Source/KNSoft.MakeLifeEasier/String/Core.h index cd7abb4..4e38f72 100644 --- a/Source/KNSoft.MakeLifeEasier/String/Core.h +++ b/Source/KNSoft.MakeLifeEasier/String/Core.h @@ -131,6 +131,15 @@ Str_EqualW( #pragma endregion +FORCEINLINE +LOGICAL +Str_TestCchRet( + _In_ unsigned long CchRet, + _In_ size_t const BufferCount) +{ + return CchRet > 0 && CchRet < BufferCount; +} + #pragma region String PrintF _Success_( diff --git a/Source/KNSoft.MakeLifeEasier/UI/Message.h b/Source/KNSoft.MakeLifeEasier/UI/Message.h index 71fbae2..aeeb6f5 100644 --- a/Source/KNSoft.MakeLifeEasier/UI/Message.h +++ b/Source/KNSoft.MakeLifeEasier/UI/Message.h @@ -49,6 +49,37 @@ UI_EnableDlgItem( return EnableWindow(GetDlgItem(Dialog, ItemId), EnableState); } +/// +FORCEINLINE +W32ERROR +UI_SendMessageTimeout( + _In_ HWND Window, + _In_ UINT Msg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ UINT fuFlags, + _In_ UINT uTimeout, + _Out_opt_ PDWORD_PTR lpdwResult) +{ + LRESULT lr; + W32ERROR Ret; + + NtSetLastError(ERROR_SUCCESS); + lr = SendMessageTimeoutW(Window, Msg, wParam, lParam, fuFlags, uTimeout, lpdwResult); + if (lr != 0) + { + Ret = ERROR_SUCCESS; + } else + { + Ret = NtGetLastError(); + if (Ret == ERROR_SUCCESS) + { + Ret = ERROR_GEN_FAILURE; + } + } + return Ret; +} + /// #define UI_SendMsgW(Window, Msg, wParam, lParam) SendMessageW(Window, Msg, (WPARAM)(wParam), (LPARAM)(lParam)) #define UI_SendMsgA(Window, Msg, wParam, lParam) SendMessageA(Window, Msg, (WPARAM)(wParam), (LPARAM)(lParam)) diff --git a/Source/KNSoft.MakeLifeEasier/UI/Window.h b/Source/KNSoft.MakeLifeEasier/UI/Window.h index a1d1480..7ca3c25 100644 --- a/Source/KNSoft.MakeLifeEasier/UI/Window.h +++ b/Source/KNSoft.MakeLifeEasier/UI/Window.h @@ -24,6 +24,18 @@ UI_TruncateHandle32( return (ULONG)(ULONG_PTR)Handle32; } +FORCEINLINE +W32ERROR +UI_GetWindowLong( + _In_ HWND Window, + _In_ INT Index, + _Out_ PLONG_PTR Value) +{ + NtSetLastError(ERROR_SUCCESS); + *Value = GetWindowLongPtrW(Window, Index); + return *Value != 0 ? ERROR_SUCCESS : NtGetLastError(); +} + /// FORCEINLINE LOGICAL diff --git a/Source/KNSoft.MakeLifeEasier/packages.config b/Source/KNSoft.MakeLifeEasier/packages.config index f503ef8..66bcba6 100644 --- a/Source/KNSoft.MakeLifeEasier/packages.config +++ b/Source/KNSoft.MakeLifeEasier/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Source/Test/Test.vcxproj b/Source/Test/Test.vcxproj index 59e1d4e..05c6780 100644 --- a/Source/Test/Test.vcxproj +++ b/Source/Test/Test.vcxproj @@ -189,12 +189,12 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/Source/Test/packages.config b/Source/Test/packages.config index ed9f293..53f60d6 100644 --- a/Source/Test/packages.config +++ b/Source/Test/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file