Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 1.63 KB

platform-invoke-examples.md

File metadata and controls

32 lines (27 loc) · 1.63 KB
title description ms.date dev_langs helpviewer_keywords ms.assetid
Platform Invoke Examples
See a platform invoke example that demonstrates how to define and call the MessageBox function in User32.dll.
03/30/2017
csharp
vb
cpp
examples [.NET Framework], platform invoke
unmanaged functions
COM interop, platform invoke
platform invoke, examples
interoperation with unmanaged code, platform invoke
DLL functions
15926806-f0b7-487e-93a6-4e9367ec689f

Platform Invoke Examples

The following examples demonstrate how to define and call the MessageBox function in User32.dll, passing a simple string as an argument. In the examples, the xref:System.Runtime.InteropServices.DllImportAttribute.CharSet?displayProperty=nameWithType field is set to Auto to let the target platform determine the character width and string marshalling.

[!code-cppConceptual.Interop.PInvoke#1] [!code-csharpConceptual.Interop.PInvoke#1] [!code-vbConceptual.Interop.PInvoke#1]

For additional examples, see Marshalling Data with Platform Invoke.

See also