{"id":132,"date":"2022-08-17T14:14:22","date_gmt":"2022-08-17T06:14:22","guid":{"rendered":"https:\/\/miie.net\/?p=132"},"modified":"2022-08-17T14:14:22","modified_gmt":"2022-08-17T06:14:22","slug":"winform-wpf-uwp-winui","status":"publish","type":"post","link":"https:\/\/diji.net\/?p=132","title":{"rendered":"WPF\u3001WinUI\u3001UWP\u3001WinForm \u533a\u522b"},"content":{"rendered":"<p>WPF\u3001WinUI\u3001UWP\u3001WinForm \u5728\u9879\u76ee\u4e2d\u5230\u5e95\u662f\u600e\u4e48\u533a\u522b\u7684\uff1f<\/p>\n<p>\u5fae\u8f6f\u7684UI\u6280\u672f\u6709\u5f88\u591a\uff0c\u7684\u786e\u8ba9\u5f00\u53d1\u8005\u5934\u6655\uff0c\u7279\u522b\u662f\u5f88\u591a\u547d\u540d\u7a7a\u95f4\u5305\u542bWindows\u548cMicrosoft\u8fd9\u4e24\u4e2a\u540d\u5b57\u3002<\/p>\n<p>\u5148\u5355\u72ec\u8bf4\u660eWin32\uff0cWin32\u67093\u4e2a\u542b\u4e49<\/p>\n<ol>\n<li>Win32 UI\uff1a\u6307\u7684\u662f\u754c\u9762\u4e0a\u7684\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u90fd\u662f\u539f\u751fWindows\u63a7\u4ef6\uff0c\u6bcf\u4e2a\u63a7\u4ef6\u90fd\u662f\u4e00\u4e2aHWND<\/li>\n<li>Win32<br \/>\nAPI\uff1a\u6307C\u5f62\u5f0f\u7684\uff0c\u5927\u90e8\u5206\u90fd\u4e0d\u7b26\u5408UWP\u6c99\u76d2\u73af\u5883\u7684API<\/li>\n<li>Win32 \u7a0b\u5e8f\uff1a\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548c\u8868\u73b0\u5f62\u5f0f\uff0c\u9664\u4e86Win32\u5f62\u5f0f\u5219\u662fUWP\u5f62\u5f0f\uff0c\u6240\u4ee5Win32\u5f62\u5f0f\u5305\u542b\u4e86WPF\uff0cWinForm\u3002UWP\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u5f62\u5f0f\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u7279\u70b9\uff0c\u6700\u5c0f\u5316\u4e4b\u540e\uff0c\u7a0b\u5e8f\u6682\u505c\u8fd0\u884c\u3002<\/li>\n<\/ol>\n<p><strong>\u8fa8\u522b\u65b9\u6cd5<\/strong><br \/>\nWin32 UI\uff0cWPF\u3001WinUI\u3001UWP\u3001WinForm\u7b49\u7b49\u540d\u8bcd\uff0c\u90fd\u53ef\u4ee5\u7528\u4e09\u65b9\u9762\u6765\u603b\u7ed3\u533a\u522b\uff0c\u4e00\u4e2a\u662f\u7a0b\u5e8f\u4f9d\u8d56\u4ec0\u4e48\uff0c\u4e00\u4e2a\u662fUI\u7ed8\u5236\u65b9\u5f0f\uff0c\u4e00\u4e2a\u662f\u8fd0\u884c\u6743\u9650\u3002<br \/>\n\u4ece\u4ed6\u4eec\u51fa\u751f\u7684\u5148\u540e\u987a\u5e8f\u5f00\u59cb\u8bf4\u8d77<br \/>\n<strong>1. Win32 UI<\/strong><br \/>\n<strong>1.1 \u4f9d\u8d56<\/strong><br \/>\n\u5305\u542b\u4e86\u4e00\u5927\u6279\u7a33\u5b9a\u7684\uff0c\u517c\u5bb9\u7684C\u8bed\u8a00\u7248\u672cWin32API\uff0c\u6bd4\u5982 GetWindowTextA\uff0c\u7528\u6765\u83b7\u53d6\u7a97\u53e3\u6587\u5b57\uff0c\u975e\u5e38\u975e\u5e38\u65e9\u671f\u4e0d\u5c11\u7a0b\u5e8f\u4e5f\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u83b7\u53d6QQ\u5bc6\u7801\u6846\u63a7\u4ef6\u4e2d\u7684\u5bc6\u7801\uff0c\u867d\u7136\u5bc6\u7801\u6846\u4e2d\u6587\u672c\u8868\u73b0\u4e3a\u201c*\u201d\uff0c\u4f46\u662f\u5b9e\u9645\u5b58\u50a8\u7684\u4e3a\u5bc6\u7801\u7684\u5185\u5bb9\u3002<br \/>\n<strong>1.2 UI\u7ed8\u5236\u65b9\u5f0f<\/strong><br \/>\n\u754c\u9762\u4e0a\u7684\u5143\u7d20\u90fd\u662f\u7531Windows\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u7684\u63a7\u4ef6\uff0c\u6bd4\u5982\u7f16\u8f91\u6846\uff0c\u6587\u672c\u6846\uff0c\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u90fd\u6709\u81ea\u5df1\u7684HWND\u5f62\u5f0f\u7684HANDLE\uff0c\u5176\u4ed6\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u63a7\u4ef6<br \/>\n\u627e\u5230HWND\u540e\uff0c\u5229\u7528HWND\u5bf9\u63a7\u4ef6\u8fdb\u884c\u64cd\u4f5c\uff0c\u6bd4\u5982\u53ef\u4ee5\u4f7f\u5f97\u7070\u8272\u4e0d\u80fd\u70b9\u51fb\u7684\u6309\u94ae\u53ef\u4ee5\u70b9\u51fb\u7684\u51fd\u6570EnableWindow\u3002\u6574\u4e2a\u5e94\u7528\u7684\u6240\u6709\u63a7\u4ef6\u5f62\u6210\u7684\u6811\u5f62\u5217\u8868\uff0c\u90fd\u662f\u88abWindows\u64cd\u4f5c\u7cfb\u7edf\u638c\u63e1\u7684\u3002<br \/>\n<strong>1.3 \u6743\u9650<\/strong><br \/>\n\u5229\u7528Win32API\u5f00\u53d1\u51fa\u6765\u7684\u7a0b\u5e8f\uff0c\u5177\u5907\u8d85\u7ea7\u5927\u7684\u6743\u9650\uff0c\u6bd4\u5982\u4e0a\u9762\u63d0\u5230\u7684\u83b7\u53d6\u5bc6\u7801\uff0c\u8ba9\u7070\u8272\u6309\u94ae\u53ef\u4ee5\u70b9\u51fb\uff0c\u9664\u6b64\u4e4b\u5916\u8fd8\u53ef\u4ee5\u81ea\u52a8\u626b\u63cfU\u76d8\uff0c\u8fd8\u53ef\u4ee5\u4fee\u6539\u5176\u5b83\u8fdb\u7a0b\u7684\u884c\u4e3a\uff0c\u8fd9\u6837\u5bb9\u6613\u4ea7\u751f\u5f88\u591a\u574f\u7a0b\u5e8f\uff0c\u4e8e\u662f\u9700\u8981\u6740\u6bd2\u8f6f\u4ef6<br \/>\n\u5f88\u6709\u5fc5\u8981\u5b58\u5728\uff0c\u6216\u8005\u90e8\u5206API\u9700\u8981\u7ba1\u7406\u5458\u624d\u80fd\u8fd0\u884c\uff08\u8fd9\u4e00\u62db\u5927\u90e8\u5206\u6ca1\u7528\uff0c\u5927\u90e8\u5206\u7528\u6237\u4f1a\u653e\u884c\uff09\uff0c\u5373\u4f7f\u5b9e\u5728\u76ee\u524dWindows10\/11\u7684Windows Defender\u5f00\u542f\u7684\u60c5\u51b5\u4e0b\uff0c\u4ecd\u7136\u4e0d\u6562\u968f\u610f\u4e0b\u8f7d\u548c\u8fd0\u884c\u4e0d\u660e\u6765\u5386\u7684\u7a0b\u5e8f\u3002<br \/>\n<strong>2. WinFrom<\/strong><br \/>\n<strong>2.1 \u4f9d\u8d56<\/strong><br \/>\n\u56e0\u4e3aWin32API\u7684\u5f00\u53d1\u662fC\/C++\u8bed\u8a00\u7684\uff0c\u9700\u8981\u4e86\u89e3\u6bd4\u8f83\u591a\u7684\u77e5\u8bc6\u548c\u5185\u5b58\u7ba1\u7406\uff0c\u4e8e\u662f\u5728C#\u8bed\u8a00\u4e0a\u5c01\u88c5\u4e86\u5927\u90e8\u5206Win32API\uff0c\u7279\u522b\u662f\u7a97\u53e3\u90e8\u5206\u7684API\u5f62\u6210\u4e86WinForm\u5f00\u53d1<br \/>\n<strong>2.2 UI\u7ed8\u5236\u65b9\u5f0f<\/strong><br \/>\n\u540cWin32\u7a0b\u5e8f<br \/>\n<strong>2.3 \u6743\u9650<\/strong><br \/>\n\u540cWin32\u7a0b\u5e8f\uff0cC# API\u4e0d\u8db3\u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u5229\u7528C#\u8c03\u7528C\u51fd\u6570\u7684\u65b9\u5f0f\u5b9e\u73b0<br \/>\n<strong>3. WPF<\/strong><br \/>\n<strong>3.1 \u4f9d\u8d56<\/strong><br \/>\n\u65e0<br \/>\n<strong>3.2 UI\u7ed8\u5236\u65b9\u5f0f<\/strong><br \/>\n\u8fdb\u7a0b\u53ea\u5269\u4e0b\u4e00\u4e2a\u4e3b\u7a97\u53e3\uff0c\u4e3b\u7a97\u53e3\u5185\u7684\u6240\u6709\u5143\u7d20\u5f62\u6210\u7684\u6811\u72b6\u5217\u8868<br \/>\n\uff0c\u5bf9Windows\u64cd\u4f5c\u7cfb\u7edf\u6765\u8bb2\u662f\u4e0d\u4e86\u89e3\u7684\uff0cWPF\u7a0b\u5e8f\u81ea\u5df1\u63a5\u7ba1\u4e86\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u7684\u7ed8\u5236\uff0c\u548c\u4e8b\u4ef6\u54cd\u5e94\uff0c\u610f\u5473\u7740\uff0cWPF\u7a0b\u5e8f\u5bf9\u7a97\u53e3\u6d88\u606f\u5faa\u73af\u4ec5\u4ec5\u4f9d\u8d56\u4e3b\u7a97\u53e3\u7684\u6d88\u606f\uff0c\u7136\u540e\u81ea\u5df1\u5bf9\u4e3b\u7a97\u53e3\u7684\u6240\u6709\u6d88\u606f\u8fdb\u884c\u8f6c\u53d1\uff0c\u4e0d\u4f9d\u8d56Windows\u64cd\u4f5c\u7cfb\u7edf\u6765\u8f6c\u53d1\uff0c\u8fd9\u6837\u6709\u4e00\u4e2a\u597d\u5904\u662f\u7a0b\u5e8f\u66f4\u5b89\u5168\uff0c\u522b\u4eba\u518d\u4e5f\u83b7\u53d6\u4e0d\u5230\u7a0b\u5e8f\u4e2d\u7684\u5bc6\u7801\u6846\u63a7\u4ef6\uff0c\u56e0\u4e3a\u5bc6\u7801\u6846\u4e0d\u5b58\u5728HWND\uff0c\u65e0\u6cd5\u88ab\u904d\u5386\u5230\u3002\u8fd8\u6709\u4e00\u4e2a\u597d\u5904\u5f97\u76ca\u4e8eGPU\u7684\u5e2e\u5fd9\uff0c\u754c\u9762\u66f4\u6f02\u4eae\u4e86\u3002<br \/>\n<strong>3.3 \u6743\u9650<\/strong><br \/>\n\u540cWin32\u7a0b\u5e8f\uff0cAPI\u4e0d\u8db3\u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u5229\u7528C#\u8c03\u7528C\u51fd\u6570\u7684\u65b9\u5f0f\u5b9e\u73b0<br \/>\n<strong>4. UWP<\/strong><br \/>\n<strong>4.1 \u4f9d\u8d56<\/strong><br \/>\n\u4e0a\u9762\u63d0\u5230\u7684\u51e0\u4e2a\u7a0b\u5e8f\uff0c\u6743\u9650\u90fd\u53ef\u4ee5\u5f88\u5927\uff0c\u79fb\u52a8\u65f6\u4ee3\u7684\u6c99\u76d2\u673a\u5236\u9700\u8981\u4e00\u79cd\u65b9\u6848\uff0c\u4f7f\u5f97\u5b89\u88c5\uff0c\u5378\u8f7d\uff0c\u6743\u9650\u63a7\u5236\u660e\u786e\u3002<br \/>\nUWP\u4e0a\u53ef\u4ee5\u7528\u7684\u51fd\u6570\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>WinRT\u8fd0\u884c\u65f6<\/li>\n<li>\u90e8\u5206Win32API\u53ef\u4ee5\u7528\uff08\u6bd4\u5982socket\u51fd\u6570connect\uff09<\/li>\n<li>\u5927\u90e8\u5206COM\u7ec4\u4ef6\u53ef\u4ee5\u7528<\/li>\n<li>\u8fd8\u6709\u7684\u90e8\u5206\u9700\u8981\u770b\u5fae\u8f6f\u63d0\u4f9b\u7684\u5217\u8868<br \/>\n<strong>4.2 UI\u7ed8\u5236\u65b9\u5f0f<\/strong><br \/>\n\u539f\u7406\u548cAPI\u90fd\u5f88\u76f8\u4f3cWPF\uff0c\u754c\u9762API\u4e3b\u8981\u662f\u505a\u4e86\u51cf\u5c11\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u80fd\u8fd0\u884c\u5728\u8f83\u5dee\u7684\u8bbe\u5907\u4e0a\uff0c\u540c\u65f6\u547d\u540d\u7a7a\u95f4\u53d1\u751f\u53d8\u5316\u3002<br \/>\n\u63a7\u4ef6\u4e3e\u4f8b Windows.UI.Xaml.Controls.Grid\uff0c\u5728\u6211\u7684\u7535\u8111\u4e0a\uff0c\u5b83\u6765\u81ea\u4e8eE:\\WindowsKits\\10\\References\\10.0.19041.0\\Windows.Foundation.UniversalApiContract\\10.0.0.0\\Windows.Foundation.UniversalApiContract.winmd\uff0c\u66f4\u65b0\u9891\u7387\u540c\u64cd\u4f5c\u7cfb\u7edf\uff0c\u800c\u4e14\u65e7\u7248\u672c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u518d\u66f4\u65b0\uff0c\u5e38\u5e38\u9047\u5230\u5728\u65b0\u7248\u672c\u5f00\u53d1\u7684xaml\u6587\u4ef6\uff0c\u5728\u65e7\u7248\u672c\u4e2d\u8fd0\u884ccrash\uff0c\u56e0\u4e3a\u65e7\u7248\u672c\u7f3a\u5931\u63a7\u4ef6\u7684\u67d0\u4e2a\u5c5e\u6027\uff0c\u4e3a\u4e86\u89e3\u51b3\u4ee5\u4e0a\u95ee\u9898\uff0c\u6709\u4e86\u540e\u9762\u7684WinUI.<br \/>\n<strong>4.3 \u6743\u9650<\/strong><br \/>\n\u7c7b\u4f3c\u4e8e\u624b\u673a\u5e94\u7528\uff0c\u9ed8\u8ba4\u53ea\u80fd\u8bbf\u95ee\u7f51\u7edc\uff0c\u65e0\u6cd5\u548c\u5f53\u524d\u8ba1\u7b97\u673a\uff08\u4e0d\u5305\u542b\u5f53\u524d\u8ba1\u7b97\u673a\u7684\u865a\u62df\u673a\uff09\u4e2d\u7684\u5176\u4ed6\u5e94\u7528\u8fdb\u884cTCP\/IP\u901a\u4fe1\uff0c\u672a\u7ecf\u7528\u6237\u540c\u610f\uff0c\u4e0d\u5f97\u626b\u63cf\u5176\u4ed6\u76d8\u7b26\uff08D: E:), \u6743\u9650\u5f97\u5230\u7684\u63a7\u5236 \u7f3a\u70b9\u5f88\u591a\uff0c\u6240\u4ee5\u5f00\u53d1\u4eba\u5458\u4e0d\u5f00\u5fc3\uff1a<\/li>\n<li>\u90e8\u5206API\u6027\u80fd\u6bd4\u4f20\u7edfWin32\u7a0b\u5e8f\u5dee\uff0c\u6bd4\u5982\u904d\u5386\u6587\u4ef6\uff0c\u56e0\u4e3a\u9700\u8981\u4e2d\u95f4\u5e94\u7528\u6765\u4f20\u9012\u67e5\u627e\u5230\u7684\u6570\u636e\uff0c\u52a0\u4e0aAPI\u90fd\u662f\u5f02\u6b65\u7684\u5b58\u5728\u7ebf\u7a0b\u7684\u5207\u6362\u3002<\/li>\n<li>\u9ed8\u8ba4\u6700\u5c0f\u5316\u4f1a\u6682\u505c\u5e94\u7528\uff0c\u8fd9\u6837\u4f7f\u5f97\u7f51\u7edc\u8bf7\u6c42\u4e5f\u6682\u505c\u4e86<\/li>\n<li>\u65e0\u6cd5\u628a\u56fe\u6807\u653e\u5165\u7cfb\u7edf\u6258\u76d8<\/li>\n<li>socket\u65e0\u6cd5\u4e0e\u672c\u673a\u5e94\u7528\u901a\u8baf<br \/>\n<strong>5. WinUI<\/strong><br \/>\n<strong>5.1 \u4f9d\u8d56<\/strong><br \/>\nWinUI2\u4f9d\u8d56UWP<br \/>\nWinUI3\u4e0d\u4f9d\u8d56UWP<br \/>\n\u5fae\u8f6fWinUI\u7684\u4ecb\u7ecd<br \/>\n<strong>5.2 UI\u7ed8\u5236\u65b9\u5f0f<\/strong><br \/>\n\u65e0\u8bba\u662fWinUI2\u8fd8\u662fWinUI3\uff0c\u65e0\u8bba\u662fWinUI3\u7684Win32\u7a0b\u5e8f\u8fd8\u662fUWP\u7a0b\u5e8f\uff0c\u7ed8\u5236\u65b9\u5f0f\u540cWPF\uff1a\u81ea\u7ed8<br \/>\n\u63a7\u4ef6\u4e3e\u4f8b Microsoft.UI.Xaml.Controls\uff0c\u5728\u6211\u7684\u7535\u8111\u4e0a\uff0c\u5b83\u6765\u81ea\u4e8eC:\\Users\\xxx.nuget\\packages\\microsoft.ui.xaml\\2.7.0\\lib\\uap10.0\\Microsoft.UI.Xaml.winmd\uff0c\u66f4\u65b0\u5f88\u5feb\uff0c\u66f4\u65b0\u540e\u53ef\u4ee5\u8fd0\u884c\u4e0e\u65e7\u7248\u672c\u7684\u64cd\u4f5c\u7cfb\u7edf<br \/>\n<strong>5.3 \u6743\u9650<\/strong><br \/>\nWinUI2\u6743\u9650\u540cUWP<br \/>\nWinUI3\u6743\u9650\u8981\u770b\u521b\u5efa\u7684\u662f\u4e0d\u662fWin32\u7a0b\u5e8f\uff0c\u5982\u679c\u662fWin32\u7a0b\u5e8f\uff0c\u6700\u5c0f\u5316\u540e\u4e0d\u4f1a\u6682\u505c\u5e94\u7528\uff0c\u5982\u679c\u662fUWP\u7a0b\u5e8f\uff0c\u5219\u540cUWP<br \/>\n<strong>6.MAUI<\/strong><br \/>\n\u4e00\u5957\u671f\u671b\u7528\u4e00\u4e2a\u5e93\u6765\u62bd\u8c61Windows\/iOS\/Android\u5e73\u53f0\u7684\u754c\u9762\u5e93\uff0c\u5728Windows\u7aef\u5b83\u4f9d\u8d56WinUI 3,\u5728iOS\u7aef\uff0c\u5b83\u4f9d\u8d56xamarin.iOS\uff0c\u5728Andoird\u7aef\uff0c\u5b83\u4f9d\u8d56xamarin.Android\u3002xamarin.iOS<br \/>\n\u548cxamarin.Android\u5c5e\u4e8e\u5bf9\u5e94\u5e73\u53f0\u7684\u539f\u751f\u5f00\u53d1\uff0c\u4e0d\u5c5e\u4e8e\u81ea\u7ed8\u3002<\/li>\n<\/ul>\n<p>\u9898\u4e3b\u63d0\u5230\u7684\u7591\u95ee<br \/>\n\u95ee: \u90a3\u4e48\u662f\u5426\u610f\u5473\u7740\u6211\u53ea\u8981\u628a\u8fd9\u4e2a\u5305\u6362\u4e00\u4e0b (\u4ee5\u53ca\u5bf9\u5e94\u7684 xaml \u7684\u5305), \u6211\u7684\u5e94\u7528\u5c31\u53d8\u6210\u53e6\u4e00\u79cd\u7c7b\u578b\u4e86?<br \/>\n\u7b54: \u5e94\u7528\u7c7b\u578b\u5b9a\u4e49\u5728csproj\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u6587\u672c\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u7684\u5c5e\u6027\u6765\u66f4\u6362\u7c7b\u578b\uff0c\u4e00\u822c\u66f4\u6362\u6bd4\u8f83\u9ebb\u70e6\uff0c\u5982\u679c\u60f3\u66f4\u6362\uff0c\u8fd8\u662f\u65b0\u5efa\u4e00\u4e2a\u5de5\u7a0b\uff0c\u7136\u540e\u628a\u6587\u4ef6\u62f7\u8d1d\u8fc7\u53bb\u6bd4\u8f83\u597d<br \/>\n\u95ee\uff1a\u90a3\u4e48 UWP \u9650\u5236\u8c03\u7528 win32 \u7684 api \u662f\u600e\u4e48\u9650\u5236\u7684\u5462?<br \/>\n\u7b54\uff1a\u6240\u6709\u6d89\u53ca\u5230\u53ef\u80fd\u8df3\u51fa\u6c99\u76d2\u7684API\u90fd\u4f1a\u9650\u5236\uff0c\u9650\u5236\u65b9\u5f0f\u6709\u4e24\u79cd<\/p>\n<ul>\n<li>\u4e00\u79cd\u662f\u5229\u7528\u5b8f\u5b9a\u4e49\u4f7f\u5f97API\u6ca1\u6709\u5b9a\u4e49\uff0c\u4ece\u800c\u7f16\u8bd1\u4e0d\u8fc7\uff0c\u8fbe\u5230\u4e0d\u5141\u8bb8\u8c03\u7528\uff0c<\/li>\n<li>\u4e00\u79cd\u662f\u8c03\u7528\u540e\uff0c\u88ab\u8c03\u7528\u7684\u51fd\u6570\u5224\u65ad\u5f53\u524d\u662f\u4e0d\u662fUWP\u73af\u5883\uff0c\u5982\u679c\u662fUWP\u73af\u5883\u5219\u4e0d\u8d77\u4f5c\u7528<br \/>\nwin32 API\u80fd\u4e0d\u80fd\u7528\uff0c\u770b\u5177\u4f53API\u6587\u6863\u6700\u51c6\u786e\uff0c\u6587\u6863\u6700\u4e0b\u65b9\u90fd\u4f1a\u8868\u660e\u662f\u5426\u53ef\u4ee5\u7528\u4e8eUWP\uff0c\u4e5f\u6709\u8fd9\u6837\u7684\u9875\u9762\u6765\u8868\u660e\u4e86\u54ea\u4e00\u7c7b\u4e0d\u80fd\u7528\uff0c\u6bd4\u5982<a href=\"https:\/\/docs.microsoft.com\/en-us\/uwp\/win32-and-com\/win32-and-com-for-uwp-apps\">\u6587\u6863\u8fd9\u5728\u91cc<\/a><br \/>\n\u95ee\uff1a\u6309\u7167\u73b0\u5728\u7684\u6761\u4ef6\uff0c\u6211\u53ea\u8981\u5355\u72ec\u5199\u4e2a\u7c7b\u5f15\u4e2a\u5176\u4ed6\u7684 nuget\u5305\u5c31\u80fd\u95f4\u63a5\u8c03\u7528 win32 \u7684 api \u4e86\u5440<br \/>\n\u7b54\uff1a\u7684\u786e\u53ef\u4ee5\u8fd9\u4e48\u505a\uff0c\u5982\u679c\u5f15\u7528\u7684API\u90fd\u53ef\u4ee5\u5728UWP\u4e2d\u4f7f\u7528\uff0c\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4e0d\u5e78\u7684\u662f\uff0c\u5927\u591a\u6570nuget\u5305\u90fd\u5305\u542b\u4e00\u4e9b\u4e0d\u80fd\u5728UWP\u4e2d\u4f7f\u7528\u7684API\uff0c\u4f7f\u5f97UWP\u5e94\u7528\u65e0\u6cd5\u63d0\u4ea4\u3002<br \/>\n\u95ee\uff1aWinUI \u8bf4\u7684\u652f\u6301 Win32 \u7a0b\u5e8f\u662f\u4ec0\u4e48\u610f\u601d\u5462\uff1f<br \/>\n\u4ee3\u8868\u652f\u6301\u201c\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548c\u8868\u73b0\u5f62\u5f0f\u201d\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6700\u5c0f\u5316\u4e0d\u6682\u505c\uff0c\u4e0d\u4ee3\u8868Win32 UI\uff0c\u662f\u5426\u4ee3\u8868Win32 API\u770b\u5229\u7528WinUI3\u521b\u5efa\u4ec0\u4e48\u7c7b\u578b\u7684\u7a0b\u5e8f\u4e86(UWP \u8fd8\u662f Win32).<br \/>\n\u989d\u5916\u8bf4\u660e<br \/>\n\u5982\u679cWin32\u5e94\u7528\u88ab\u6253\u5305\u5230\u5e94\u7528\u5546\u5e97\uff0c\u5219\u90e8\u5206API\u4f1a\u5931\u6548\uff0c\u6bd4\u5982\u5176\u4ed6\u7b54\u4e3b\u63d0\u5230\u7684\u6ce8\u518c\u8868\u64cd\u4f5c\u5176\u5b9e\u662f\u548c\u64cd\u4f5c\u7cfb\u7edf\u7684\u6ce8\u518c\u8868\u9694\u79bb\u7684\uff0c\u8fd9\u662f\u4f9d\u9760API\u5185\u90e8\u5b9e\u73b0\u7684\uff0c\u4f1a\u5224\u65ad\u5f53\u524d\u8fd0\u884c\u7684APP\u662f\u4e0d\u662fUWP\u5e94\u7528\u3002<br \/>\nWindows Store\u65e2\u53ef\u4ee5\u4e0a\u4f20UWP\u5e94\u7528\uff0c\u4e5f\u53ef\u4ee5\u4e0a\u4f20Win32\u5e94\u7528\uff0c\u5982\u679c\u4e0a\u4f20\u7684\u662fWin32\u5e94\u7528\uff0c\u90e8\u5206API\u8fd8\u662f\u4f1a\u88ab\u7981\u6b62\u4f7f\u7528\uff0c\u6bd4\u5982\u521b\u5efa\u8fdb\u7a0b\uff0c\u5176\u4ed6\u53ef\u80fd\u6709\u95ee\u9898\u7684API\u9700\u8981\u5411Microsoft\u8bf4\u660e\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>\u90a3\u4e48WinUI 3\u548cWPF\u5230\u5e95\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u96be\u9053\u53ea\u662f\u4e3a\u4e86\u7edf\u4e00WPF\u548cUWP\u7684UI\u5f00\u53d1\uff1f\u4e5f\u8bb8\u662f\u5427\u3002<br \/>\n\u7531\u4e8e\u672c\u4eba\u5bf9MFC\u73af\u5883\u4e0b\u7684Win32\u7a0b\u5e8f\u548cUWP\u5f88\u719f\u6089\uff0c\u5176\u4ed6\u90fd\u662f\u4e0d\u6df1\u5165\uff0c\u53ef\u80fd\u6709\u9519\u8bef\uff0c\u6b22\u8fce\u8ba8\u8bba\u3002<\/p>\n<p>\u4f5c\u8005\uff1ashuice<br \/>\n\u94fe\u63a5\uff1a<a href=\"https:\/\/www.zhihu.com\/question\/498398314\/answer\/2221576589\"><a href=\"https:\/\/www.zhihu.com\/question\/498398314\/answer\/2221576589\">https:\/\/www.zhihu.com\/question\/498398314\/answer\/2221576589<\/a><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WPF\u3001WinUI\u3001UWP\u3001WinForm \u5728\u9879\u76ee\u4e2d\u5230\u5e95\u662f\u600e\u4e48\u533a\u522b\u7684\uff1f \u5fae\u8f6f\u7684UI\u6280\u672f\u6709\u5f88\u591a\uff0c\u7684\u786e\u8ba9\u5f00\u53d1\u8005\u5934\u6655\uff0c\u7279\u522b\u662f\u5f88\u591a\u547d\u540d\u7a7a\u95f4\u5305\u542bWindows\u548cMicrosoft\u8fd9\u4e24\u4e2a\u540d\u5b57\u3002 \u5148\u5355\u72ec\u8bf4\u660eWin32\uff0cWin32\u67093\u4e2a\u542b\u4e49 Win32 UI\uff1a\u6307\u7684\u662f\u754c\u9762\u4e0a\u7684\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u90fd\u662f\u539f\u751fWindows\u63a7\u4ef6\uff0c\u6bcf\u4e2a\u63a7\u4ef6\u90fd\u662f\u4e00\u4e2aHWND Win32 API\uff1a\u6307C\u5f62\u5f0f\u7684\uff0c\u5927\u90e8\u5206\u90fd\u4e0d\u7b26\u5408UWP\u6c99\u76d2\u73af\u5883\u7684API Win32 \u7a0b\u5e8f\uff1a\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548c\u8868\u73b0\u5f62\u5f0f\uff0c\u9664\u4e86Win32\u5f62\u5f0f\u5219\u662fUWP\u5f62\u5f0f\uff0c\u6240\u4ee5Win32\u5f62\u5f0f\u5305\u542b\u4e86WPF\uff0cWinForm\u3002UWP\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u5f62\u5f0f\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u7279\u70b9\uff0c\u6700\u5c0f\u5316\u4e4b\u540e\uff0c\u7a0b\u5e8f\u6682\u505c\u8fd0\u884c\u3002 \u8fa8\u522b\u65b9\u6cd5 Win32 UI\uff0cWPF\u3001WinUI\u3001UWP\u3001WinForm\u7b49\u7b49\u540d\u8bcd\uff0c\u90fd\u53ef\u4ee5\u7528\u4e09\u65b9\u9762\u6765\u603b\u7ed3\u533a\u522b\uff0c\u4e00\u4e2a\u662f\u7a0b\u5e8f\u4f9d\u8d56\u4ec0\u4e48\uff0c\u4e00\u4e2a\u662fUI\u7ed8\u5236\u65b9\u5f0f\uff0c\u4e00\u4e2a\u662f\u8fd0\u884c\u6743\u9650\u3002 \u4ece\u4ed6\u4eec\u51fa\u751f\u7684\u5148\u540e\u987a\u5e8f\u5f00\u59cb\u8bf4\u8d77 1. Win32 UI 1.1 \u4f9d\u8d56 \u5305\u542b\u4e86\u4e00\u5927\u6279\u7a33\u5b9a\u7684\uff0c\u517c\u5bb9\u7684C\u8bed\u8a00\u7248\u672cWin32API\uff0c\u6bd4\u5982 GetWindowTextA\uff0c\u7528\u6765\u83b7\u53d6\u7a97\u53e3\u6587\u5b57\uff0c\u975e\u5e38\u975e\u5e38\u65e9\u671f\u4e0d\u5c11\u7a0b\u5e8f\u4e5f\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u83b7\u53d6QQ\u5bc6\u7801\u6846\u63a7\u4ef6\u4e2d\u7684\u5bc6\u7801\uff0c\u867d\u7136\u5bc6\u7801\u6846\u4e2d\u6587\u672c\u8868\u73b0\u4e3a\u201c*\u201d\uff0c\u4f46\u662f\u5b9e\u9645\u5b58\u50a8\u7684\u4e3a\u5bc6\u7801\u7684\u5185\u5bb9\u3002 1.2 UI\u7ed8\u5236\u65b9\u5f0f \u754c\u9762\u4e0a\u7684\u5143\u7d20\u90fd\u662f\u7531Windows\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u7684\u63a7\u4ef6\uff0c\u6bd4\u5982\u7f16\u8f91\u6846\uff0c\u6587\u672c\u6846\uff0c\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u90fd\u6709\u81ea\u5df1\u7684HWND\u5f62\u5f0f\u7684HANDLE\uff0c\u5176\u4ed6\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u63a7\u4ef6 \u627e\u5230HWND\u540e\uff0c\u5229\u7528HWND\u5bf9\u63a7\u4ef6\u8fdb\u884c\u64cd\u4f5c\uff0c\u6bd4\u5982\u53ef\u4ee5\u4f7f\u5f97\u7070\u8272\u4e0d\u80fd\u70b9\u51fb\u7684\u6309\u94ae\u53ef\u4ee5\u70b9\u51fb\u7684\u51fd\u6570EnableWindow\u3002\u6574\u4e2a\u5e94\u7528\u7684\u6240\u6709\u63a7\u4ef6\u5f62\u6210\u7684\u6811\u5f62\u5217\u8868\uff0c\u90fd\u662f\u88abWindows\u64cd\u4f5c\u7cfb\u7edf\u638c\u63e1\u7684\u3002 1.3 \u6743\u9650 \u5229\u7528Win32API\u5f00\u53d1\u51fa\u6765\u7684\u7a0b\u5e8f\uff0c\u5177\u5907\u8d85\u7ea7\u5927\u7684\u6743\u9650\uff0c\u6bd4\u5982\u4e0a\u9762\u63d0\u5230\u7684\u83b7\u53d6\u5bc6\u7801\uff0c\u8ba9\u7070\u8272\u6309\u94ae\u53ef\u4ee5\u70b9\u51fb\uff0c\u9664\u6b64\u4e4b\u5916\u8fd8\u53ef\u4ee5\u81ea\u52a8\u626b\u63cfU\u76d8\uff0c\u8fd8\u53ef\u4ee5\u4fee\u6539\u5176\u5b83\u8fdb\u7a0b\u7684\u884c\u4e3a\uff0c\u8fd9\u6837\u5bb9\u6613\u4ea7\u751f\u5f88\u591a\u574f\u7a0b\u5e8f\uff0c\u4e8e\u662f\u9700\u8981\u6740\u6bd2\u8f6f\u4ef6 \u5f88\u6709\u5fc5\u8981\u5b58\u5728\uff0c\u6216\u8005\u90e8\u5206API\u9700\u8981\u7ba1\u7406\u5458\u624d\u80fd\u8fd0\u884c\uff08\u8fd9\u4e00\u62db\u5927\u90e8\u5206\u6ca1\u7528\uff0c\u5927\u90e8\u5206\u7528\u6237\u4f1a\u653e\u884c\uff09\uff0c\u5373\u4f7f\u5b9e\u5728\u76ee\u524dWindows10\/11\u7684Windows Defender\u5f00\u542f\u7684\u60c5\u51b5\u4e0b\uff0c\u4ecd\u7136\u4e0d\u6562\u968f\u610f\u4e0b\u8f7d\u548c\u8fd0\u884c\u4e0d\u660e\u6765\u5386\u7684\u7a0b\u5e8f\u3002 2. WinFrom 2.1 \u4f9d\u8d56 \u56e0\u4e3aWin32API\u7684\u5f00\u53d1\u662fC\/C++\u8bed\u8a00\u7684\uff0c\u9700\u8981\u4e86\u89e3\u6bd4\u8f83\u591a\u7684\u77e5\u8bc6\u548c\u5185\u5b58\u7ba1\u7406\uff0c\u4e8e\u662f\u5728C#\u8bed\u8a00\u4e0a\u5c01\u88c5\u4e86\u5927\u90e8\u5206Win32API\uff0c\u7279\u522b\u662f\u7a97\u53e3\u90e8\u5206\u7684API\u5f62\u6210\u4e86WinForm\u5f00\u53d1 2.2 UI\u7ed8\u5236\u65b9\u5f0f \u540cWin32\u7a0b\u5e8f 2.3 \u6743\u9650 \u540cWin32\u7a0b\u5e8f\uff0cC# API\u4e0d\u8db3\u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u5229\u7528C#\u8c03\u7528C\u51fd\u6570\u7684\u65b9\u5f0f\u5b9e\u73b0 3. WPF 3.1 \u4f9d\u8d56 \u65e0 3.2 UI\u7ed8\u5236\u65b9\u5f0f \u8fdb\u7a0b\u53ea\u5269\u4e0b\u4e00\u4e2a\u4e3b\u7a97\u53e3\uff0c\u4e3b\u7a97\u53e3\u5185\u7684\u6240\u6709\u5143\u7d20\u5f62\u6210\u7684\u6811\u72b6\u5217\u8868 \uff0c\u5bf9Windows\u64cd\u4f5c\u7cfb\u7edf\u6765\u8bb2\u662f\u4e0d\u4e86\u89e3\u7684\uff0cWPF\u7a0b\u5e8f\u81ea\u5df1\u63a5\u7ba1\u4e86\u6bcf\u4e00\u4e2a\u63a7\u4ef6\u7684\u7ed8\u5236\uff0c\u548c\u4e8b\u4ef6\u54cd\u5e94\uff0c\u610f\u5473\u7740\uff0cWPF\u7a0b\u5e8f\u5bf9\u7a97\u53e3\u6d88\u606f\u5faa\u73af\u4ec5\u4ec5\u4f9d\u8d56\u4e3b\u7a97\u53e3\u7684\u6d88\u606f\uff0c\u7136\u540e\u81ea\u5df1\u5bf9\u4e3b\u7a97\u53e3\u7684\u6240\u6709\u6d88\u606f\u8fdb\u884c\u8f6c\u53d1\uff0c\u4e0d\u4f9d\u8d56Windows\u64cd\u4f5c\u7cfb\u7edf\u6765\u8f6c\u53d1\uff0c\u8fd9\u6837\u6709\u4e00\u4e2a\u597d\u5904\u662f\u7a0b\u5e8f\u66f4\u5b89\u5168\uff0c\u522b\u4eba\u518d\u4e5f\u83b7\u53d6\u4e0d\u5230\u7a0b\u5e8f\u4e2d\u7684\u5bc6\u7801\u6846\u63a7\u4ef6\uff0c\u56e0\u4e3a\u5bc6\u7801\u6846\u4e0d\u5b58\u5728HWND\uff0c\u65e0\u6cd5\u88ab\u904d\u5386\u5230\u3002\u8fd8\u6709\u4e00\u4e2a\u597d\u5904\u5f97\u76ca\u4e8eGPU\u7684\u5e2e\u5fd9\uff0c\u754c\u9762\u66f4\u6f02\u4eae\u4e86\u3002 3.3 \u6743\u9650 \u540cWin32\u7a0b\u5e8f\uff0cAPI\u4e0d\u8db3\u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u5229\u7528C#\u8c03\u7528C\u51fd\u6570\u7684\u65b9\u5f0f\u5b9e\u73b0 4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-csharp"],"_links":{"self":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=132"}],"version-history":[{"count":0,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions"}],"wp:attachment":[{"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}