القديم الجديد win32api
توفر هذه الصفحة قائمة بالروابط لمجموعة فرعية من منشورات مدونة Raymond Chen الشهيرة The Old New Thing . المجموعة الفرعية محدودة بشكل أساسي في Win32Api وبعض الأشياء ذات الصلة كوم.
السبب في الحفاظ على هذه الصفحة هو أنه غالبًا ما يوفر معلومات مفقودة في MSDN أو الموصوفة هناك بطريقة خفية ، وأيضًا لأن المدونة ليست قابلة للبحث بسهولة.
يتم تصنيف الروابط هنا من خلال موضوعها بدلاً من ترتيب زمني. في بعض الأحيان ، عند الاقتضاء ، يمكن وضع منشور واحد في فئات متعددة.
في بعض الحالات (النادرة جدًا) ، يتم تضمين روابط لمصادر أخرى إذا كانت مفيدة.
إخلاء المسئولية: أنا لا أدعي تأليف أي محتويات مرتبطة. هذا يتعلق فقط بالتنظيم المفيد للمقالات العظيمة التي كتبها ريموند على مر السنين.
جدول المحتويات
- العمليات والمواضيع
- العمليات
- المواضيع
- برك الموضوعات
- خيط تقارب الكائنات
- كومة الموضوع
- الألياف
- التزامن
-
WaitOnAddress()
-
WaitForMultipleObjects()
والأقارب - أنماط خالية من القفل
- DLLs
- موارد
- موارد النقطات والأيقونة
- قوالب الحوار
- قوالب القائمة وموارد التسريع
- موارد السلسلة
- قوالب الإصدار
- البيانات والموارد المخصصة
- التطبيق (ككل)
-
HWND
(وجهة النظر العامة)- التسلسل الهرمي لنظام التشغيل Windows
- أنماط النوافذ
- فئات النوافذ
- نوافذ المستوى الأعلى
- إطار النافذة والتسمية التوضيحية
- DWM
- مربعات الحوار
- الحوارات المتداخلة والمدمجة
- مربعات حوار مشتركة
- السيطرة على الملاحة
- مدير الحوار
- طريقة
- أوراق الممتلكات
- الضوابط
- عناصر التحكم في الرسوم المتحركة
- أزرار
- مربعات التحرير والسرد
- تحرير الضوابط
- قائمة المشاهدات
- ضوابط النص الغنية
- أشرطة التمرير
- ضوابط ثابتة
- أشرطة الأدوات
- تلميحات الأدوات
- أشرطة التعقب
- وجهات نظر قائمة الأشجار
- معالجة الرسائل
- رسائل محددة
- إشعارات
- بناء النوافذ وتدميره
- رسائل هندسة النوافذ
- رسائل الطلاء نافذة
- رسائل تركيز النافذة
- رسائل لوحة المفاتيح
- رسائل الماوس
- رسائل الحوار
- رسائل نافذة أخرى
- رسائل النظام
- GDI
- المؤشرات
- فرش
- أقلام
- نقار النقط
- ديب
-
LockWindowUpdate()
- رسم العناصر القياسية
-
UXTHEME.DLL
- شاشات متعددة
- إمكانية الوصول
- كوم
- إعلان واجهات كوم
- شقق كوم
- كوم تهيئة
- كوم Static Store
- com marchaling
- com معالجة الأخطاء
- كوم واجهات غير متزامنة
- GUIDS
- كوم سلاسل
- كوم المتغيرات
-
IUnknown
-
IMoniker
-
ICallback
-
IContextMenu
-
IFileDialog
-
IMultiLanguage
-
INamespaceWalk
-
IStream
-
IVirtualDesktopManager
- الحافظة
- سحب وإسقاط
- تعداد
- صدَفَة
- أشياء كوم غير مصنف
- ذاكرة
- المدخلات والمخرجات
- المدخلات والإخراج غير المتزامن
- الملفات والأدلة
- ACL
- أذونات الأمن والسمات والمعرفات
- السجل
- سلاسل ولغات
- خدمات NT
- غير مصنف
العمليات والمواضيع
العمليات
- لا تنتظر
CreateProcess
حتى تبدأ العملية - لماذا تقوم وظيفة
CreateProcess
بتعديل سطر أوامر الإدخال الخاص بها؟ - لماذا يأخذ الناس قفلًا حول مكالمات
CreateProcess
؟ - تعطيل مربع الحوار تحطم البرنامج
- كيف أقوم بتمرير الكثير من البيانات إلى عملية عندما تبدأ؟
- ما هو الغرض من معلمة
hPrevInstance
إلى WinMain
؟ - هل
RunAsInvoker
Secret ، حتى أعلى UAC؟ - كيف يمكنني منع عملية الطفل من عرض مربع حوار الإبلاغ عن خطأ Windows؟
- كيف ينجح ذلك في
WriteProcessMemory
في الكتابة إلى الذاكرة للقراءة فقط؟ - هل من الجيد السماح
WriteProcessMemory
بإدارة حماية الصفحة بالنسبة لي؟ - كيف يمكنني إطلاق عملية غير مرتبطة من عمليتي المرتفعة ، Redux
- كيف يمكنني التحقق من مستوى سلامة عمليتي؟
- هل صحيح أن رفع استثناء منظم من معالج استثناء منظم ينهي العملية؟
- طريقة أكثر مباشرة وخالية من الأخطاء لإنشاء عملية في كائن عمل
المواضيع
- موضوع غير صالح ومعرفات العملية
- لماذا تعامل الخيط الخاص بي فجأة سيئ؟ كل ما فعلته هو الانتظار!
- ماذا يحدث إذا قمت ببساطة بالعودة من رد الاتصال عبر سلسلة الرسائل إلى
_beginthread
و _beginthreadex
؟ - لماذا يجب ألا تعلق موضوعًا أبدًا
- مخاطر النوم على موضوع واجهة المستخدم
- في السعي لتحقيق قائمة انتظار الرسائل
- تعداد المواضيع في عملية
- Win32 واجهة المستخدم يعمل بطبيعته ذات الخيوط الواحدة
- ما مدى سوء تأخير إغلاق مقبض الخيط لفترة طويلة بعد خروج الموضوع؟
- إذا اتصلت بـ
GetExitCodeThread
لخيط أعرفه بالتأكيد قد خرج ، فلماذا لا يزال يقول STILL_ACTIVE
؟ - هل هناك مشكلة في
CreateRemoteThread
على أنظمة 64 بت؟ - هل وظيفة
TerminateThread
متزامنة؟ - إزالة
TerminateThread
من الكود الذي ينتظر كائن عمل لتفريغ - ما هي الهدف من
FreeLibraryAndExitThread
؟ - ماذا يحدث إذا أعطيت قيمًا متناقضة لالتزام المكدس ومكدس؟
برك الموضوعات
- ماذا تعني المعلمة
msWindowLength
بالضبط إلى SetThreadpoolTimer
؟ - ما الفرق بين
CreateTimerQueueTimer
و SetThreadpoolTimer
؟ - كيفية تجنب الوصول إلى الذاكرة المحررة عند إلغاء رد الاتصال على تجمع الخيوط
- تجنب الجمود عند إلغاء رد اتصال تجمع مؤشرات الترابط ، الجزء 1: بيانات رد الاتصال الخارجي
- تجنب الجمود عند إلغاء رد الاتصال على تجمع الخيوط ، الجزء 2: الرجوع إلى الكائن المحتوي
- GOTCHA: لن ينتظر مؤقت Threadpool الدوري حتى إكمال القراد السابق
- لماذا أحصل على استثناء من تجمع الخيوط أثناء إيقاف العملية؟
- ماذا يحدث للقيمة التي تم إرجاعها من الوظيفة التي تم تمريرها إلى
QueueUserWorkItem
؟ - النموذج العقلي لـ
StartThreadpoolIo
- كيف يمكنني اكتشاف أن عنصر عمل تجمع الخيوط يستغرق وقتًا طويلاً؟
- كيف يمكنني إغلاق تجمع الخيوط وإلغاء جميع الأعمال التي تم وضعها في قائمة الانتظار؟
خيط تقارب الكائنات
- مؤشر ترابط تقارب كائنات واجهة المستخدم ، الجزء 1: مقابض النافذة
- تقارب مؤشر ترابط كائنات واجهة المستخدم ، الجزء 2: سياقات الجهاز
- خيط تقارب كائنات واجهة المستخدم ، الجزء 3: القوائم ، الرموز ، المؤشرات ، وجداول التسريع
- تقارب مؤشر ترابط كائنات واجهة المستخدم ، الجزء 4: كائنات GDI وغيرها من الملاحظات على التقارب
- مؤشر ترابط تقارب كائنات واجهة المستخدم ، الجزء 5: تنظيف الكائن
- تقارب موضوع كائنات واجهة المستخدم: إضافة
كومة الموضوع
- كيف يمكنني توسيع مكدس موضوعي في وقت التشغيل؟
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 1
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 2
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 3
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 4
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 5
- استخدام الألياف لتوسيع مكدس مؤشر ترابط في وقت التشغيل ، الجزء 6
- مقارنة الألياف مع المواضيع لغرض توسيع مكدس مؤشر الترابط في وقت التشغيل
- تحديد مقدار مساحة المكدس تقريبًا ، الجزء 1
- تحديد مقدار مساحة المكدس تقريبًا ، الجزء 2
الألياف
- ماذا يحدث للألياف التي تم تشغيلها على خيط عندما يخرج الخيط؟
- من الجيد استخدام الألياف ، ولكن يجب أن يكون الجميع على متن الخطة
- الألياف ليست مفيدة أكثر من ذلك بكثير ؛ هناك زاوية واحدة فقط لا تزال مفيدة لسبب لا علاقة للألياف
التزامن
- فهم عواقب
WAIT_ABANDONED
- أحداث ويندوز الرئيسية والأقسام الهامة وميزات مزامنة Vista الجديدة
- الجمع بين قائمة انتظار العمل للأحداث المتميزة ، والطلب غير مهم ، مع حدث إعادة التقييم التلقائي
- ما مدى انتعاش أقفال SRW ، خاصة عندما يكون هناك القراء والكتاب؟
- يمكنك استخدام ملف ككائن التزامن أيضًا
- هل يمكنني الانتظار حتى يصبح حدث kernel غير مجهول ؟
- إذا كان قفل القارئ/الكاتب النحيف (
SRWLOCK
) لا يتذكر من هو مالك القفل المشترك ، فهل هذا يعني أنه من المقبول الحصول عليه بشكل متكرر؟
WaitOnAddress()
- يتيح لك
WaitOnAddress
إنشاء كائن المزامنة من أي متغير بيانات ، حتى بايت - تنفيذ حاجز التزامن من حيث
WaitOnAddress
- تنفيذ قسم مهم من حيث
WaitOnAddress
- تمديد قسمنا الحرج بناءً على
WaitOnAddress
لدعم الموعد - مقارنة
WaitOnAddress
مع Futexes (Futexi؟ Futexen؟) - إنشاء إشارة من
WaitOnAddress
- إنشاء مربع مع عدد أقصى من
WaitOnAddress
- إنشاء حدث يعيد اليدوي من
WaitOnAddress
- إنشاء حدث تلقائي من إعادة التوصيل من
WaitOnAddress
WaitForMultipleObjects()
والأقارب
-
MsgWaitForMultipleObjects
وحالة قائمة الانتظار - يمكنك استدعاء
MsgWaitForMultipleObjects
مع مقابض صفر - ضخ الرسائل أثناء الانتظار لفترة من الوقت
- في انتظار جميع المقابض مع
MsgWaitForMultipleObjects
هو خطأ في انتظار حدوثه - لماذا
WaitForMultipleObjects
return ERROR_INVALID_PARAMETER
عندما تبدو جميع المعلمات صالحة بالنسبة لي؟ - إذا تسبب أكثر من كائن في عودة
WaitForMultipleObjects
، فكيف أعرف عن الكائنات الأخرى؟ - ما الهدف من تمرير حدث لا يتجول أبدًا إلى
MsgWaitForMultipleObjects
؟
أنماط خالية من القفل
- قفل العديد من المنتجات العديدة/المستهلك المفردة: قائمة انتظار عمل مع مفصل المهمة
- قفل العديد من المنتجات الحرة/المستهلك الفردي: قائمة انتظار عمل حيث يفوز آخر واحد
- قفل أنماط عديدة المنتج/المستهلك المفردة: قائمة انتظار من أحداث متطابقة غير قابلة للتكافؤ
- قفل العديد من المنتجات العديدة/المستهلك المفردة: قائمة انتظار عمل للأحداث المتميزة ، والترتيب غير مهم
- قفل العديد من المنتجات الحرة/المستهلك الواحد: قائمة انتظار عمل للأحداث المتميزة ، FIFO
- قفل العديد من المنتجات العديدة/المستهلك المفردة: قائمة انتظار عمل للأحداث المتميزة ، والطلب غير مهم ، سؤال المتابعة
DLLs
- لا تثق بعنوان الإرجاع
- لماذا لا يمكنني
GetProcAddress
وظيفة أنا dllexport'ed؟ - ما هو الفرق بين
HINSTANCE
و HMODULE
؟ - الوصول إلى
HINSTANCE
للوحدة الحالية من مكتبة ثابتة -
LoadLibraryEx(DONT_RESOLVE_DLL_REFERENCES)
معيب بشكل أساسي - لماذا يتم تفريغ DLLs في ترتيب "الخطأ"؟
- كيف يتم تصدير وظائف DLL في النوافذ 32 بت؟
- وظائف تصديرها حقًا
- إعادة التفكير في طريقة حل صادرات DLL لنوافذ 32 بت
- تم تزيين الأسماء في مكتبة الاستيراد لسبب ما
- ماذا يحدث عندما تخطئ في Dllimport؟
- المشكلات المتعلقة بإجبار كعب على إنشاء وظيفة مستوردة
- تخصيص الذاكرة وتحريرها عبر حدود الوحدة النمطية
- إعادة توجيه DLL ليست هي نفسها تحميل التأخير
- ما هو تلميح استيراد DLL؟
- ما هو ملزمة استيراد DLL؟
- ما هي الهدف من
FreeLibraryAndExitThread
؟ - مكتبة تم تحميلها عبر
LOAD_LIBRARY_AS_DATAFILE
(أو أعلام مماثلة) لا يمكن تشغيلها في أي ألعاب وحدة الرنة - هل يمكن أن تكون هناك أي مشاكل في استدعاء
GetModuleFileNameEx
على عمليتك الخاصة؟ - كيف يمكنني تحديد أن DLL يجب أن يحل اعتماد DLL من نفس الدليل الذي يوجد فيه DLL؟
- بعد أن صنعت DLL Delay-تحميل DLL آخر ، بدأ DLL الخاص بي في الانهيار في رمز فصل العملية
- الأنواع المختلفة من زراعة DLL
- لماذا تفشل
GetModuleInfo
في إنتاج نقطة دخول للمشاركين التنفيذيين؟ - ماذا يعني
SizeOfImage
في بنية MODULEINFO
؟ - كيف يمكنني قمع مربع الخطأ الذي يظهر عندما تفشل
LoadLibrary
؟
DllMain()
- بعض الأسباب لعدم فعل أي شيء مخيف في
DllMain
الخاص بك - سبب آخر لعدم فعل أي شيء مخيف في
DllMain
الخاص بك: deadlock غير المقصود - بعض الأسباب لعدم فعل أي شيء مخيف في
DllMain
الخاص بك ، الجزء 3 - مؤشر الترابط الذي يحصل على إشعار
DLL_PROCESS_DETACH
ليس بالضرورة هو الذي حصل على DLL_PROCESS_ATTACH notification
- كيف يمكنك تحميل DLL أثناء
DLL_PROCESS_DETACH
دون حتى إدراكه - عندما يخبرك
DLL_PROCESS_DETACH
أن العملية تخرج ، فإن أفضل رهان لك هو العودة دون القيام بأي شيء
موارد
- يتخلف مترجم الموارد إلى
CP_ACP
، حتى في مواجهة تلميحات خفية مفادها أن الملف هو UTF-8 - العلاقة بين موارد الوحدة النمطية والكائنات المستمدة من الموارد في نوافذ 32 بت
- ما هو الفرق بين
FreeResource
، و Pearh ، DestroyAcceleratorTable
- يجب أن تكون موارد PE محاذاة 4 بايت ، لكن هذا لا يمنع الناس من محاولة محاذاة أخرى
- كيف يمكنني أن أقول أن شخصًا ما استخدم ماكرو
MAKEINTRESOURCE
لتهريب عدد صحيح داخل مؤشر؟ - Gotcha سيئة للغاية:
FindResource
و FindResourceEx
موارد النقطات والأيقونة
- لماذا يتم وضع نقطات مستقلة عن الجهاز رأسًا على عقب؟
- شكل موارد صورة نقطية
- شكل موارد الأيقونة
- تنسيق موارد الأيقونات ، إعادة النظر
- تطور تنسيق ملف ICO ، الجزء 1: بدايات أحادية اللون
- تطور تنسيق ملف ICO ، الجزء 2: الآن بالألوان!
- تطور تنسيق ملف ICO ، الجزء 3: صور ألفا المدمجة
- تطور تنسيق ملف ICO ، الجزء 4: صور PNG
- كيف أقوم بتعيين قناة ألفا من صورة نقطية GDI إلى 255؟
موارد سلسلة الرسائل
- لماذا يقول
FormatMessage
أن %0
ينهي الرسالة دون خط جديد متخيل؟ هل تضيف سرا الخطوط الجديدة؟
قوالب الحوار
- حول صعوبة الحصول على تخطيط Pixel-Perfect في قوالب حوار Win32
- تطور قوالب الحوار - قوالب كلاسيكية 32 بت
- تطور قوالب الحوار - قوالب ممتدة 32 بت
- تطور قوالب الحوار - ملخص
- سيقوم مترجم الموارد بإضافة أنماط النوافذ لك ، ولكن إذا كنت تقوم بإنشاء قالب حوار بنفسك ، فلن تحصل على هذه المساعدة
قوالب القائمة وموارد التسريع
- تطور قوالب القائمة: مقدمة
- تطور قوالب القائمة: قوائم كلاسيكية 32 بت
- تطور قوالب القائمة: قوائم ممتدة 32 بت
- تنسيق موارد جدول المسرع
موارد السلسلة
- تنسيق موارد السلسلة
- يمكن
LoadString
تحميل سلاسل مع خالية مضمّنة ، لكن وظيفة الغلاف الخاصة بك قد لا
قوالب الإصدار
- تطور موارد الإصدار - موارد الإصدار 32 بت
- تطور موارد الإصدار - موارد الإصدار 32 بت التالفة
البيانات والموارد المخصصة
- شكل البيانات والموارد المخصصة
التطبيق (ككل)
- ما هي النوافذ التي تظهر في قائمة
Alt+Tab
؟ - غيرت Windows Vista ترتيب
Alt+Tab
قليلاً - Win32 واجهة المستخدم يعمل بطبيعته ذات الخيوط الواحدة
- متى تقوم
STARTF_USESHOWWINDOW
بتجاوز المعلمة التي تم تمريرها إلى ShowWindow
؟ - يجب أن يطلق على
WaitForInputIdle
حقًا WaitForProcessStartupComplete
-
WaitForInputIdle
ينتظر أي موضوع ، والذي قد لا يكون الموضوع الذي تهتم به - ما هي الاتفاقيات لإدارة المقابض القياسية؟
- المقابض القياسية مخصصة حقًا للبرامج ذات الخيوط الواحدة
- إذا كان بإمكان DLLs فقط الحصول على إشعارات
DllMain
، فكيف يمكن لـ EXE تلقي إشعار عند إنشاء مؤشر ترابط (على سبيل المثال)؟
سطر الأوامر
- الكلمة الأولى في سطر الأوامر هي اسم البرنامج فقط عن طريق الاتفاقية
- كيف تهدف وظيفة
CommandLineToArgvW
إلى استخدامها؟ - ما الأمر مع المعاملة الغريبة لعلامات الاقتباس والخطوط الخلفية بواسطة
CommandLineToArgvW
شريط المهام
- كيف يمكنني منع المستخدمين من تثبيت برنامجي إلى شريط المهام؟
- بدلاً من إنشاء شيء ما ثم محاولة إخفاءه ، ببساطة لا تنشئه في المقام الأول (أيقونة الدرج)
- ماذا لو كان طلبي هو في الحقيقة تطبيقين تم تجميعهما في ملف واحد ، وأريد جمعهما في مجموعتين على شريط المهام في Windows 7؟
- كيف يمكنني تخصيص كيفية تجميع Windows للتطبيق في شريط المهام؟
- عرض تراكب على زر شريط المهام
- عرض أزرار التحكم في نافذة معاينة شريط المهام الخاص بك
- عرض صورة مصغرة مخصصة لتطبيقك (وأثناء وجودك فيه ، معاينة مباشرة مخصصة)
- كيف يمكنني الاستعلام عن موقع شريط المهام على الشاشات الثانوية؟
- كيف تمكن هذا البرنامج من تثبيت نفسه على شريط المهام عندما قمت بتثبيته؟
- ماذا لو كان لديّ برنامجان يعتبران تطبيقًا واحدًا منطقيًا ، وأريد أن يعاملهما كمجموعة واحدة على شريط المهام؟
- لماذا تتغير أيقونة شريط المهام للنوافذ المجمعة إلى شيء غريب؟
HWND
(وجهة النظر العامة)
- ماذا يعني أن تكون النافذة أحادية؟
- كيف يمكنني الحصول على عنوان إجراء النافذة الفعلي وليس ثانك؟
- ما هي هذه القيم الغريبة التي يتم إرجاعها من
GWLP_WNDPROC
؟ - بايت نافذة المكافأة في
GWLP_USERDATA
- ما هو الفرق بين
WM_DESTROY
و WM_NCDESTROY
؟ - إرسال رسالة
WM_DESTROY
مثل المزحة التي تدعو شخص ما يتظاهر بأنه الشرطة - الحياة السرية لـ
GetWindowText
- لماذا قواعد
GetWindowText
غريبة جدا؟ - الطلاء فقط عندما تكون نافذتك مرئية على الشاشة
- تحديد ما إذا كانت نافذتك مغطاة
- الحصول على حجم النافذة وموضعها أثناء تقليلها
- لماذا لا يعيد الاتصال على الفور
SetForegroundWindow
GetForegroundWindow
بنفس النافذة؟ - كيف تقرر Windows ما إذا كان يجب أن تستخدم نافذة تم إنشاؤها حديثًا تخطيط LTR أو RTL؟
التسلسل الهرمي لنظام التشغيل Windows
- ما الذي يميز نافذة سطح المكتب؟
- ما هو حد تعشيش النافذة؟
- ما الفرق بين
HWND_TOP
و HWND_TOPMOST
؟ - يمكن أن تحتوي النافذة على أحد الوالدين أو المالك ولكن ليس كلاهما
- لماذا يرسل سيطرتي إخطاراتها إلى النافذة الخاطئة بعد أن أعززها؟
-
WindowFromPoint
، ChildWindowFromPoint
، RealChildWindowFromPoint
، متى سينتهي كل شيء؟ -
GetParent
، مثلما يربك مثل EnumClaw
، لكنها وظيفة فعلية! ( GetAncestor()
، GetWindow()
) - إن وجود نافذة مالك من عملية أخرى أمر صعب ، ولكن في بعض الأحيان يكون الشيء الصحيح الذي يجب القيام به
- ما هي الوثائق الخاصة بـ
SetParent
التي تحاول أن تخبرني عن مزامنة حالة واجهة المستخدم؟ - إظهار ما يحدث عندما يكون لدى أحد الوالدين والطفل حالات واجهة المستخدم المختلفة
- الحصول على نافذة الوالدين والطفل للحصول على نفس حالات واجهة المستخدم
أنماط النوافذ
- أي أجزاء نمط النافذة تنتمي إلى من؟
- كيف أشير إلى أنني أريد أن تتبع نافذتي قواعد التخطيط من اليمين إلى اليسار؟
- لماذا لا تحكم بلدي الثابت الشفافة شفافة؟ (
WS_EX_TRANSPARENT
) - مثل الكعكة ،
WS_EX_TRANSPARENT
هي كذبة ، أو على الأقل ليست الحقيقة بأكملها - لقد استخدمت
WS_EX_COMPOSITED
للتخلص من وميض إعادة رسم ، ولكنه أدى إلى استجابة بطيئة - كيف يمكنني استخدام
WS_CLIPCHILDREN
وما زلت قادرًا على رسم عنصر تحكم بخلفية شفافة؟
فئات النوافذ
- ما الذي تم تمرير
HINSTANCE
إلى CreateWindow
و RegisterClass
المستخدمة؟ - إن استخدام
HINSTANCE
الخاطئة في RegisterClass
يشبه سرقة الهوية - إذا كانت وظيفة
RegisterClass
تأخذ ملكية فرشاة الخلفية المخصصة ، فلماذا تتسرب؟ - يؤثر تغيير فئة النافذة على جميع النوافذ التي تنتمي إلى تلك الفئة
- ماذا يفعل
CS_SAVEBITS
؟ - ماذا يفعل نمط فئة
CS_OWNDC
؟ - ماذا يفعل نمط فئة
CS_CLASSDC
؟ - يؤثر تعديل نمط
CS_NOCLOSE
على جميع نوافذ الفصل ، وليس بالضرورة بطريقة ملحوظة على الفور - لماذا يكره
PrintWindow
CS_PARENTDC
؟ لأن الجميع يكره CS_PARENTDC
! - لماذا يكره
PrintWindow
CS_PARENTDC
؟ Redux - فئة فرعية أكثر أمانًا
- الطبقات الخاصة ، الفئة الفائقة ، والفcys الفئة الفرعية العالمية
- ما الذي يجعل
RealGetWindowClass
أكثر واقعية من GetClassName
؟ - لماذا تأخذ
CreateWindowEx
معلمة النمط الموسعة كمعلمة لها بدلاً من الأخير؟ - متى يجب أن أستخدم
CS_GLOBALCLASS
؟ - ما مدى فريدة من نوعها التي يجب أن تكون معلمة UIDSUBCLASS عندما أتصل بـ
SetWindowSubclass
؟
نوافذ المستوى الأعلى
إطار النافذة والتسمية التوضيحية
- الحصول على قائمة النقر بزر الماوس الأيمن للحصول على أيقونة التسمية التوضيحية
- رسم تعليق نشط المظهر حتى عندما لا يكون نشطًا
- كيف يمكنني قمع النافذة الكاملة السحب/تغيير الحجم لنافذة واحدة فقط؟
- كيف يمكنني تبديل نافذة بين العادي والشروط الكاملة؟
- كيف يمكنني تمكين الأزرار وتقليلها إلى الحد الأدنى ، وإغلاق الأزرار في شريط التسمية التوضيحية الخاصة بي؟
- الحصول على موقع زر الإغلاق في شريط العنوان
- الحصول على موقع زر الإغلاق في شريط العنوان ، من Windows 2000 أو Windows XP
- لماذا أبعاد نافذة أكبر من الشاشة؟
- إنشاء نافذة يمكن تغيير حجمها في اتجاه واحد فقط
- لماذا لا تقوم بإعادة توجيه
WM_GETMINMAXINFO
وتثبت النتائج؟
DWM
- لماذا لا يتلقى برنامجي رسالة
WM_DWMSENDICONICTHUMBNAIL
عندما أطلب تمثيلًا مبدعًا؟ - تتحكم المعلمة
MARGINS
إلى دالة DwmExtendFrameIntoClientArea
- كيف يمكنني قمع الرسوم المتحركة الافتراضية التي تحدث عندما أختبئ أو أظهر نافذة؟
- عرض صورة مصغرة مخصصة لتطبيقك (وأثناء وجودك فيه ، معاينة مباشرة مخصصة)
- كيف يمكنني اكتشاف أن نافذتي قد تم قمعها من الشاشة بواسطة القشرة؟ ("النافذة الابتكار")
مربعات الحوار
- لماذا لا يمكنني إنشاء مربع الحوار الخاص بي؟ خطأ الصاعد #1
- لماذا لا يمكنني إنشاء مربع الحوار الخاص بي؟ خطأ الصاعد #2
- إرجاع القيم من إجراء حوار
- نوع مختلف من إجراء الحوار
- نوع آخر مختلف من إجراء الحوار
- الإجابة الافتراضية على كل مربع حوار هي "إلغاء"
- تدوير z-order
- باستخدام مفتاح
TAB
للتنقل في غير dialogs - باستخدام مفتاح
TAB
للتنقل في غير dialogs ، Redux - منع تحرير نص التحكم من الانتقاد تلقائيًا في مربع حوار
- أولئك الذين لا يفهمون مدير الحوار محكوم عليهم بإعداده بشكل سيء
- حيل أخرى مع
WM_GETDLGCODE
-
GetDialogBaseUnits
هو الفخار - لماذا لا يتم استطوير حوار رسم الخرائط
MapDialogRect
؟ - لماذا يتم إنشاء مربعات الحوار في البداية مخفية؟
- ما هي الصفقة مع علامة
DS_SHELLFONT
؟ - لماذا
DS_SHELLFONT = DS_FIXEDSYS | DS_SETFONT
؟ - كيفية ضبط التركيز في مربع الحوار
- لا تترك التركيز أبدًا على عنصر تحكم معاق
- دقة في استعادة وضع النافذة السابق
- الأشياء التي تعرفها بالفعل: كيف انتظر حتى يتم عرض مربع الحوار الخاص بي قبل القيام بشيء ما؟
- ماذا تفعل
TranslateAccelerator
؟ - إذا كان لدي مربع حوار غير معدني مع مسرعات مخصصة ، والتي يجب أن أتصل أولاً:
IsDialogMessage
أو TranslateAccelerator
- تذكير لطيف: في مربع حوار ، لا تعطي موافق وإلغاء المسرعات
- لماذا لا تزال مسرعات الضوابط الخفية نشطة؟
- كيف أجعل مسرعاتي تنطبق فقط عند استخدامها في النافذة الرئيسية وليس عندما يستخدم المستخدم مربع حوار غير معدني؟
- لماذا لا يعمل مفتاح
TAB
على عناصر التحكم التي قمت بتمييزها باسم WS_TABSTOP
؟ - لا يمكنك استخدام رسالة
WM_USER
في مربع حوار - كيف يمكنني إنشاء مربع حوار يمين اليمين في وقت التشغيل؟
- كيف يحسب مدير الحوار متوسط عرض الشخصية؟
الحوارات المتداخلة والمدمجة
- ما هو نمط
DS_CONTROL
؟ - المزيد من الملاحظات حول استخدام نمط
DS_CONTROL
- ليس من الجيد إعطاء عناصر تحكم متعددة في مربع الحوار نفس المعرف
- عند تضمين مربع حوار داخل آخر ، تأكد من عدم إنشاء معرفات التحكم المكررة بطريق الخطأ
- عندما يتم استدعاء الضغط الافتراضي ، يذهب الاستدعاء إلى مربع الحوار على المستوى الأعلى
مربعات حوار مشتركة
- لماذا لا يلف
MessageBox
الخاصة بي في الموقع الصحيح؟ - كيف يمكنني تخصيص قسم الروابط المفضلة في مربع حوار فتح الملف؟
- لماذا يغير مربع حوار الملف المشترك الدليل الحالي؟
- يمكنك تصفية مربع حوار الملف المشترك مع أحرف البدل
- كيف يمكنني عرض مربع حوار Find Printers برمجيًا؟
- لماذا لا تُدرج الملفات المفتوحة في المجلدات المشتركة التي تعرض جميع ملفاتي المفتوحة؟
- تم تأجيل السيطرة الشائعة لربط الامتدادات
- تصفية المجلدات التي تظهر في مربع تصفح المجلد
- فتح مربع حوار متصفح المجلد الكلاسيكي مع مجلد محدد مسبقًا
- لماذا يقوم مربع الحوار "حفظ الملف الشائع" بإنشاء ملف مؤقت ثم حذفه؟
- تخصيص مربع الحوار القياسي للألوان
- كيف أقوم بتعيين الدليل الأولي لحوار الملف المفتوح على دليل افتراضي؟
- عندما أقوم بتحديد ملفات متعددة في مربع حوار فتح الملف ، لماذا يأتي العنصر الأخير أولاً؟
- قمت بتعيين خيار
OFN_NONETWORKBUTTON
في بنية OPENFILENAME
، ولكن ليس له أي تأثير على عنصر الشبكة في جزء التنقل - كيف يمكنني إضافة عناصر تحكم مخصصة إلى ملف حوار فتح الملف الشائع أو حفظ الملف؟
- كيف يمكنني فتح
FileSavePicker
الخاصة بي في نفس المجلد الذي تم اختياره بواسطة FileOpenPicker
أو FolderPicker
؟ (Win32/com ما يعادلها المذكورة في نهاية المنشور)
السيطرة على الملاحة
- باستخدام مفتاح
TAB
للتنقل في غير dialogs - باستخدام مفتاح
TAB
للتنقل في غير dialogs ، Redux - إدارة حالة واجهة المستخدم للمسارعين ومستطيلات التركيز
- التنقل المخصص في مربعات الحوار ، Redux
- تركز مربعات الحوار على عنصر التحكم الذي كان له تركيز عند آخر مرة تبغيت فيها ؛ كيف يمكنني الدخول في هذا الإجراء لنوافذ بلدي؟
- كيف يمكنني إنشاء ترتيب علامة تبويب غير دائرية ، أو نوع آخر من الطلبات المخصصة في مربع حوار Win32 الخاص بي؟
مدير الحوار
- مدير الحوار ، الجزء 1: عمليات الاحماء
- مدير الحوار ، الجزء 2: إنشاء نافذة الإطار
- مدير الحوار ، الجزء 3: إنشاء عناصر التحكم
- مدير الحوار ، الجزء 4: حلقة الحوار
- مدير الحوار ، الجزء 5: تحويل مربع حوار غير وسياسي إلى وسيط
- مدير الحوار ، الجزء 6: التفاصيل الدقيقة في حلقات الرسائل
- مدير الحوار ، الجزء 7: المزيد من التفاصيل الدقيقة في حلقات الرسائل
- مدير الحوار ، الجزء 8: التنقل المخصص في مربعات الحوار
- مدير الحوار ، الجزء 9: مسرعات مخصصة في مربعات الحوار
طريقة
- الترتيب الصحيح لتعطيل وتمكين النوافذ
- الطريقة ، الجزء 1: وسيلة واجهة المستخدم مقابل الوسائط الكود
- الطريقة ، الجزء 2: الكود مقابل الوسيلة الوطنية
- الطريقة ، الجزء 3: رسالة
WM_QUIT
- الطريقة ، الجزء 4: أهمية تعيين المالك الصحيح لواجهة المستخدم الوسائط
- الطريقة ، الجزء 5: تعيين المالك الصحيح لواجهة المستخدم الوسيطة
- الطريقة ، الجزء 6: التفاعل مع برنامج ذهب وسيط
- الطريقة ، الجزء 7: مربع
MessageBox
المحددة ، النسخة الرخيصة - الطريقة ، الجزء 8:
MessageBox
الموقوتة ، الإصدار الأفضل - الطريقة ، الجزء 9: تعيين المالك الصحيح لواجهة المستخدم الوسائط ، الامتحان العملي
- يتم تناول رسائل الموضوع بواسطة حلقات مشروطة
- إنقاذ رسائل الخيط من حلقات مشروط عبر مرشحات الرسائل
أوراق الممتلكات
- ما هي الآثار الأخرى التي تحدثها
DS_SHELLFONT
على صفحات ورقة العقار؟ -
PSM_ISDIALOGMESSAGE
هو لأوراق الخصائص غير المقيدة لأن IsDialogMessage
هي مربعات الحوار غير معدلة - يمكنك تمديد بنية
PROPSHEETPAGE
مع بيانات المكافأة الخاصة بك - يتم إرسال إشعار
PSN_SETACTIVE
في كل مرة يتم تنشيط صفحة المعالج الخاصة بك - إلحاق حمولة إضافية إلى بنية
PROPSHEETPAGE
- كيف أقوم بتمرير مجموعة من هياكل
PROPSHEETPAGE
ذات الحجم المتغير إلى ورقة الخصائص؟
الضوابط
- فقط لأنك تحكم لا يعني أنك بالضرورة داخل مربع حوار
عناصر التحكم في الرسوم المتحركة
- قيود التحكم في الرسوم المتحركة
- لماذا لا يستخدم عنصر التحكم في الرسوم المتحركة الإصدار 6 موضوعًا للخلفية؟
أزرار
- ما هو نمط زر
BS_PUSHLIKE
؟ (لا تستخدم ، إنها قديمة تمامًا في الوقت الحاضر. استخدم خانة الاختيار أو زر الراديو بدلاً من ذلك.)
مربعات التحرير والسرد
- تسريع إضافة عناصر إلى combobox أو listbox (
WM_SETREDRAW
)
تحرير الضوابط
- ما هي الصفقة مع رسالة
EM_SETHILITE
؟ - منع تحرير نص التحكم من الانتقاد تلقائيًا في مربع حوار
- كيف يمكنني قمع تحذيرات
CapsLock
على عناصر التحكم في تحرير كلمة المرور؟ - التاريخ المبكر لأسلوب التحكم في تحرير
ES_NUMBER
- كيف أسمح لأرقام سلبية بأسلوب التحكم في تحرير
ES_NUMBER
؟ - كيف أسمح بإدخال علامة ناقص في تحكم التحرير الخاص بي ، ولكن فقط إذا كانت الشخصية الأولى؟
قائمة المشاهدات
- مشاهدات LISTVIEW التي تم وضعها مقابل غير موضعية
- عرض غرس لعناصر ListView مطوية ومكشوفة
- الحوسبة قائمة بفيارات في الخلفية
- ما الفرق بين
LVM_HITTEST
و LVM_INSERTMARKHITTEST
؟ - لماذا يوجد إشعار
LVN_ODSTATECHANGED
عندما يكون هناك بالفعل إشعار LVN_ITEMCHANGED
جيد تمامًا؟ - إنشاء ListView مع مربعات الاختيار على بعض العناصر ولكن ليس غيرها
- كيف يمكنني تغيير حجم عمود ListView برمجيًا لتناسب محتوياته؟
- كيف يمكنني إنشاء خانة اختيار معطلة لعنصر ListView؟
- تسريع إضافة عناصر إلى combobox أو listbox (
WM_SETREDRAW
)
ضوابط النص الغنية
تاريخ سيطرة ريتشديت من موراي سارجنت (المنشور هو مجرد رابط (مكسور) إلى https://blogs.msdn.microsoft.com/murrays/2006/10/19/some-richedit-history/)- كيف يمكنني تحميل ملف كامل في عنصر تحكم نص غني؟
- كيف أضع أكثر من 32000 حرفًا في عنصر تحكم في نص غني؟
- كيف أقوم بطباعة محتويات عنصر تحكم نص غني؟
أشرطة التمرير
- برنامج الخدش
- أشرطة التمرير ، الجزء 2
- أشرطة التمرير ، الجزء 3: تحسين دورة الطلاء
- أشرطة التمرير ، الجزء 4: إضافة شريط التمرير النسبي
- الجزء 5 على الأرجح: إمكانية الوصول إلى لوحة المفاتيح لأشرطة التمرير
- إضافة إلى الجزء 5: دقة في رمز لوحة المفاتيح
- أشرطة التمرير الجزء 6 - العجلة
- أشرارات التمرير الجزء 7 - التكامل
- شريط التمرير 8 - تغيير حجم التفاعل المتكامل
- أشرطة التمرير الجزء 9 - الحفاظ على الاستعارة
- أشرارات التمرير 10 - نحو فهم أعمق لرسالة
WM_NCCALCSIZE
- أشرارات التمرير 11: نحو فهم أعمق لرسالة
WM_NCCALCSIZE
- إجابات لممارسة الرياضة من Scrollbars الجزء 11
- شريط التمرير 12: تطبيق
WM_NCCALCSIZE
على عينة شريط التمرير لدينا - أشرطة التمرير Redux: الجزء 12
- هناك نوعان من أشرطة التمرير
- لماذا تم اختيار
WHEEL_DELTA
ليكون 120 بدلاً من قيمة أكثر ملاءمة مثل 100 أو حتى 10؟ - لماذا يعين إعداد نطاق شريط التمرير الأفقي لأول مرة أيضًا النطاق العمودي ، والعكس بالعكس؟
- التلقائي على السحب ، الجزء 1: التنفيذ الأساسي
- التلقائي على السحب ، الجزء 2: لماذا يتم التمرير بشكل أسرع إذا كنت أتضحى الماوس؟
- التلقائي على السحب ، الجزء 3: Autoscroll الديناميكي بناءً على موضع الماوس
- تلقائي على السحب ، الجزء 4: Autoscroll الديناميكي بناءً على سرعة الهروب
- التلقائي على السحب ، الجزء 5: إضافة تذبذب إلى مرسى للهروب من السرعة
ضوابط ثابتة
- متى سيحذف عنصر التحكم الثابت تلقائيًا الصورة المحملة فيها ، ومتى تقع مسؤولية التطبيق؟
TAB عناصر التحكم
- كيف يمكنني إنشاء عناصر تحكم في مربع الحوار الذي يحتوي على عنصر تحكم في علامة التبويب؟
- كيف من المفترض أن أقوم بإنشاء أطفال من التحكم في علامة التبويب Win32؟
أشرطة الأدوات
- لماذا يوجد كل من
TBSTYLE_EX_VERTICAL
و CCS_VERT
؟ - كيف يمكنني إنشاء شريط أدوات يجلس في شريط المهام؟
- كيف أقوم بإنشاء زر شريط أدوات محاذاة يميني؟
- إنشاء مهام مخصصة في قائمة القفز
تلميحات الأدوات
- ترميز تلميحات الأدوات في مكانها
- استخدام دروش مخصص في تلميحات الأدوات لضبط الخط
- تعدد الأدوات المتعددة في واحدة في تلميح الأدوات
- توليد نص تلميح الأدوات ديناميكيًا
- لماذا لا يمكنني عرض تلميح الأدوات لنافذة معطلة؟
- الإفراط في توثيق
TTM_RELAYEVENT
ولماذا ينتج عنه جهاز توقيت دوري لمدة ثانية واحدة يعمل طالما كانت تلميح الأدوات مرئيًا
أشرطة التعقب
- إضافة مسرع سهم
Ctrl
+لنقل شريط التتبع بمقدار وحدة واحدة فقط ، الجزء 1: الغوص الأولي - إضافة مسرع سهم
Ctrl
+لنقل شريط التتبع بمقدار وحدة واحدة فقط ، الجزء 2: المحاولة الثانية - كيف يمكنني منع المستخدمين من استخدام الماوس لسحب إبهام شريط التتبع إلى مواقع لا تضاعف خمسة؟ الجزء 1: إعادة صياغة المشكلة
- كيف يمكنني منع المستخدمين من استخدام الماوس لسحب إبهام شريط التتبع إلى مواقع لا تضاعف خمسة؟ الجزء 2: دفع موقف الإبهام
إطلالات قائمة الأشجار
- نمط
TVS_CHECKBOXES
غريب ، وهي طريقة مهذبة للقول إنه مجنون - احذر من قائمة الصور التي تم تسريبها عند استخدام نمط
TVS_CHECKBOXES
- إنشاء خانات فحص عرض الأشجار يدويًا: قائمة صور الحالة البسيطة
- إنشاء خانات اختيار عرض الأشجار يدويًا: الاستجابة للنقرات
- إنشاء خانات فحص عرض الأشجار يدويًا: خانات الاختيار تحت عنوان
- خانات الاختيار عرض الشجرة: تاريخ قذر
- خانات الاختيار عرض الشجرة: حالات خانة الاختيار الموسعة
معالجة الرسائل
- ما هي أرقام الرسائل التي تنتمي إلى من؟
- الطرق المختلفة لإرسال رسالة
- بث الرسائل المعرفة من قبل المستخدم
- متى يمكن لرسائل أن تتلقى رسائل نافذة؟
- ما الفرق بين
GetKeyState
و GetAsyncKeyState
؟ - يتم تناول رسائل الموضوع بواسطة حلقات مشروطة
- إنقاذ رسائل الخيط من حلقات مشروط عبر مرشحات الرسائل
- مخاطر تصفية رسائل نافذة
- لا يمكنك محاكاة إدخال لوحة المفاتيح مع
PostMessage
- ضخ الرسائل أثناء الانتظار لفترة من الوقت
- في السعي لتحقيق قائمة انتظار الرسائل
- لا ، في الحقيقة ، تحتاج إلى تمرير جميع الرسائل غير المعقولة إلى
DefWindowProc
- حتى لو كان لديك رمز للتعامل مع رسالة ، يُسمح لك بالاتصال
DefWindowProc
، لأنك كنت تفعل ذلك على أي حال بعد كل شيء - ما الذي استخدمه
Get/SetMessageExtraInfo
؟ - لماذا يعيد
GetWindowLongPtr
قيمة القمامة على النوافذ 64 بت؟ - تتبع
TrackMouseEvent
أحداث الماوس في نافذتك ، ولكن فقط إذا كانت الأحداث تنتمي إلى نافذتك - لا تنس تضمين قائمة انتظار الرسائل في التسلسل الهرمي لقفلك
- ماذا يحدث لرسالة مرسلة عندما يصل
SendMessageTimeout
إلى مهلة؟ - لماذا لا يمكنني
PostMessage
رسالة WM_COPYDATA
، لكن يمكنني SendMessageTimeout
مع مهلة صغيرة؟ - على الرغم من أن رسائل Mouse-Move و Paint و Timer يتم إنشاءها عند الطلب ، إلا أنه لا يزال من الممكن أن ينتهي أحدهم في قائمة الانتظار الخاصة بك
- تتم معالجة الرسائل المنشورة قبل رسائل الإدخال ، حتى لو تم نشرها لاحقًا
- ما نوع الرسائل التي يمكن أن تتلقاها نافذة الرسائل فقط؟
- إذا كانت النماذج الأولية لـ
DispatchMessageA
و DispatchMessageW
متطابقة ، فلماذا كلاهما؟ - أولئك الذين لا يفهمون مدير الحوار محكوم عليهم بإعداده بشكل سيء
- كيف يمكنني تشغيل إعادة حساب من مؤشر الماوس بعد أن قمت بتغيير بعض حالة الطلب الداخلي؟
- كيف يمكنني تشغيل إعادة حساب من مؤشر الماوس بعد أن قمت بتغيير بعض حالة الطلب الداخلي؟ ، المتابعة
-
GetQueueStatus
وحالة قائمة الانتظار
ربط
- ما الذي تم تمرير
HINSTANCE
إلى SetWindowsHookEx
المستخدم؟ - كيف يمكنني إخطاره عندما يتغير المؤشر؟
- What does the thread parameter to
SetWindowsHookEx
actually mean? - Why does
SetFocus
fail without telling me why?
Specific Messages
إشعارات
- What's the difference between the
wParam
of the WM_NOTIFY
message and the idFrom
in the NMHDR
structure. - Restating the obvious about the
WM_COMMAND
message - Restating the obvious about the
WM_NOTIFY
message
Window Construction and Destruction
- What is the difference between
WM_DESTROY
and WM_NCDESTROY
? - How can I determine the reason why my window is closing? (
WM_CLOSE
)
Window Geometry Messages
- Use
WM_WINDOWPOSCHANGED
to react to window state changes - Use
WM_WINDOWPOSCHANGING
to intercept window state changes
Window Painting Messages
- Paint messages will come in as fast as you let them (
WM_PAINT
) - What happens if I don't paint when I get a
WM_PAINT
message? - What is the implementation of
WM_PRINTCLIENT
? - There's a default implementation for
WM_SETREDRAW
, but you might be able to do better - Speeding up adding items to a combobox or listbox (
WM_SETREDRAW
) - Using
WM_SETREDRAW
to speed up adding a lot of elements to a control
Window Focus Messages
-
WM_KILLFOCUS
is the wrong time to do field validation - The dangers of playing focus games when handling a
WM_KILLFOCUS
message - Why doesn't the
MoveWindow
function generate the WM_GETMINMAXINFO
message?
Keyboard Messages
- How do I respond to the
WM_MENUCHAR
message?
Mouse Messages
- Why is there no
WM_MOUSEENTER
message? - Why do I get spurious
WM_MOUSEMOVE
messages? - Sure, I can get spurious
WM_MOUSEMOVE
messages, but why do they keep streaming in? - How do I get mouse messages faster than
WM_MOUSEMOVE
? - Logical consequences of the way Windows converts single-clicks into double-clicks
- Implementing higher-order clicks
- How slow do you have to slow-double-click for it to be a rename?
- How can I prevent the mouse from moving in response to touch input?
Dialog Messages
- Those who do not understand the dialog manager are doomed to reimplement it, badly
- Managing the UI state of accelerators and focus rectangles (
WM_CHANGEUISTATE
, WM_QUERYUISTATE
and WM_UPDATEUISTATE
) - Untangling the confusingly-named
WM_UPDATEUISTATE
and WM_CHANGEUISTATE
messages - Who sends the initial
WM_UPDATEUISTATE
message? - How can I prevent the keyboard focus rectangle from appearing on a control I created?
- Other tricks with
WM_GETDLGCODE
- How do I prevent multi-line edit controls from eating the Enter key?
- Why do
DLGC_WANTALLKEYS
and DLGC_WANTMESSAGE
have the same value?
Other Window Messages
- The dangers of messing with activation when handling a
WM_ACTIVATE
message - Why does my window get a
WM_ACTIVATE
message when it isn't active? - A timed context menu (
WM_CANCELMODE
) - Pitfalls in handling the
WM_CONTEXTMENU
message ( WM_CONTEXTMENU
) -
WM_NCHITTEST
is for hit-testing, and hit-testing can happen for reasons other than the mouse being over your window - How likely is it that a window will receive a
WM_NULL
message out of the blue? ( WM_NULL
) - Why is there a special
PostQuitMessage
function? ( WM_QUIT
) - How does
PostQuitMessage
know which thread to post the quit message to? ( WM_QUIT
) - Who is responsible for destroying the font passed in the
WM_SETFONT
message? ( WM_SETFONT
) - When I send a
WM_GETFONT
message to a window, why don't I get a font? ( WM_GETFONT
) - If my
WM_TIMER
handler takes longer than the timer period, will my queue fill up with WM_TIMER
messages? - Killing a window timer prevents the
WM_TIMER
message from being generated for that timer, but it doesn't retroactively remove ones that were already generated
System Messages
- If one program blocks shutdown, then all programs block shutdown (
WM_QUERYENDSESSION
, WM_ENDSESSION
) - Why do I have to return this goofy value for
WM_DEVICECHANGE
? ( WM_DEVICECHANGE
) - Windows doesn't close windows when a user logs off; that's your call (
WM_ENDSESSION
) - Once you return from the
WM_ENDSESSION
message, your process can be terminated at any time ( WM_ENDSESSION
)
GDI
- Why are
RECT
s endpoint-exclusive? - Can you create an information context for the display?
- What does the
CS_OWNDC
class style do? - What does the
CS_CLASSDC
class style do? - How do you detect "Large Fonts"? (DPI)
- Drawing a monochrome bitmap with transparency
- Let GDI do your RLE compression for you
- The mysterious stock bitmap: There's no way to summon it, but it shows up in various places
- Why is my icon being drawn at the wrong size when I call
DrawIcon
? - You must flush GDI operations when switching between direct access and GDI access, and direct access includes other parts of GDI
- How do I get the dimensions of a cursor or icon?
- What are the dire consequences of not selecting objects out of my DC?
- Of what use is the
RDW_INTERNALPAINT
flag? - Functions that return GDI regions rarely actually return regions
- Color-aware ClearType requires access to fixed background pixels, which is a problem if you don't know what the background pixels are, or if they aren't fixed
- What is the correct way of using
SaveDC
and RestoreDC
? - How are
BitBlt
raster opcodes calculated? - Notes on
DrawText
and tab stops - Why doesn't
GetTextExtentPoint
return the correct extent for strings containing tabs? - Why are there trivial functions like
CopyRect
and EqualRect
? - More on trivial functions like
CopyRect
and EqualRect
- What are the consequences of increasing the per-process GDI handle limit?
- The focus rectangle says, “I'm not orange. I'm just drawn that way.”
Cursors
- The effect of
SetCursor
lasts only until the next SetCursor
- What can or should I do with the cursor handle returned by
SetCursor
? - What is the deal with the
SM_CXCURSOR
system metric? - How do I find out the size of the mouse cursor?
Brushes
- The hollow brush
- Other uses for bitmap brushes
- What is the DC brush good for?
- I know I can change the color of the DC pen, but what about the other attributes?
- How can I extract the color from a solid color GDI brush?
Pens
- Is there a difference between creating a null pen with
CreatePen
and just using the stock null pen?
Bitmaps
- How do I set the alpha channel of a GDI bitmap to 255?
DIB
- A survey of the various ways of creating GDI bitmaps with predefined data
- Blitting between color and monochrome DCs
- Manipulating the DIB color table for fun and profit
- Using DIB sections to perform bulk color mapping
- The fun and profit of manipulating the DIB color table can be done without having to modify it
- Separating the metadata from the DIB pixels: Precalculating the
BITMAPINFO
- Separating the metadata from the DIB pixels: Changing the raster operation
- The disembodiment of DIBs from the DIB section
- What is the
hSection
parameter to CreateDIBSection
for?
LockWindowUpdate()
- What does
LockWindowUpdate
do? - How is
LockWindowUpdate
meant to be used? - With what operations is
LockWindowUpdate
meant to be used? - With what operations is
LockWindowUpdate
not meant to be used? - Final remarks on
LockWindowUpdate
Painting Standard Elements
- Rendering standard Windows elements
- Rendering menu glyphs is slightly trickier
- What states are possible in a
DRAWITEMSTRUCT
structure?
UXTHEME.DLL
-
BeginBufferedPaint
: It's not just for buffered painting any more - How do
IsThemeActive
, IsAppThemed
, and IsCompositionActive
differ? - How do I get the tabbed dialog effect on my own custom tabbed dialog?
- How do I revert a control back to its default theme?
Multiple Monitors
- For better performance, set all your monitors to the same color format
- How do I get a handle to the primary monitor?
- Why does the primary monitor have
(0,0)
as its upper left coordinate? - How do I get the color depth of the screen?
- How does the window manager adjust
ptMaxSize
and ptMaxPosition
for multiple monitors?
إمكانية الوصول
- Accessibility is not just for people with disabilities
- How to retrieve text under the cursor (mouse pointer)
- How do I set an accessible name on an unlabeled control?
- How can I get notified when some other window is destroyed?
- Using accessibility to monitor windows as they come and go
- How can I write a program that monitors another window for a title change?
- How can I write a program that monitors another window for a change in size or position?
COM
Declaring COM Interfaces
- The macros for declaring COM interfaces, revisited: C version
- The macros for declaring COM interfaces, revisited: C++ version
- The macros for declaring COM interfaces, revisited: C++ implementation
- The oracle always tells the truth, even when it is wrong: COM method calls with a user-defined type as a return value (on problems of COM interfaces called from C code)
- The COM interface contract rules exist for a reason
- Giving a single object multiple COM identities, part 1
- Giving a single object multiple COM identities, part 2
- Giving a single object multiple COM identities, part 3
- Giving a single object multiple COM identities, part 4
- How do I consume raw COM interfaces from a Windows Runtime metadata file?
COM Apartments
- The dreaded "main" threading model
- A slightly less brief introduction to COM apartments (but it's still brief)
- Yo dawg, I hear you like COM apartments, so I put a COM apartment in your COM apartment so you can COM apartment while you COM apartment
- What kind of apartment is the private apartment I created via
CLSID_ContextSwitcher
? - Setting up private COM contexts to allow yourself to unload cleanly
- How do you get into a context via
IContextCallback::ContextCallback
? - Using contexts to return to a COM apartment later
- What do the output values from
CoGetApartmentType
mean? - User interface code + multi-threaded apartment = death
- Other problems traced to violating COM single-threaded apartment rules in the shell
- What's the point of
APTTYPE_CURRENT
? I mean, of course I'm current. - How do I get a foothold in the neutral apartment?
- What is so special about the Application STA?
- What does it mean when a call fails with
0x8000001F = RO_E_BLOCKED_CROSS_ASTA_CALL
?
COM Initialization
- What does the
COINIT_SPEED_OVER_MEMORY
flag to CoInitializeEx
do? - Crashing in COM after I call
CoUninitialize
, how can COM be running after it is uninitalized?
COM Static Store
- The COM static store, part 1: Introduction
- The COM static store, part 2: Race conditions in setting a singleton
- The COM static store, part 3: Avoiding creation of an expensive temporary when setting a singleton
- The COM static store, part 4: Aggregating into a single object
- The COM static store, part 5: Using COM weak references
- The COM static store, part 6: Using C++ weak references
COM Marshaling
- What is COM marshaling and how do I use it?
- On proper handling of buffers in COM and RPC methods
- What are the rules for
CoMarshalInterThreadInterfaceInStream
and CoGetInterfaceAndReleaseStream
? - What are the rules for
CoMarshalInterface
and CoUnmarshalInterface
? -
CoGetInterfaceAndReleaseStream
does not mix with smart pointers - The COM marshaller uses the COM task allocator to allocate and free memory
- Why do I get a
QueryInterface(IID_IMarshal)
and then nothing? - We batched up our COM requests and return a single stream of results, but the performance is still slow
- What are the various usage patterns for manually-marshaled interfaces?
- An initial look at the mechanics of how COM marshaling is performed
- https://devblogs.microsoft.com/oldnewthing/20220616-00/?p=106757
- Writing a marshal-by-value marshaler, part 1
- Writing a marshal-by-value marshaler, part 2
- Writing a compound marshaler
- Understanding the marshaling flags: The free-threaded marshaler
COM Error Handling
- What happens to my COM server-side object when clients die unexpectedly?
- Why does COM require output pointers to be initialized even on failure?
- How do I convert an
HRESULT
to a Win32 error code? - How can I tell the WIL
RETURN_IF_FAILED
macro that some errors are ignorable? - Do not overload the
E_NOINTERFACE
error - What does it mean when a call fails with
0x8000001F = RO_E_BLOCKED_CROSS_ASTA_CALL
? - What does it mean when my cross-thread COM call fails with
RPC_E_SYS_CALL_FAILED
? - Understanding a mysterious
RPC_E_WRONGTHREAD
exception when we're on the right thread
COM Asynchronous Interfaces
- COM asynchronous interfaces, part 1: The basic pattern
- COM asynchronous interfaces, part 2: Abandoning the operation
- COM asynchronous interfaces, part 3: Abandoning the operation after a timeout
- COM asynchronous interfaces, part 4: Doing work while waiting for the asynchronous operation
- COM asynchronous interfaces, part 5: The unreliable server
- COM asynchronous interfaces, part 6: Learning about completion without polling
- COM asynchronous interfaces, part 7: Being called directly when the operation completes
- COM asynchronous interfaces, part 8: Asynchronous release, the problems
- COM asynchronous interfaces, part 9: Asynchronous release, assembling a solution
GUIDs
- What's the difference between
UuidFromString
, IIDFromString
, CLSIDFromString
, GUIDFromString
... - What is the difference between
UuidToString
, StringFromCLSID
, StringFromIID
, and StringFromGUID2
? - Why are there four functions for parsing strings into GUIDs, and why are they in three different DLLs?
- Why does COM express GUIDs in a mix of big-endian and little-endian? Why can't it just pick a side and stick with it?
COM Strings
- Why is there a
BSTR
cache anyway? - Raymond's complete guide to
HSTRING
semantics - What is the correct way of using the string buffer returned by the
WindowsPreallocateStringBuffer
function?
COM Variants
- What's the difference between
VARIANT
and VARIANTARG
? - Nasty gotcha:
VarCmp
vs VariantCompare
- Why can't
VarDateFromStr
parse back a Hungarian date that was generated by VarBstrFromDate
?
IUnknown
- The layout of a COM object
- Under what conditions will the
IUnknown::AddRef
method return 0? - The ways people mess up
IUnknown::QueryInterface
- The ways people mess up
IUnknown::QueryInterface
, episode 2 - The ways people mess up
IUnknown::QueryInterface
, episode 3 - The ways people mess up
IUnknown::QueryInterface
, episode 4 - COM object destructors are very sensitive functions
- Avoiding double-destruction when an object is released
- I'd like an
IUnknown
, I know you have many, I'll take any of them - A very brief introduction to patterns for implementing a COM object that hands out references to itself
- Giving a single object multiple COM identities, part 1
- Giving a single object multiple COM identities, part 2
- Giving a single object multiple COM identities, part 3
- Giving a single object multiple COM identities, part 4
- Reducing chattiness by querying for multiple interfaces at once, part 1
- Reducing chattiness by querying for multiple interfaces at once, part 2
IMoniker
- Pidls and monikers do roughly the same thing, just backwards
ICallback
- A very brief introduction to patterns for implementing a COM object that hands out references to itself
IContextMenu
- Why an object cannot be its own enumerator
- How to host an
IContextMenu
, part 1 - Initial foray - How to host an
IContextMenu
, part 2 - Displaying the context menu - How to host an
IContextMenu
, part 3 - Invocation location - How to host an
IContextMenu
, part 4 - Key context - How to host an
IContextMenu
, part 5 - Handling menu messages - How to host an
IContextMenu
, part 6 - Displaying menu help - How to host an
IContextMenu
, part 7 - Invoking the default verb - How to host an
IContextMenu
, part 8 - Optimizing for the default command - How to host an
IContextMenu
, part 9 - Adding custom commands - How to host an
IContextMenu
, part 10 - Composite extensions - groundwork - How to host an
IContextMenu
, part 11 - Composite extensions - composition - Simplifying context menu extensions with
IExecuteCommand
- How do I launch a file as if it were a text file, even though its extension is not
.txt
? - Do not access the disk in your
IContextMenu
handler, no really, don't do it - Sure, we do that: Context menu edition
- Psychic debugging: Why your
IContextMenu::InvokeCommand
doesn't get called even though you returned success from IContextMenu::QueryContextMenu
- Don't forget to implement canonical names for verbs in your shell context menu extension
IFileDialog
- The
SetClientGuid
method of the common file and folder dialogs lets you give names to those dialogs, too (multiple contexts for open/save dialogs) - How can I get my
FileSavePicker
to open in the same folder that was picked by the FileOpenPicker
or FolderPicker
? (win32/COM equivalent mentioned at the end of the post) - Why does IFileDialog still show non-filesystem folders when I pass
FOS_FORCEFILESYSTEM
?
IMultiLanguage
- Converting between
LCID
s and RFC 1766 language codes - Feel free to stop using
IMultiLanguage2::DetectInputCodepage
INamespaceWalk
- How can I control which parts of the shell namespace the
INamespaceWalk::Walk
operation will walk into? - How can I cancel the
INamespaceWalk::Walk
operation? - Cancelling the
INamespaceWalk::Walk
operation a little faster
IStream
- The subtleties of
CreateStreamOnHGlobal
, part 1: Introduction and basic usage - The subtleties of
CreateStreamOnHGlobal
, part 2: Suppressing the deletion of an unknown HGLOBAL
- The subtleties of
CreateStreamOnHGlobal
, part 3: Suppressing the deletion of a shared HGLOBAL
- The subtleties of
CreateStreamOnHGlobal
, part 4: Non-movable memory - A practical use for
GetHGlobalFromStream
when sharing was never your intention
IVirtualDesktopManager
- Virtual desktops are an end-user window management feature, not a programmatic one
Clipboard
- How ownership of the Windows clipboard is tracked in Win32
- What happens when applications try to copy text by sending
Ctrl+C
- How do I make it so that users can copy static text on a dialog box to the clipboard easily?
- What is the proper handling of
WM_RENDERFORMAT
and WM_RENDERALLFORMATS
? - Copying a file to the clipboard so you can paste it into Explorer or an email message or whatever
- Printing the contents of the clipboard as text to
stdout
- Improving the performance of
CF_HDROP
by providing file attribute information - What's up with the
CF_SYLK
and CF_DIF
clipboard formats? - How can I wait more than 30 seconds for a delay-rendered clipboard format to become rendered?
Drag and Drop
- What a drag: Dragging text
- What a drag: Dragging a Uniform Resource Locator (URL)
- What a drag: Dragging a Uniform Resource Locator (URL) and text
- What a drag: Dragging a virtual file (
HGLOBAL
edition) - What a drag: Dragging a virtual file (
IStream
edition) - What a drag: Dragging a virtual file (
IStorage
edition) - You can drag multiple virtual objects, you know
- Reading a contract from the other side: Simulating a drop
- Simulating a drop, part two
- What happens if I drag the mouse by exactly the amount specified by
SM_CXDRAG
? - How do I accept files to be opened via
IDropTarget
instead of on the command line? - How do I accept files to be opened via
IDropTarget
instead of on the command line? - bonus content - Using Explorer's fancy drag/drop effects in your own programs
- Drag/drop effects: The little drop information box
- Why isn't my shell namespace extension getting every single
DragOver
mouse message? - Why doesn't my program get fancy drag/drop effects in high contrast mode with
CLSID_DragDropHelper
?
تعداد
- Using fibers to simplify enumerators, part 1: When life is easier for the enumerator
- Using fibers to simplify enumerators, part 2: When life is easier for the caller
- Using fibers to simplify enumerators, part 3: Having it both ways
- Using fibers to simplify enumerators, part 4: Filtering
- Using fibers to simplify enumerators, part 5: Composition
صدَفَة
- When does
SHLoadInProc
unload a DLL? - What does
SHGFI_USEFILEATTRIBUTES
mean? - What's the difference between
SHGetMalloc
, SHAlloc
, CoGetMalloc
, and CoTaskMemAlloc
- Querying information from an Explorer window
- Execute a file as if it were a program, even though its extension is not
EXE
- How do I launch a file as if it were a text file, even though its extension is not
.txt
? - What does the
SEE_MASK_UNICODE
flag in ShellExecuteEx
actually do? - Simple things you can do with the
ShellExecuteEx
function - What were
ShellExecute
hooks designed for? - Why does
ShellExecute
return SE_ERR_ACCESSDENIED
for nearly everything? - How do I
ShellExecute
a file, but with a specific program instead of the default program? - What is the difference between
CSIDL_DESKTOP
and CSIDL_DESKTOPDIRECTORY
? -
SHCIDS_CANONICALONLY
is the moral equivalent in the shell namespace of the Unicode ordinal comparison - Don't forget to double-null-terminate those strings you pass to
SHFileOperation
- Why does
SHFileOperation
have internal error codes for DVD? - Why do non-folders in my shell namespace extension show up in the folder tree view?
-
SHAutoComplete
giveth, and SHAutoComplete
taketh away - What is the
lpClass
member of SHELLEXECUTEINFO
used for? - Some known folders cannot be moved, but others can, and you'll just have to accept that
- One possible reason why
ShellExecute
returns SE_ERR_ACCESSDENIED
and ShellExecuteEx
returns ERROR_ACCESS_DENIED
- Why does
SHGetSpecialFolderPath
take such a long time before returning a network error? - How do you obtain the icon for a shortcut without the shortcut overlay? (
SHGetFileInfo()
) - How can I get information about the items in the Recycle Bin?
- Modernizing our simple program that retrieves information about the items in the Recycle Bin
- Invoking commands on items in the Recycle Bin
- How do I perform shell file operations while avoiding shell copy hooks?
- Command line tool to manage Windows 7 Libraries, with source code (
IShellLibrary
) -
IShellFolder::BindToObject
is a high-traffic method; don't do any heavy lifting - Obtaining the parsing name (and pidl) for a random shell object
- Creating a simple pidl: For the times you care enough to send the very fake
- Creating a simple shell item, just as fake as a simple pidl
- Displaying a property sheet for multiple files
- How do I get a high resolution icon for a file?
- How do I extract an icon at a nonstandard size if
IExtractIcon::Extract
tells me to go jump in a lake? - How do I read the "Double-click to open an item (single-click to select)" setting in Folder Options?
- The wonderful world of shell bind context strings
- Helper functions to make shell bind contexts slightly more manageable
- Customizing item enumeration with
IShellItem
- Customizing item enumeration with
IShellItem
, the old-fashioned way - How do I create an
IShellItemArray
from a bunch of file paths? - How do I invoke a verb on an
IShellItemArray
? - How does a shell namespace extension provide icons for virtual items that track the standard icons set by the user's file associations?
- How do I get the user-customed name of My Computer or Recycle Bin?
- How do I get the user-customized name of a mapped network drive?
- Enumerating all the programs that can open a particular file extension
- Enumerating all the programs that can launch a particular protocol
- How do I register a command on the desktop background context menu? (And how do I remove one I don't like?)
- How can I get the canonical name for a known folder?
- Peeking inside an
IShellItem
to see what it's made of - Why does
SHGetKnownFolderPath
return E_FAIL
for a known folder? - Why does
SHGetKnownFolderPath
fail when impersonating? - Why can't I use
SHSetKnownFolderPath
to change the location of FOLDERID_LocalAppData
? - How do I programmatically add a folder to my Documents library?
- Why doesn't
SHGetFileInfo
give me customized folder icons? - How can I detect that a shell item refers to a virtual folder, or to a file system inside a file?
- Why is there a limit of 15 shell icon overlays?
- The case of the
SHGetFolderPath(CSIDL_COMMON_DOCUMENTS)
that returned ERROR_PATH_NOT_FOUND
- Why is the
HSHELL_WINDOWDESTROYED
notification raised when a window is hidden, even if it hasn't been destroyed? - Why am I receiving
HCNE_UPDATEDIR
notifications that my code never generates? - Why am I receiving
SHCNE_UPDATEDIR
notifications that my code never generates? - How can I get the original target of a shortcut without applying any 32-bit adjustments?
- How does Explorer calculate the “Date” of a file?
Uncategorized COM Stuff
- The macros for declaring and implementing COM interfaces
- An introduction to COM connection points
- Dispatch interfaces as connection point interfaces
- Adjustor thunks
- What is the underlying object behind a COM interface pointer?
- How to turn off the exception handler that COM "helpfully" wraps around your server
- Shortcuts are serializable objects, which means that they can be stored in places other than just a file
- Why does
IFileOperation
skip junctions even though I passed FOFX_NOSKIPJUNCTIONS
? - Nasty gotcha:
STGM_READ | STGM_WRITE
does not grant read/write access - How can I get the list of programs the same way that Programs and Features gets it?
- How do I obtain the computer manufacturer's name via C++? (
IWbemClassObject
) - The stream pointer position in
IDataObject::GetData
and IDataObject::GetDataHere
is significant - The sad implementation history of COM component categories and why it means you have to click twice to see your newly-installed taskbar toolbar
- How do I request that my out-of-process COM server run unelevated?
- How can a desktop app use a Windows Runtime object that infers UI context from its thread? The
IInitializeWithWindow
pattern ( IInitializeWithWindow
) - How do I protect myself against a COM call that can hang? I'm already running the server out-of-process.
- What can I do about timer build-up when waiting for COM outbound calls to complete?
- Manipulating the positions of desktop icons
- A reminder about the correct way of accessing and manipulating the position of icons on the desktop
- The oracle always tells the truth, even when it is wrong: COM method calls with a user-defined type as a return value (on problems of COM interfaces called from C code)
- Notes on COM aggregation: Obtaining a pointer to your aggregated partner without introducing a reference cycle
- Notes on COM aggregation: How do you implement tear-offs in an aggregated object?
- The theory behind the
IHttpFilter
interface
ذاكرة
- Stupid memory-mapping tricks
- Creating a shared memory block that can grow in size
- Why do I have to pass a valid page protection value to
VirtualAlloc
even if it ignores it? - How can I include/exclude specific memory blocks in user-mode crash dumps?
-
IsBadXxxPtr
should really be called CrashProgramRandomly ( IsBadWritePtr()
et al.) - A closer look at the stack guard page
- The case of the stack overflow exception when the stack is nowhere near overflowing
- How to allocate address space with a custom alignment or in a custom address region
Input and Output
- Mount points, volumes, and physical drives, oh my!
- What's the difference between an asynchronous
PIPE_WAIT
pipe and a PIPE_NOWAIT
pipe? - Be careful when redirecting both a process's
stdin
and stdout
to pipes, for you can easily deadlock - Looking at the problem at the wrong level: Closing a process's
stdin
-
ReadDirectoryChangesW
reads directory changes, but what if the directory doesn't change? - How do
FILE_FLAG_SEQUENTIAL_SCAN
and FILE_FLAG_RANDOM_ACCESS
affect how the operating system treats my file? - I used
FILE_FLAG_SEQUENTIAL_SCAN
but it didn't seem to speed up my sequential scanning - You can use an
OVERLAPPED
structure with synchronous I/O, too - We're currently using
FILE_FLAG_NO_BUFFERING
and FILE_FLAG_WRITE_THROUGH
, but we would like our WriteFile
to go even faster - On using
ILE_FLAG_WRITE_THROUGH
and FILE_FLAG_NO_BUFFERING
for memory-mapped files - On the interaction between the
FILE_FLAG_NO_BUFFERING
and FILE_FLAG_WRITE_THROUGH
flags - Why does my synchronous overlapped
ReadFile
return FALSE
when the end of the file is reached? - Why does
SetFileValidData
fail even though I enabled the SE_MANAGE_VOLUME_NAME
privilege? - Is
GENERIC_ALL
equivalent to GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE
? -
CancelIoEx
can cancel I/O on console input, which is kind of nice -
CancelIoEx
can cancel synchronous I/O, which is kind of nice - Why does
IsPathRelative
return FALSE
for paths that are drive-relative? - The security check happens at the acquisition of the handle
- Taking a shortcut: You can query properties from a volume, and it will forward to the physical drive
- https://devblogs.microsoft.com/oldnewthing/20201023-00/?p=104395
- How do I disassociate a thread from an I/O completion port?
- Is it okay to call
MapViewOfFile
on the same mapping handle simultaneously from different threads? - What are these dire multithreading consequences that the
GetFullPathName
documentation is trying to warn me about? - How can I force a
WriteFile
or ReadFile
to complete synchronously or hang, in order to test something? - How can I perform a
CopyFile
, but also flush the file buffers before the destination handle is closed?
Asynchronous Input and Output
- Developing the method for taking advantage of the fact that the
OVERLAPPED
associated with asynchronous I/O is passed by address - Ready... cancel... wait for it! (part 1)
- Ready... cancel... wait for it! (part 2)
- Ready... cancel... wait for it! (part 3)
- If you're waiting for I/O to complete, it helps if you actually have an I/O to begin with
- Why does my asynchronous I/O complete synchronously?
- If an asynchronous I/O completes synchronously, is the
hEvent
in the OVERLAPPED
structure signaled anyway? - You can use an
OVERLAPPED
structure with synchronous I/O, too - Why does my synchronous overlapped
ReadFile
return FALSE
when the end of the file is reached? - If I issue a second overlapped I/O operation without waiting for the first one to complete, are they still guaranteed to complete in order?
- Why are my file write operations synchronous, even though I opened the file as
FILE_FLAG_OVERLAPPED
? - File-extending writes are not always synchronous, which is entirely within the contract
- Why you might need additional control over the secret event hiding inside the file object
- Why doesn't my asynchronous read operation complete when I close the handle?
- The mental model for
StartThreadpoolIo
- How can I force a
WriteFile
or ReadFile
to complete synchronously or hang, in order to test something? - If I issue multiple overlapped I/O requests against the same region of a file, will they execute in the order I issued them?
- What are the potentially-erroneous results if you don't pass
NULL
as the lpNumberOfBytesRead
when issuing overlapped I/O?
Files and Directories
- The Definitive Guide on Win32 to NT Path Conversion
- How can I tell that a directory is really a recycle bin?
- How can I tell that a directory is weird and should be excluded from the user interface?
- How do I get information about the target of a symbolic link?
- How do I access a file without updating its last-access time?
- How do I show the contents of a directory while respecting the user's preferences for hidden and super-hidden files as well as the user's language preferences?
- You can use a file as a synchronization object, too
- How can I append to a file and know where it got written, even if the file is being updated by multiple processes?
- The
FILE_FLAG_DELETE_ON_CLOSE
flag applies to the handle, also known as the file object, which is not the same as the file - How long do I have to keep the
SECURITY_ATTRIBUTES
and SECURITY_DESCRIPTOR
structures valid after using them to create a file? - How do I create a directory where people can create subdirectories but cannot mess with those created by other users?
- How can I tell whether a file is on a removable drive, a fixed drive, or a remote drive?
- How can I tell whether a file is on an SSD?
- Why does a non-recursive
ReadDirectoryChangesW
still report files created inside subdirectories? - The early history of Windows file attributes, and why there is a gap between System and Directory
- Even if you open a file with GUID, you can still get its name, or at least one of its names (
GetFinalPathNameByHandle()
) - How do I get from a file path to the volume that holds it?
- How do I get from a volume to the physical disk that holds it?
- Renaming a file is a multi-step process, only one of which is changing the name of the file
- How can I recognize file systems that don't support 64-bit unique file identifiers?
- How can I recognize whether two handles refer to the same underlying file?
ACL
- The
MoveSecurityAttributes
policy affects only how Explorer recalculates ACLs when a file is moved; everybody else is on their own - How to create a folder that inherits its parent's ACL, and then overrides part of it
Security Permissions, Attributes and Identifiers
- The security check happens at the acquisition of the handle
- What is the default security descriptor?
- How do I convert a SID between binary and string forms?
- What are these SIDs of the form
S-1-15-2-xxx
? - What are these SIDs of the form
S-1-15-3-xxx
? - An easy way to determine whether you have a particular file permission
- What are the access rights and privileges that control changing ownership of an object?
- How do the names in the file security dialog map to access control masks?
- If you ask for
STANDARD_RIGHTS_REQUIRED
, you may as well ask for the moon - A user's SID can change, so make sure to check the SID history
- Detecting whether a SID is well-known SID
- SIDs are really just another a fancy way of creating unique IDs in a decentralized way
- What's the point of giving my unnamed object proper security attributes since unnamed objects aren't accessible outside the process anyway (or are they?)
- Is a SID with zero subauthorities a valid SID? It depends whom you ask
- What's the difference between duplicating the handle to a token and duplicating a token?
- I called
AdjustTokenPrivileges
, but I was still told that a necessary privilege was not held - I called
AdjustTokenPrivileges
, but I was still told that a necessary privilege was not held, redux - The history of the
EncodePointer
function for obfuscating pointers - Additional helpful pseudo-handles: The process token, the thread token, and the effective token
- How can I tell whether my process is running as SYSTEM?
- A brief summary of the various versions of the Security Descriptor Definition Language (SDDL)
- How do I free the pointers returned by functions like
GetTokenInformation
? - A clarification on the multithreading constraints of the
EncryptMessage
function
Registry
- Beware of non-null-terminated registry strings
- The performance cost of reading a registry key
- So how bad is it that I'm calling
RegOpenKey
instead of RegOpenKeyEx
? - If I simply want to create a registry key but don't intend to do anything else with it, what security access mask should I ask for?
- How can I programmatically inspect and manipulate a registry hive file without mounting it?
- Why doesn't
RegSetKeySecurity
propagate inheritable ACEs, but SetSecurityInfo
does? - Why does
RegNotifyChangeKeyValue
stop notifying once the key is deleted? - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it? part 1 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it? part 2 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it? part 3 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it? part 4 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it? part 5 - The history of passing a null pointer as the key name to
RegOpenKeyEx
- On the failed unrealized promise of
RegOverridePredefKey
(ie don't use it.)
Strings and Locales
-
TEXT
vs. _TEXT
vs. _T
, and UNICODE
vs. _UNICODE
- The sad history of Unicode
printf
-style format specifiers in Visual C++ - Nasty gotcha:
SetThreadUILanguage
cannot be used to restore the thread UI language - How can
CharUpper
and CharLower
guarantee that the uppercase version of a string is the same length as the lowercase version? (use LCMapStringEx()
in any new code) - Is there a code page that matches ASCII and can round trip arbitrary bytes through Unicode?
- A consequence of being the first to adopt a standard is that you may end up being the only one to adopt it: The sad story of Korean jamo
- The
activeCodePage
manifest element can be used for more than just setting UTF-8 as the active code page - Feel free to stop using
IMultiLanguage2::DetectInputCodepage
- On the proper care and feeding of the enigmatic
GetDistanceOfClosestLanguageInList
function - How can I get
WideCharToMultiByte
to convert strings encoded in UTF-16BE?
NT Services
- Calling
ShutdownBlockReasonCreate
from my service doesn't stop the user from shutting down - What does it mean when my attempt to stop a Windows NT service fails with
ERROR_BROKEN_PIPE
? - How can I configure my Windows NT service to autostart when the system gains Internet access?
- On the confusing names for the Windows service SID types
غير مصنف
- How do I determine the processor's cache line size? (
GetLogicalProcessorInformation()
) - Why are structure sizes checked strictly?
- What's the difference between
CreateMenu
and CreatePopupMenu
? - Why are
HANDLE
return values so inconsistent? - How to retrieve text under the cursor (mouse pointer)
- How to detect programmatically whether you are running on 64-bit Windows
- A timed context menu
- The importance of passing the
WT_EXECUTELONGFUNCTION
flag to QueueUserWorkItem
- If your callback fails, it's your responsibility to set the error code
- The double-click time tells the window manager how good your reflexes are
- The cursor isn't associated with a window or a window class; it's associated with a thread group
- Menu item states are not reliable until they are shown because they aren't needed until then
- How can I display a live screenshot of a piece of another application?
- Converting from a UTC-based
SYSTEMTIME
directly to a local-time-based SYSTEMTIME
- Programmatically uploading a file to an FTP site
- How can you use both versions 5 and 6 of the common controls within the same module?
- How can I tell if Windows Update is waiting for the system to reboot?
- How do I call
SetTimer
with a timer ID that is guaranteed not to conflict with any other timer ID? - A window can't have two timers with the same ID, so how do I assign an ID that nobody else is using?
- What does it mean when a display change is temporary?
- How do I obtain the comment for a share?
- How accurate are the various Windows time-querying functions?
- How can I detect whether the user is logging off?
- Why are timer IDs and dialog control IDs 64-bit values on 64-bit Windows? Did you really expect people to create more than 4 billion timers or dialog controls?
- If you suppress GDI+ background thread, then you are expected to pump messages yourself
- If one program blocks shutdown, then all programs block shutdown (
WM_QUERYENDSESSION
, WM_ENDSESSION
) - When I ask the
GetIpAddrTable
function to sort the results, how are they sorted? - How can I detect that the system is no longer showing a UAC prompt? (
EVENT_SYSTEM_DESKTOPSWITCH
) - How can I get the number of processors in the system, when there are more than 64?
- Why are some system functions exported as stubs instead as forwarders?
- How can I check whether the user has disconnected from the session?
- Why does
PF_VIRT_FIRMWARE_ENABLED
return false even when virtualization is enabled in the firmware? - How can I convert between IANA time zones and Windows registry-based time zones?
- The focus rectangle says, “I'm not orange. I'm just drawn that way.”
- Why does the precise point at which I get a stack overflow exception change from run to run? (structured exception handling aka SEH)
- How do I programmatically reposition monitors in a multiple-monitor system? (
ChangeDisplaySettingsEx()
) - How do I upgrade a 32-bit tick count to a 64-bit one?
- The error code you get might not be the one you want
- How can I find out which processor architectures are supported via emulation by the current system?
- How can I detect whether the system has a keyboard attached? On the
GetRawInputDeviceList
function - Filtering out fake keyboards from the
GetRawInputDeviceList
function - How expensive is
PssCaptureSnapshot
? ما هي السرعة؟ How much memory does it consume? - What is the
CreateExplorerShellUnelevatedTask
scheduled task? - Under what conditions can I modify the memory that I received in the form a
STGMEDIUM
? - Is it true that raising a structured exception from a structured exception handler terminates the process?
- Why are many Windows user interface elements positioned at multiples of 4 or 8 pixels? (DPI,
DEVICE_SCALE_FACTOR
) - A history of the
fd_set
, FD_SETSIZE
, and how it relates to WinSock - How can I detect programmatically whether Windows is an N or KN version?
- How should I interpret the various values of
NLM_CONNECTIVITY
? - How can I find out the last time a user logged on from C++?
- How can I specify icons for my app to use on the Start menu in high contrast mode?
- How can I add an environment variable to a process launched via
ShellExecuteEx
or IContextMenu
? - Functions that return the size of a required buffer generally return upper bounds, not tight bounds