Der alte neue Win32API
Diese Seite enthält eine Liste von Links zu Teilmenge der Beiträge von Raymond Chens berühmtem Blog The Old New Ding . Die Untergruppe ist hauptsächlich auf Win32API und einige COM-verwandte Sachen beschränkt.
Der Grund, warum ich diese Seite pflege, ist, dass sie häufig Informationen liefert, die bei MSDN fehlen oder die dort auf kryptische Weise beschrieben werden, und auch, weil der Blog nicht leicht durchsucht werden kann.
Die Links hier werden nach ihrem Thema anstelle einer chronologischen Ordnung kategorisiert. Manchmal kann ein einzelner Beitrag in mehreren Kategorien in mehreren Kategorien versetzt werden.
In einigen (ziemlich seltenen) Fällen sind Links zu anderen Quellen enthalten, wenn sie als nützlich befunden werden.
Haftungsausschluss: Ich beantrage keine Autorschaft mit verknüpften Inhalten. Hier geht es nur um hoffentlich nützliche Organisation der großen Artikel, die Raymond im Laufe der Jahre geschrieben hat.
Inhaltsverzeichnis
- Prozesse und Fäden
- Prozesse
- Themen
- Fadenpools
- Fadenaffinität von Objekten
- Fadenstapel
- Fasern
- Synchronisation
-
WaitOnAddress()
-
WaitForMultipleObjects()
und Verwandte - Lock-freie Muster
- DLLs
- Ressourcen
- Bitmap- und Icon -Ressourcen
- Dialogvorlagen
- Menüvorlagen und Beschleunigungsressourcen
- String -Ressourcen
- Versionsvorlagen
- Daten und benutzerdefinierte Ressourcen
- Anwendung (insgesamt)
-
HWND
(allgemeiner Standpunkt)- Windows -Hierarchie
- Fensterstile
- Fensterklassen
- Fenster auf oberster Ebene
- Fensterrahmen und Bildunterschrift
- DWM
- Dialoge
- Verschachtelte und eingebettete Dialoge
- Gemeinsame Dialoge
- Kontrollnavigation
- Dialogmanager
- Modalität
- Immobilienblätter
- Kontrollen
- Animationskontrollen
- Knöpfe
- Kombinationsboxen
- Steuerelemente bearbeiten
- Listen Sie Ansichten auf
- Reiche Textsteuerungen
- Scrollbars
- Statische Kontrollen
- Symbolleisten
- Tooltips
- Trackbars
- Baumlistenansichten
- Verarbeitung von Nachrichten
- Spezifische Nachrichten
- Benachrichtigungen
- Fensterkonstruktion und Zerstörung
- Fenstergeometrienachrichten
- Fenstermalerei Nachrichten
- Fensterfokus -Nachrichten
- Tastaturnachrichten
- Mausmeldungen
- Dialognachrichten
- Andere Fenstermeldungen
- Systemmeldungen
- GDI
- Cursoren
- Bürsten
- Stifte
- Bitmaps
- Dib
-
LockWindowUpdate()
- Malt Standardelemente
-
UXTHEME.DLL
- Mehrere Monitore
- Zugänglichkeit
- Com
- COM -Schnittstellen deklarieren
- Com Apartments
- COM -Initialisierung
- Com statischer Laden
- Com Marshaling
- COM -Fehlerbehandlung
- Com asynchrone Schnittstellen
- Guids
- Com Strings
- Com Varianten
-
IUnknown
-
IMoniker
-
ICallback
-
IContextMenu
-
IFileDialog
-
IMultiLanguage
-
INamespaceWalk
-
IStream
-
IVirtualDesktopManager
- Zwischenablage
- Ziehen und Drop
- Aufzählung
- Hülse
- Nicht kategorisierte Com -Sachen
- Erinnerung
- Eingang und Ausgabe
- Asynchroner Eingang und Ausgang
- Dateien und Verzeichnisse
- ACL
- Sicherheitsberechtigungen, Attribute und Kennungen
- Registrierung
- Saiten und Orte
- NT -Dienste
- Nicht kategorisiert
Prozesse und Fäden
Prozesse
-
CreateProcess
wartet nicht, bis der Prozess beginnt - Warum modifiziert die Funktion
CreateProcess
die Befehlszeile für Eingabe? - Warum nehmen die Leute ein Schloss um
CreateProcess
-Anrufe? - Deaktivieren des Programms zum Programmabsturz
- Wie übergeben ich viele Daten an einen Prozess, wenn er beginnt?
- Was war der Zweck des Parameters
hPrevInstance
für WinMain
? - Ist
RunAsInvoker
eine geheime, noch höhere UAC -Einstellung? - Wie kann ich verhindern, dass ein untergeordneter Prozess das Dialogfeld Windows ERROR -Berichtsberichterstattung anzeigt?
- Wie kommt es, dass
WriteProcessMemory
es gelingt, nur schreibgeschrieben zu schreiben? - Ist es eine gute Idee, den
WriteProcessMemory
für mich verwalten zu lassen? - Wie kann ich einen nicht gelobten Prozess aus meinem erhöhten Prozess, Redux, starten?
- Wie kann ich die Integritätsniveau meines Prozesses überprüfen?
- Stimmt es, dass die Erhöhung einer strukturierten Ausnahme von einem strukturierten Ausnahmebehandler den Prozess beendet?
- Eine direktere und fehlerfreiere Methode, um einen Prozess in einem Jobobjekt zu erstellen
Themen
- Ungültige Thread- und Prozess -IDs
- Warum wird mein Fadengriff plötzlich schlecht? Ich wartete nur darauf!
- Was passiert, wenn Sie einfach aus dem Thread -Rückruf zurückkehren, der an
_beginthread
und _beginthreadex
übergeben wurde? - Warum sollten Sie niemals einen Thread aussetzen sollten
- Die Gefahren des Schlafens auf einem UI -Faden
- In der Verfolgung der Nachrichtenwarteschlange
- Aufzählung von Themen in einem Prozess
- Win32 User Interface Work ist von Natur aus Single-Threaded
- Wie schlimm ist es, nach dem Verlassen des Threads eine lange Zeit zu verzögern?
- Wenn ich
GetExitCodeThread
für einen Thread nenne, den ich mit Sicherheit beendet habe, warum heißt es immer noch STILL_ACTIVE
? - Gibt es ein Problem mit
CreateRemoteThread
auf 64-Bit-Systemen? - Ist die
TerminateThread
-Funktion synchron? - Entfernen des
TerminateThread
aus Code, der auf ein Jobobjekt wartet, um zu leeren - Was ist der Sinn von
FreeLibraryAndExitThread
? - Was passiert, wenn ich widersprüchliche Werte für das Stack Commit and Stack Reserve gebe?
Fadenpools
- Was genau bedeutet der Parameter
msWindowLength
zu SetThreadpoolTimer
? - Was ist der Unterschied zwischen
CreateTimerQueueTimer
und SetThreadpoolTimer
? - So vermeiden Sie den Zugriff auf den auf Freed -Speicher zugänglichen Speicher beim Abbrechen eines Thread -Pool -Rückrufs
- Vermeiden von Deadlocks beim Stornieren eines Thread -Pool -Rückrufs, Teil 1: Externe Rückrufdaten
- Vermeiden von Deadlocks beim Stornieren eines Thread -Pool -Rückrufs, Teil 2: Verweisen Sie auf das enthaltende Objekt zurück
- GOTCHA: Ein periodischer Threadpool -Timer wartet nicht, bis die vorherige Zecke abgeschlossen ist
- Warum bekomme ich eine Ausnahme vom Thread -Pool während des Herunterfahrens?
- Was passiert mit dem von der an
QueueUserWorkItem
übergebenen Wert aus der Funktion? - Das mentale Modell für
StartThreadpoolIo
- Wie kann ich feststellen, dass ein Thread -Pool -Arbeitselement zu lange dauert?
- Wie kann ich einen Thread -Pool schließen und alle Arbeiten absagen, die daran in der Warteschlange gestellt wurden?
Fadenaffinität von Objekten
- Thread -Affinität von Benutzeroberflächenobjekten, Teil 1: Fenstergriffe
- Thread -Affinität von Benutzeroberflächenobjekten, Teil 2: Gerätekontexte
- Thread -Affinität von Benutzeroberflächenobjekten, Teil 3: Menüs, Symbole, Cursor und Beschleunigungstabellen
- Thread -Affinität von Benutzeroberflächenobjekten, Teil 4: GDI -Objekte und andere Hinweise zur Affinität
- Thread-Affinität von Benutzeroberflächenobjekten, Teil 5: Objektreinigung
- Thread -Affinität der Benutzeroberflächenobjekte: Addendum
Fadenstapel
- Wie kann ich den Stapel meines Threads zur Laufzeit erweitern?
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 1
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 2
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 3
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 4
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 5
- Verwenden Sie Fasern, um den Stapel eines Threads zur Laufzeit zu erweitern, Teil 6
- Vergleich der Fasern mit Threads, um den Stapel eines Threads zur Laufzeit zu erweitern
- Bestimmen Sie ungefähr, wie viel Stapelraum verfügbar ist, Teil 1
- Bestimmen Sie ungefähr, wie viel Stapelraum verfügbar ist, Teil 2
Fasern
- Was passiert mit den Fasern, die auf einem Thread lief, wenn der Thread beendet ist?
- Es ist in Ordnung, Fasern zu verwenden, aber jeder muss mit dem Plan an Bord sein
- Fasern sind nicht mehr nützlich; Es gibt nur eine Ecke davon, die aus einem Grund nützlich bleibt, der nicht mit den Fasern zusammenhängt
Synchronisation
- Verständnis der Konsequenzen von
WAIT_ABANDONED
- Windows -Ereignisse, kritische Abschnitte und neue Vista -Synchronisationsfunktionen
- Kombinieren Sie die Arbeitswarteschlange mit unterschiedlichen Ereignissen, bestellen Sie nicht wichtig, mit einem automatischen Ereignis
- Wie fair sind SRW -Schlösser, insbesondere wenn es sowohl Leser als auch Schriftsteller gibt?
- Sie können eine Datei auch als Synchronisationsobjekt verwenden
- Kann ich darauf warten, dass ein Kernel -Ereignis unsigniert wird?
- Wenn sich das schlanke Leser/Autor -Schloss (
SRWLOCK
) nicht erinnert, wer der gemeinsame Lock -Besitzer ist, heißt das dann in Ordnung, ihn rekursiv zu erwerben?
WaitOnAddress()
-
WaitOnAddress
können Sie ein Synchronisationsobjekt aus einer Datenvariablen erstellen, sogar ein Byte - Implementierung einer Synchronisationsbarriere in Bezug auf
WaitOnAddress
- Implementierung eines kritischen Abschnitts in Bezug auf
WaitOnAddress
- Erweitern Sie unseren kritischen Abschnitt basierend auf
WaitOnAddress
um Zeitüberschreitungen zu unterstützen - Vergleich von
WaitOnAddress
mit Futexes (Futexi? Futexen?) - Erstellen eines Semaphors von
WaitOnAddress
- Erstellen eines Semaphors mit einer maximalen Anzahl von
WaitOnAddress
- Erstellen eines manuellen Ereignisses von
WaitOnAddress
- Erstellen eines automatischen Ereignisses von
WaitOnAddress
WaitForMultipleObjects()
und Verwandte
-
MsgWaitForMultipleObjects
und der Warteschlangenzustand - Sie können
MsgWaitForMultipleObjects
mit Nullhandles aufrufen - Meldungen pumpen, während er einen bestimmten Zeitraum wartet
- Das Warten auf alle Griffe mit
MsgWaitForMultipleObjects
ist ein Fehler, der darauf wartet, dass er passiert - Warum
WaitForMultipleObjects
return ERROR_INVALID_PARAMETER
, wenn alle Parameter für mich gültig aussehen? - Wenn mehr als ein Objekt dazu führt, dass ein
WaitForMultipleObjects
zurückkehrt, wie kann ich dann über die anderen erfahren? - Was bringt es, ein nie signalisiertes Ereignis an
MsgWaitForMultipleObjects
zu übergeben?
Lock-freie Muster
- Kostenlose Muster für viele Produzierer/Einzelverbraucher sperren
- Sperren Sie kostenlose Muster für viele Produzierer/Einzelkonsumenten: eine Arbeitswarteschlange, in der der letzte gewinnt
- Lock Free Viele Produzierer/Einzelkonsumentenmuster: Eine Arbeitswarteschlange identischer nicht-koalarmer Ereignisse
- Sperren Sie kostenlose Muster der Viele Produzierer/Einzelkonsumenten: Eine Arbeitswarteschlange mit unterschiedlichen Ereignissen, bestellen Sie nicht wichtig
- Lock Free Viele Produzierer/Einzelkonsumentenmuster: Eine Arbeitswarteschlange mit unterschiedlichen Ereignissen, FIFO
- Lock Free Viele Produzierer/Einzelkonsumentenmuster: Eine Arbeitswarteschlange mit unterschiedlichen Ereignissen, nicht wichtig, Follow-up-Frage
DLLs
- Vertrauen Sie nicht der Rückgabemitteladresse
- Warum kann ich keine Funktion
GetProcAddress
, die ich dllexportiert habe? - Was ist der Unterschied zwischen
HINSTANCE
und HMODULE
? - Zugriff auf die
HINSTANCE
des aktuellen Moduls aus einer statischen Bibliothek -
LoadLibraryEx(DONT_RESOLVE_DLL_REFERENCES)
ist grundlegend fehlerhaft - Warum werden DLLs in der "falschen" Reihenfolge entladen?
- Wie werden DLL-Funktionen in 32-Bit-Fenstern exportiert?
- Exportierte Funktionen, die wirklich Spediteure sind
- Überdenken der Art und Weise, wie DLL-Exporte für 32-Bit-Fenster gelöst werden
- Namen in der Importbibliothek sind aus einem bestimmten Grund dekoriert
- Was passiert, wenn Sie dllimport falsch verstanden haben?
- Probleme im Zusammenhang mit dem Erzwingen eines Stubs, der für eine importierte Funktion erstellt werden soll
- Speicher über Modulgrenzen hinweg zuzuweisen und zu befreien
- Die DLL-Weiterleitung ist nicht dasselbe wie Verzögerungsbelastung
- Was deutet DLL Import an?
- Was ist DLL Importbindung?
- Was ist der Sinn von
FreeLibraryAndExitThread
? - Eine Bibliothek, die über
LOAD_LIBRARY_AS_DATAFILE
(oder ähnliche Flags) geladen wurde - Könnte es Probleme beim Aufrufen von
GetModuleFileNameEx
für Ihren eigenen Prozess geben? - Wie kann ich angeben, dass meine DLL eine DLL -Abhängigkeit von demselben Verzeichnis, in dem sich die DLL befindet, auflösen sollte?
- Nachdem ich meine DLL-Verzögerung einer weiteren DLL geladen hatte, hat meine DLL angefangen, in ihrem Prozessableitungscode zu stürzen
- Die verschiedenen Arten von DLL -Pflanzen
- Warum produziert
GetModuleInfo
keinen Einstiegspunkt für ausführbare Produkte? - Was bedeutet die
SizeOfImage
in der MODULEINFO
-Struktur? - Wie untersuche ich das Fehlerbox, das angezeigt wird, wenn ein
LoadLibrary
fehlschlägt?
DllMain()
- Einige Gründe, in Ihrem
DllMain
nichts Beängstigendes zu tun - Ein weiterer Grund, in Ihrem
DllMain
nichts Beängstigendes zu tun: versehentlicher Deadlock - Einige Gründe, in Ihrem
DllMain
nichts Beängstigendes zu tun, Teil 3 - Der Thread, der die
DLL_PROCESS_ATTACH notification
DLL_PROCESS_DETACH
erhält - Wie Sie möglicherweise eine DLL während
DLL_PROCESS_DETACH
laden, ohne sie zu merken - Wenn
DLL_PROCESS_DETACH
Ihnen sagt, dass der Prozess beendet ist, ist es Ihre beste Wahl, nur zurückzukehren, ohne etwas zu tun
Ressourcen
-
CP_ACP
Ressourcencompiler stand - Die Beziehung zwischen Modulressourcen und von Ressourcen abgeleiteten Objekten in 32-Bit-Fenstern
- Was ist der Unterschied zwischen
FreeResource
und beispielsweise DestroyAcceleratorTable
- PE-Ressourcen müssen 4-Byte-Ausrichtung sein, aber das hindert die Menschen nicht daran, andere Ausrichtungen auszuprobieren
- Wie kann ich sagen, dass jemand das
MAKEINTRESOURCE
-Makro verwendet hat, um eine Ganzzahl in einen Zeiger zu schmuggeln? - Schrecklich böse Gotcha:
FindResource
und FindResourceEx
Bitmap- und Icon -Ressourcen
- Warum stehen Geräteunabhängige Bitmaps auf den Kopf?
- Das Format von Bitmap -Ressourcen
- Das Format der Icon -Ressourcen
- Das Format der Icon -Ressourcen, überarbeitet
- Die Entwicklung des ICO -Dateiformates, Teil 1: Monochrome Anfänge
- Die Entwicklung des ICO -Dateiformates, Teil 2: Jetzt in Farbe!
- Die Entwicklung des ICO-Dateiformates, Teil 3: Alpha-gebundene Bilder
- Die Entwicklung des ICO -Dateiformates, Teil 4: PNG -Bilder
- Wie setze ich den Alpha -Kanal einer GDI -Bitmap auf 255?
Message String -Ressourcen
- Warum sagt
FormatMessage
, dass %0
die Nachricht ohne eine nachfolgende neue Linie endet? Fügt es heimlich neue Zeilen hinzu?
Dialogvorlagen
- Bei der Schwierigkeit, Pixel-perfekte Layout in Win32-Dialogvorlagen zu erhalten
- Die Entwicklung von Dialogvorlagen - 32 -Bit -Klassiker vorlagen
- Die Entwicklung von Dialogvorlagen - 32 -Bit -erweiterte Vorlagen
- Die Entwicklung der Dialogvorlagen - Zusammenfassung
- Der Ressourcen -Compiler fügt Ihnen hilfreich Fensterstile hinzu. Wenn Sie jedoch selbst eine Dialogvorlage erstellen, erhalten Sie diese Hilfe nicht
Menüvorlagen und Beschleunigungsressourcen
- Die Entwicklung der Menüvorlagen: Einführung
- Die Entwicklung der Menüvorlagen: 32-Bit klassische Menüs
- Die Entwicklung der Menüvorlagen: 32-Bit-erweiterte Menüs
- Das Format von Gaspecelerator Table Ressourcen
String -Ressourcen
- Das Format der String -Ressourcen
-
LoadString
kann Strings mit eingebetteten Nulls laden, aber Ihre Wrapper -Funktion ist möglicherweise nicht
Versionsvorlagen
- Die Entwicklung der Versionsressourcen - 32 -Bit -Versionsressourcen
- Die Entwicklung der Versionsressourcen - beschädigte 32 -Bit -Versionsressourcen
Daten und benutzerdefinierte Ressourcen
- Das Format von Daten und benutzerdefinierten Ressourcen
Anwendung (insgesamt)
- Welche Fenster werden in der
Alt+Tab
angezeigt? - Windows Vista hat die Registerkarte
Alt+Tab
leicht geändert - Win32 User Interface Work ist von Natur aus Single-Threaded
- Wann überschreibt
STARTF_USESHOWWINDOW
den an ShowWindow
übergebenen Parameter? -
WaitForInputIdle
sollte wirklich als WaitForProcessStartupComplete
bezeichnet werden -
WaitForInputIdle
wartet auf einen Thread, der möglicherweise nicht der Thread ist, den Sie sich interessieren - Was sind die Konventionen für die Verwaltung von Standardgriffe?
- Standardgriffe sind wirklich für Programme mit Single-Thread-Programmen gedacht
- Wenn nur DLLs
DllMain
-Benachrichtigungen erhalten können, wie kann ein EXE eine Benachrichtigung erhalten, wenn ein Thread erstellt wird (zum Beispiel)?
Befehlszeile
- Das erste Wort in der Befehlszeile ist der Programmname nur nach Konvention
- Wie soll die
CommandLineToArgvW
-Funktion verwendet werden? - Was ist mit der seltsamen Behandlung von Anführungszeichen und Backslashes durch
CommandLineToArgvW
los
Taskleiste
- Wie kann ich Benutzer daran hindern, mein Programm in die Taskleiste festzuhalten?
- Anstatt etwas zu erstellen und dann zu versuchen, es zu verbergen, erstellen Sie es einfach nicht in erster Linie (Tray -Symbol)
- Was ist, wenn meine Anwendung wirklich zwei Anwendungen in einer einzigen Datei gebündelt ist und ich möchte, dass sie in der Taskleiste in Windows 7 in zwei Gruppen aufgenommen werden?
- Wie kann ich anpassen, wie meine Anwendungsfenster in der Taskleiste gruppiert sind?
- Zeigen Sie ein Overlay auf der Taskleisten -Taste an
- Zeigen Sie Steuertasten in Ihrem Taskleisten -Vorschau -Fenster an
- Zeigen Sie ein benutzerdefiniertes Miniaturbild für Ihre Bewerbung an (und während Sie in der IT eine benutzerdefinierte Live -Vorschau)
- Wie kann ich den Ort der Taskleiste für Sekundärmonitore abfragen?
- Wie hat sich dieses Programm geschafft, sich an meine Taskleiste festzuhalten, als ich es installiert habe?
- Was ist, wenn ich zwei Programme habe, die logischerweise eine einzige Anwendung sind und dass sie als einzelne Gruppe in der Taskleiste behandelt werden?
- Warum ändert sich das Taskleistensymbol für gruppierte Fenster zu etwas Seltsamem?
HWND
(allgemeiner Standpunkt)
- Was bedeutet es, dass ein Fenster Unicode ist?
- Wie kann ich die tatsächliche Fensterprozeduradresse und keine Thunk erhalten?
- Was sind diese seltsamen Werte von
GWLP_WNDPROC
zurückgegeben? - Die Bonusfenster -Bytes bei
GWLP_USERDATA
- Was ist der Unterschied zwischen
WM_DESTROY
und WM_NCDESTROY
? - Senden eines Fensters Eine
WM_DESTROY
-Nachricht ist wie Streich, der jemanden anruft, der vorgibt, die Polizei - Das geheime Leben von
GetWindowText
- Warum sind die Regeln für
GetWindowText
so seltsam? - Malen nur dann, wenn Ihr Fenster auf dem Bildschirm sichtbar ist
- Bestimmen Sie, ob Ihr Fenster abgedeckt ist
- Erhalten der Größe und Position eines Fensters, während sie minimiert wird
- Warum gibt es sofort nicht das gleiche Fenster zurück zurück, wenn
GetForegroundWindow
SetForegroundWindow
nicht nachgefolgt ist? - Wie entscheidet Windows, ob ein neu erstelltes Fenster LTR- oder RTL-Layout verwenden sollte?
Windows -Hierarchie
- Was ist das Besondere am Desktop -Fenster?
- Was ist das Fensternistgrenze?
- Was ist der Unterschied zwischen
HWND_TOP
und HWND_TOPMOST
? - Ein Fenster kann einen Elternteil oder einen Besitzer haben, aber nicht beides
- Warum sendet meine Kontrolle ihre Benachrichtigungen an das falsche Fenster, nachdem ich es wiederholt habe?
-
WindowFromPoint
, ChildWindowFromPoint
, RealChildWindowFromPoint
, wann wird alles enden? -
GetParent
, genauso verwirrend wie EnumClaw
, aber es ist eine tatsächliche Funktion! ( GetAncestor()
, GetWindow()
) - Ein Eigentümerfenster aus einem anderen Prozess zu haben ist schwierig, aber manchmal ist es das Richtige zu tun
- Was ist die Dokumentation für
SetParent
die versucht, mir über die Synchronisierung des UI -Zustands zu erzählen? - Demonstrieren, was passiert, wenn ein Eltern- und Kinderfenster unterschiedliche Benutzeroberflächenzustände haben
- Ein Eltern- und Kinderfenster zu bekommen, um die gleichen UI -Zustände zu haben
Fensterstile
- Welche Fensterstil -Bits gehören zu wem?
- Wie kann ich angeben, dass ich möchte, dass mein Fenster nach rechts nach links-Layout-Regeln befolgt?
- Warum ist meine transparente statische Steuerung nicht transparent? (
WS_EX_TRANSPARENT
) - Wie der Kuchen ist
WS_EX_TRANSPARENT
eine Lüge oder zumindest nicht die gesamte Wahrheit - Ich habe
WS_EX_COMPOSITED
verwendet, um mein neues Flicker loszuwerden, aber es führte zu einer schleppenden Reaktion - Wie kann ich
WS_CLIPCHILDREN
verwenden und trotzdem in der Lage sein, eine Kontrolle mit einem transparenten Hintergrund zu zeichnen?
Fensterklassen
- Wofür ist die
HINSTANCE
, für CreateWindow
und RegisterClass
verwendet wird? - Die Verwendung der falschen
HINSTANCE
in RegisterClass
ist wie Identitätsdiebstahl - Wenn die Funktion der
RegisterClass
-Funktion die benutzerdefinierte Hintergrundpinsel besitzt, warum ist dann undicht sie? - Das Ändern einer Fensterklasse betrifft alle Fenster, die zu dieser Klasse gehören
- Was macht
CS_SAVEBITS
? - Was macht der
CS_OWNDC
-Klassenstil? - Was macht der
CS_CLASSDC
-Klassenstil? - Das Ändern des
CS_NOCLOSE
-Stils wirkt sich auf alle Fenster der Klasse aus, nur nicht unbedingt auf merkwürdige Weise - Warum hasst
PrintWindow
CS_PARENTDC
? Weil jeder CS_PARENTDC
hasst! - Warum hasst
PrintWindow
CS_PARENTDC
? Redux - Sicherere Unterklasse
- Privatkurse, Superklasse und globale Unterklasse
- Was macht
RealGetWindowClass
so viel realer als GetClassName
? - Warum nimmt
CreateWindowEx
den Parameter des erweiterten Stils als erster Parameter anstelle seines letzten? - Wann sollte ich
CS_GLOBALCLASS
verwenden? - Wie einzigartig muss der Parameter uidsubClass sein, wenn ich
SetWindowSubclass
aufrufe?
Fenster auf oberster Ebene
Fensterrahmen und Bildunterschrift
- Erhalten Sie ein benutzerdefiniertes Rechtsklickmenü für das Caption-Symbol
- Eine aktive Bildunterschrift zeichnen, auch wenn sie nicht aktiv ist
- Wie unterdrücke ich das vollständige Fenster -Ziehen/die Größe für nur ein Fenster?
- Wie wechsle ich ein Fenster zwischen Normal und Vollbild?
- Wie aktiviere und deaktiviere ich das Minimieren, Maximieren und Schließen von Tasten in meiner Bildunterschrift?
- Erhalten Sie den Standort der Schließknopf in der Titelleiste
- Erhalten Sie den Standort der Schließschaltfläche in der Titelleiste von Windows 2000 oder Windows XP
- Warum sind die Abmessungen eines maximalen Fensters größer als der Monitor?
- Erstellen eines Fensters, das nur in einer Richtung geändert werden kann
- Warum leiten Sie nicht
WM_GETMINMAXINFO
weiter und klemmen die Ergebnisse?
DWM
- Warum erhält mein Programm nicht die
WM_DWMSENDICONICTHUMBNAIL
-Nachricht, wenn ich um eine ikonische Darstellung frage? - Der
MARGINS
-Parameter für die DwmExtendFrameIntoClientArea
-Funktion steuert, wie weit sich der Rahmen in den Clientbereich erstreckt - Wie untersuche ich die Standardanimation, die auftritt, wenn ich ein Fenster verstecke oder zeige?
- Zeigen Sie ein benutzerdefiniertes Miniaturbild für Ihre Bewerbung an (und während Sie in der IT eine benutzerdefinierte Live -Vorschau)
- Wie kann ich feststellen, dass mein Fenster von der Shell vom Bildschirm unterdrückt wurde? ("Fenster Cloaking")
Dialoge
- Warum kann ich mein Dialogfeld nicht erstellen? Rookie -Fehler #1
- Warum kann ich mein Dialogfeld nicht erstellen? Rookie -Fehler #2
- Rückgabewerte aus einer Dialogprozedur
- Eine andere Art von Dialogprozedur
- Eine andere andere Art von Dialogprozedur
- Die Standardantwort auf jedes Dialogfeld lautet "Abbrechen".
- Drehung der Z-Ordnung
- Verwenden der
TAB
, um in Nicht-Dialogs zu navigieren - Verwenden der
TAB
, um in Nicht-Dialogs zu navigieren, Redux - Verhindern, dass das Bearbeiten von Steuertext in einem Dialogfeld automatisch ausgewählt wird
- Diejenigen, die den Dialogmanager nicht verstehen
- Andere Tricks mit
WM_GETDLGCODE
-
GetDialogBaseUnits
ist ein Topf - Warum ist
MapDialogRect
-Mapping -Dialog nicht Rechtecke? - Warum werden Dialogfelder ursprünglich versteckt?
- Was ist der Deal mit der
DS_SHELLFONT
-Flagge? - Warum ist
DS_SHELLFONT = DS_FIXEDSYS | DS_SETFONT
? - So setzen Sie den Fokus in einem Dialogfeld
- Lassen Sie sich niemals auf eine behinderte Kontrolle konzentrieren
- Eine Subtilität bei der Wiederherstellung der vorherigen Fensterposition
- Dinge, die Sie bereits wissen: Wie warte ich, bis mein Dialogfeld angezeigt wird, bevor ich etwas tut?
- Was macht
TranslateAccelerator
? - Wenn ich ein modisches Dialogfeld mit benutzerdefinierten Beschleunigern habe, sollte ich zuerst aufrufen:
IsDialogMessage
oder TranslateAccelerator
- Sanfte Erinnerung: Geben Sie in einem Dialogfeld nicht OK an und stornieren Sie Beschleuniger abbrechen
- Warum sind Beschleuniger für versteckte Steuerelemente noch aktiv?
- Wie kann ich meine Beschleuniger nur dann im Hauptfenster gelten und nicht, wenn der Benutzer einen modischen Dialogfeld verwendet?
- Warum funktioniert die
TAB
nicht an Steuerelementen, die ich als WS_TABSTOP
markiert habe? - Sie können die
WM_USER
-Nachricht in einem Dialogfeld nicht verwenden - Wie kann ich zur Laufzeit ein Dialogfeld von rechts nach links erstellen?
- Wie berechnet der Dialogmanager die durchschnittliche Breite eines Charakters?
Verschachtelte und eingebettete Dialoge
- Wofür ist der
DS_CONTROL
-Stil? - Weitere Hinweise zur Verwendung des
DS_CONTROL
-Stils - Es ist keine gute Idee, mehrere Steuerelemente für ein Dialogfeld dieselbe ID zu geben
- Stellen Sie beim Einbetten eines Dialogs in einen anderen ein
- Wenn der Standard-Pushbutton aufgerufen wird, geht der Aufruf zum Dialog der obersten Ebene
Gemeinsame Dialoge
- Warum wickelt mein
MessageBox
nicht am richtigen Ort ein? - Wie passe ich den Abschnitt "Lieblings -Links" des Dialogfelds Open -Datei an?
- Warum ändert das Dialogfeld "Common Datei" das aktuelle Verzeichnis?
- Sie können den Dialog der gemeinsamen Datei mit Platzhaltern filtern
- Wie zeige ich den Dialogfeld "Find Printers" programmgesteuert an?
- Warum zeigt die Liste der geöffneten Dateien in den Shared Ordnern Snap-In nicht alle meine geöffneten Dateien an?
- Eine häufige Kontrolle über die Zusammenarbeit mit Erweiterungen ist gut überfällig
- Filterung der Ordner, die im Dialogfeld "Durchsuchen zum Ordner" angezeigt werden
- Öffnen des klassischen Ordnerbrowser -Dialogfelds mit einem bestimmten Ordner vorgewählt
- Warum erstellt das Dialogfeld "Common Datei" eine temporäre Datei und löscht sie dann?
- Stellen Sie den Standarddialog mit Farbpickern an
- Wie setze ich das anfängliche Verzeichnis des Dialogfelds Open -Datei auf ein virtuelles Verzeichnis ein?
- Warum wird das letzte Element zuerst mehrere Dateien im Dialogfeld "Datei Öffnen" auswählen?
- Ich habe die Option
OFN_NONETWORKBUTTON
in der OPENFILENAME
-Struktur festgelegt, aber sie hat keinen Einfluss auf das Netzwerkelement im Navigationsbereich - Wie füge ich den Dialogfeld Dialoge für gemeinsame Dateien oder Dateispeichern benutzerdefinierte Steuerelemente hinzu?
- Wie kann ich meinen
FileSavePicker
in demselben Ordner öffnen, der vom FileOpenPicker
oder FolderPicker
ausgewählt wurde? (Win32/COM -Äquivalent am Ende des Posts)
Kontrollnavigation
- Verwenden der
TAB
, um in Nicht-Dialogs zu navigieren - Verwenden der
TAB
, um in Nicht-Dialogs zu navigieren, Redux - Verwalten des UI -Zustands der Beschleuniger und Fokussierungsrechtecke
- Benutzerdefinierte Navigation in Dialogfeldern, Redux
- Dialogfelder geben den Fokus auf das Steuerelement zurück, das sich beim letzten Umschaltungsschalter konzentriert hat. Wie komme ich in diese Aktion für meine eigenen Fenster ein?
- Wie kann ich in meinem Win32-Dialog eine nicht-kreisförmige Registerkarte oder eine andere Art von benutzerdefinierter Bestellung erstellen?
Dialogmanager
- Der Dialogmanager, Teil 1: Aufwärmen
- Der Dialogmanager, Teil 2: Erstellen des Frame -Fensters
- Der Dialogmanager, Teil 3: Erstellen der Steuerelemente
- Der Dialogmanager, Teil 4: Die Dialogschleife
- Der Dialogmanager, Teil 5: Konvertieren eines nicht modalen Dialogfelds in Modal
- Der Dialogmanager, Teil 6: Feinheiten in Nachrichtenschleifen
- Der Dialogmanager, Teil 7: Weitere Feinheiten in Nachrichtenschleifen
- Der Dialogmanager, Teil 8: Benutzerdefinierte Navigation in Dialogfeldern
- Der Dialogmanager, Teil 9: Benutzerdefinierte Beschleuniger in Dialogfeldern
Modalität
- Die richtige Reihenfolge für die Deaktivierung und Aktivierung von Fenstern
- Modalität, Teil 1: UI-Modalität gegen Code-Modalität
- Modalität, Teil 2: Code-Modalität gegen UI-Modalität
- Modalität, Teil 3: Die
WM_QUIT
-Nachricht - Modalität, Teil 4: Die Wichtigkeit, den richtigen Eigentümer für die modale Benutzeroberfläche festzulegen
- Modalität, Teil 5: Stellen Sie den richtigen Eigentümer für die modale Benutzeroberfläche ein
- Modalität, Teil 6: Interaktion mit einem Programm, das modal geworden ist
- Modalität, Teil 7: Eine zeitgesteuerte
MessageBox
, die billige Version - Modalität, Teil 8: Eine zeitgesteuerte
MessageBox
, die bessere Version - Modalität, Teil 9: Setzen Sie den richtigen Eigentümer für die modale Benutzeroberfläche, praktische Prüfung
- Thread -Nachrichten werden von modalen Schleifen gefressen
- Rettung von Threadnachrichten aus modalen Schleifen über Nachrichtenfilter
Immobilienblätter
- Welche anderen Effekte hat
DS_SHELLFONT
auf Eigenschaftsblattseiten? -
PSM_ISDIALOGMESSAGE
sind modeless Eigenschaftsblätter wie IsDialogMessage
zu modischen Dialogfeldern - Sie können die
PROPSHEETPAGE
-Struktur mit Ihren eigenen Bonusdaten erweitern - Die
PSN_SETACTIVE
-Benachrichtigung wird jedes Mal gesendet, wenn Ihre Assistentenseite aktiviert ist - Anhängen zusätzlicher Nutzlast an eine
PROPSHEETPAGE
-Struktur anhängen - Wie übergeben ich eine Reihe von
PROPSHEETPAGE
Strukturen in variabler Größe an Eigenschaftsblatt?
Kontrollen
- Nur weil Sie eine Kontrolle sind, heißt das nicht, dass Sie sich unbedingt in einem Dialogfeld befinden
Animationskontrollen
- Einschränkungen der Shell -Animationskontrolle
- Warum verwendet der Animationskontroll der Version 6 keinen Hintergrund -Thread?
Knöpfe
- Wofür ist der
BS_PUSHLIKE
Button -Stil? (Verwenden Sie nicht, es ist heutzutage vollständig veraltet. Verwenden Sie stattdessen das Kontrollkästchen oder ein Optionsfeld.)
Kombinationsboxen
- Beschleunigen von Elementen zu einem Combobox oder Listbox (
WM_SETREDRAW
) hinzugefügt werden
Steuerelemente bearbeiten
- Was ist mit der
EM_SETHILITE
-Nachricht los? - Verhindern, dass das Bearbeiten von Steuertext in einem Dialogfeld automatisch ausgewählt wird
- Wie unterdrücke ich die
CapsLock
-Warnung auf Passwort bearbeiten Steuerelemente? - Die frühe Geschichte des
ES_NUMBER
-Bearbeitungssteuerstils - Wie erlaube ich negative Zahlen mit dem
ES_NUMBER
-Bearbeitungssteuerstil? - Wie erlaube ich, dass ein Minusschild in meine Bearbeitungssteuerung eingegeben werden kann, aber nur, wenn es der erste Charakter ist?
Listen Sie Ansichten auf
- Positiertes gegen nicht positionierte Listenansichtsansichten
- Anzeigen von Infotips für gefaltete und entfaltete Listansichtelemente
- Computerlistenansicht -Infotips im Hintergrund
- Was ist der Unterschied zwischen
LVM_HITTEST
und LVM_INSERTMARKHITTEST
? - Warum gibt es eine
LVN_ODSTATECHANGED
-Benachrichtigung, wenn es bereits eine vollkommen gute LVN_ITEMCHANGED
gibt? - Erstellen einer Listansicht mit Kontrollkästchen für einige Elemente, aber nicht für andere
- Wie kann ich eine ListView -Spalte programmgesteuert für die Anpassung ihrer Inhalte programmatisch ändern?
- Wie erstelle ich ein deaktiviertes Kontrollkästchen für ein ListView -Element?
- Beschleunigen von Elementen zu einem Combobox oder Listbox (
WM_SETREDRAW
) hinzugefügt werden
Reiche Textsteuerungen
Die Geschichte der Richedit -Kontrolle von Murray Sargent (Der Beitrag ist nur ein (gebrochener) Link zu https://blogs.msdn.microsoft.com/murrays/2006/10/19/some-richedit-history/)- Wie lade ich eine ganze Datei in eine reichhaltige Textsteuerung?
- Wie stecke ich mehr als 32.000 Zeichen in eine reichhaltige Textkontrolle?
- Wie drucke ich den Inhalt einer reichen Textkontrolle aus?
Scrollbars
- Das Scratch -Programm
- Scrollbars, Teil 2
- Scrollbars, Teil 3: Optimierung des Farbzyklus
- Scrollbars, Teil 4: Hinzufügen einer proportionalen Bildlaufleiste
- Wahrscheinlich Teil 5: Tastaturzugriffsgrad für Scrollbars
- Addendum zu Teil 5: Eine Subtilität im Tastaturcode
- Scrollbars Teil 6 - das Rad
- Scrollbars Teil 7 - Integralität
- Scrollbars Teil 8 - Integrale interaktive Größenänderung
- Scrollbars Teil 9 - Aufrechterhaltung der Metapher
- Scrollbars Teil 10 - Auf dem Weg zu einem tieferen Verständnis der
WM_NCCALCSIZE
-Nachricht - Scrollbars Teil 11: Auf dem Weg zu einem noch tieferen Verständnis der
WM_NCCALCSIZE
-Nachricht - Antworten auf Bewegung von Scrollbars Teil 11
- Scrollbars Teil 12:
WM_NCCALCSIZE
auf unsere Scrollbar -Probe anwenden - Scrollbars Redux: Teil 12
- Es gibt zwei Arten von Scrollbars
- Warum wurde
WHEEL_DELTA
als 120 anstelle eines viel bequemeren Wertes wie 100 oder sogar 10 ausgewählt? - Warum setzt das Einstellen des horizontalen Bildlaufleistenbereichs zum ersten Mal auch den vertikalen Bereich und umgekehrt?
- Autoscrolling on Drag, Teil 1: Grundlegende Implementierung
- Autoscrolling on Drag, Teil 2: Warum geht das Scrollen schneller, wenn ich die Maus wackeln?
- Autoscrolling on Drag, Teil 3: Dynamisches autoscroll basierend auf der Mausposition
- Autoscrolling on Drag, Teil 4: Dynamisches Autoscroll basierend auf der Fluchtgeschwindigkeit
- Autoscrolling on Drag, Teil 5: Hinzufügen von Wackel-zu-Scroll, um der Geschwindigkeit zu entkommen
Statische Kontrollen
- Wann löscht die statische Steuerung das darin geladene Bild automatisch und wann ist es in der Verantwortung der Anwendung?
Registerkarte Steuerelemente
- Wie soll ich Steuerelemente in meinem Dialogfeld erstellen, das eine Registerkartensteuerung hat?
- Wie soll ich Kinder der win32 -Registerkarte erstellen?
Symbolleisten
- Warum gibt es sowohl
TBSTYLE_EX_VERTICAL
als auch CCS_VERT
? - Wie erstelle ich eine Symbolleiste, die sich in der Taskleiste befindet?
- Wie erstelle ich eine richtig ausgerichtete Symbolleiste?
- Erstellen von benutzerdefinierten Aufgaben auf einer Sprungliste
Tooltips
- Codierung In-Place-Tooltips
- Verwenden Sie benutzerdefinierte Zeichnen in Tooltips, um die Schriftart anzupassen
- Multiplexen mehrere Tools in einem Tooltip in eine
- TOOLTIP -Text dynamisch generieren
- Warum kann ich kein Tooltip für ein deaktiviertes Fenster anzeigen?
- Überdokumentierende
TTM_RELAYEVENT
und warum es zu einem ein Sekunden lang periodischen Timer führt, so lange der Tooltip sichtbar ist
Trackbars
- Hinzufügen eines
Ctrl
+Pfeilbeschleuniger - Hinzufügen eines
Ctrl
+Pfeilbeschleuniger - Wie kann ich Benutzer daran hindern, die Maus zum Ziehen des Trackbar -Daums in Positionen zu ziehen, die nicht mehrfach von fünf Jahren sind? Teil 1: das Problem neu gestalten
- Wie kann ich Benutzer daran hindern, die Maus zum Ziehen des Trackbar -Daums in Positionen zu ziehen, die nicht mehrfach von fünf Jahren sind? Teil 2: Die Daumenposition stupsen
Baumlistenansichten
- Der Stil
TVS_CHECKBOXES
ist schrullig, was eine höfliche Art ist, zu sagen, dass es verrückt ist - Achten Sie auf die durchgesickerte Bildliste, wenn Sie den Stil
TVS_CHECKBOXES
verwenden - Kontrollkästchen für Baumansicht manuell: Eine einfache Status -Bildliste
- Kontrollkästchen Manuell Erstellen von Baumansicht: Reagieren Sie auf Klicks
- Kontrollkästchen für Baumansicht manuell: Kontrollkästchen zum Thema THEMENED
- Kontrollkästchen für Baumansicht: Eine schmutzige Geschichte
- Kontrollkästchen für Baumansicht: Das Kontrollkästchen erweitert.
Verarbeitung von Nachrichten
- Welche Nachrichtennummern gehören zu wem?
- Die verschiedenen Möglichkeiten, eine Nachricht zu senden
- Nutzerdefinierte Nachrichten übertragen
- Wann kann ein Thread Fenstermeldungen empfangen?
- Was ist der Unterschied zwischen
GetKeyState
und GetAsyncKeyState
? - Thread -Nachrichten werden von modalen Schleifen gefressen
- Rettung von Threadnachrichten aus modalen Schleifen über Nachrichtenfilter
- Die Gefahren der Filterfenstermeldungen
- Sie können die Tastatureingabe nicht mit
PostMessage
simulieren - Meldungen pumpen, während er einen bestimmten Zeitraum wartet
- In der Verfolgung der Nachrichtenwarteschlange
- Nein, wirklich, Sie müssen alle nicht behandelten Nachrichten an
DefWindowProc
weitergeben - Auch wenn Sie Code haben, um eine Nachricht
DefWindowProc
verarbeiten - Wofür wurde
Get/SetMessageExtraInfo
jemals verwendet? - Warum gibt
GetWindowLongPtr
einen Müllwert für 64-Bit-Fenster zurück? -
TrackMouseEvent
-Tracks Mausereignisse in Ihrem Fenster, aber nur, wenn die Ereignisse zu Ihrem Fenster gehören - Vergessen Sie nicht, die Meldungswarteschlange in Ihre Sperrenhierarchie aufzunehmen
- Was passiert mit einer gesendeten Nachricht, wenn
SendMessageTimeout
ihre Auszeit erreicht hat? - Warum kann ich die
WM_COPYDATA
-Nachricht nicht PostMessage
, aber ich kann es mit einer winzigen Auszeit SendMessageTimeout
? - Auch wenn Maus-, Malen- und Timer-Nachrichten auf Anfrage erzeugt werden, ist es dennoch möglich, dass einer in Ihrer Warteschlange landet
- Verpostete Nachrichten werden vor Eingabenachrichten verarbeitet, auch wenn sie später veröffentlicht wurden
- Welche Art von Nachrichten kann ein Fenster nur für Nachricht empfangen?
- Wenn die Prototypen von
DispatchMessageA
und DispatchMessageW
identisch sind, warum haben Sie beides? - Diejenigen, die den Dialogmanager nicht verstehen
- Wie kann ich eine Neuauslegung des Mauszeigers auslösen, nachdem ich einen Teil meines internen Anwendungszustands geändert habe?
- Wie kann ich eine Neuauslegung des Mauszeigers auslösen, nachdem ich einen Teil meines internen Anwendungszustands geändert habe ?, Follow-up
-
GetQueueStatus
und den Warteschlangenstaat
Haken
- Wofür ist die
HINSTANCE
, für SetWindowsHookEx
verwendet wird? - Wie kann ich benachrichtigt werden, wenn sich der Cursor ändert?
- What does the thread parameter to
SetWindowsHookEx
actually mean? - Why does
SetFocus
fail without telling me why?
Specific Messages
Benachrichtigungen
- 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?
Stifte
- 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?
Zugänglichkeit
- 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
?
Aufzählung
- 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
Hülse
- 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
Erinnerung
- 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
Nicht kategorisiert
- 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 fast is it? 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