//these probably should not be added#include <shldisp.h>//shell IDispatch interfaces#include <scrnsave.h>//screen saver#include <dbghelp.h>//debug help library#include <imagehlp.h>//many the same as dbghelp.h. Includes wintrust.h -> wincrypt.h which is not welcome.#include <setupapi.h>//obsolete#include <mapi.h>//only for MS Outlook. Can instead use Outlook COM.#include <snmp.h>//can instead download a SNMP .NET library#include Sspi.h //authentication. Includes Security.h. Use .NET classes.//these would be included if no WIN32_LEAN_AND_MEAN#include <winefs.h>//encrypted file system. .NET can encrypt/decrypt a file,but maybe this also can be useful.#include <winspool.h>//printer API. Big. Use System.Drawing.Printing namespace. See also System.Printing namespace.#include <wincrypt.h>//cryptography. Large. Use System.Security.Cryptography namespace.#endif

// Don't add this file to your project. Copy-paste only declarations that you need.// Not all declarations can be compiled without editing.// For example, cannot declare some struct pointer (use IntPtr instead, or in struct replace non-blittable types with IntPtr etc), cannot use undefined struct pointer/ref/out (use IntPtr instead).// Not all declarations are correct, usually because declarations in Windows SDK files from which they have been automatically converted lack some info.// For example, some function parameters that should be 'out' or '[Out]' or '[In]' or array now are just 'ref', because SDK declarations didn't have proper in/out annotations. Also for this reason some parameters that should be 'string' now are 'StringBuilder'.// You may want to create overloads where parameters can be of more than one type.// You may want to add 'SetLastError=true' to DllImport attribute parameters.// Some declarations contain pointers and therefore can be used only in 'unsafe' context, in some cases with 'fixed'. Or you can replace pointers to IntPtr.// These declarations are for Windows 10. Some Windows API are different or missing on other Windows versions.// In some cases need to use different declarations in 32-bit and 64-bit process. This file contains everything that is not different, + 64-bit versions, + 32-bit versions with name suffix ""__32"".

//this is probably the most popular Windows API function, but .NET does not have a wrapper function or class that works with any window
[DllImport("user32.dll", EntryPoint = "SendMessageW")]
public static extern LPARAM SendMessage(Wnd hWnd, uint Msg, LPARAM wParam, LPARAM lParam);

Thanks a lot for a thorough explanation.
I could compile and run it both as C# project and QM script.
Without your clarification and sample I have no clue how to get started on using this API stuff.
It really convenient to use C++ API in C# now.

;Finds a Windows API declaration in Api.cs.;How to use:;;;In your C# editor type a Windows API name, move the mouse over it and run this macro.;;;Or move the mouse over a Windows API name anywhere, for example in API documentation.;;;To run this macro you can use a hotkey trigger; default is Ctrl+D.;;;The macro shows a dialog with the API name, its C# declaration (empty if not found) and several options.;;;In the dialog review the declaration, maybe change options, and click OK.;;;If you start this macro while it is already running, it replaces text in the dialog.;;;Also you can edit text in the dialog Name field to search for a new name.;How it works:;;;Double-clicks to select word from mouse, and gets the word through the clipboard.;;;Finds the declaration in Api.cs file and shows it in dialog together with options.;;;Api.cs file full path must be specified in the dialog.;;;The macro can copy the declaration to the clipboard or/and run a macro that for example can insert the declaration in a C# file. Example - function SDK_insert_declaration.

;Inserts decl in file csFile, before line //insert new declaration here;You can specify this function name in dialog "Windows API for C#" (function SDK_fine_declaration shows it) field "Run macro".;If the file is open in Visual Studio, it nicely updates editor text, even with Undo, if the file is saved. Tested with Visual Studio 2015.