Simon Mourier's Avatar
Simon Mourier's blog (1346 answers on StackOverflow) about Microsoft technologies C#, C/C++, .NET, WinRT, WinUI, COM, Interop, DirectX, Direct2D, Windows, ...
  • 🔎︎ Search
  • Categories
  • Archives
  • About Me
  • c#
  • registry
  • winapi

How to import ZwDeleteKey in C#

Jan 10, 2022 See the question and my original answer on StackOverflow

Official documentation for ZwDeleteKey does mention "NtosKrnl.exe" being the "DLL", but this is wrong, the import definition should be like this instead (plus there's no string involved, the entry point is not ambiguous and the function doesn't set last error):

[DllImport("ntdll")]
private static extern int ZwDeleteKey(SafeRegistryHandle hKey);  
  • SmoBlog © 2010-2025 Simon Mourier. All rights reserved.
  • Privacy & Terms