Werbung

Herkunft

Kurzinformation

Creates C# code to access a C function

Syntax

<# .Synopsis Creates C# code to access a C function .Description Creates C# code to access a C function .Example Add-PInvoke -Library User32.dll -Signature GetSystemMetrics(uint Metric) .Parameter Library A C Library containing code to invoke .Parameter Signature The C# signature of the external method .Parameter OutputText If Set, retuns the source code for the pinvoke method. If not, compiles the type. #> param( [Parameter(Mandatory=$true, HelpMessage="The C Library Containing the Function, i.e. User32")] [String] $Library, [Parameter(Mandatory=$true, HelpMessage="The Signature of the Method, i.e. int GetSystemMetrics(int Metric")] [String] $Signature, [Switch] $OutputText ) process { if ($Library -notlike "*.dll*") { $Library+=".dll" } if ($signature -notlike "*;") { $Signature+=";" } if ($signature -notlike "public static extern*") { $signature = "public static extern $signature" } $MemberDefinition = "[DllImport(`"$Library`")] $Signature" if (-not $OutputText) { Add-Type -PassThru -Name "PInvoke$(Get-Random)" ` -MemberDefinition $MemberDefinition } else { $MemberDefinition } }

Beschreibung

Creates C# code to access a C function

Links

Liste aller Commandlets Mehr über die Windows PowerShell

Bücher zur PowerShell

Buchcover Windows PowerShell 5.0 - Das Praxishandbuch (1. Auflage 2016/5. Auflage Gesamtreihe) Windows PowerShell 5.0 - Das Praxishandbuch (1. Auflage 2016/5. Auflage Gesamtreihe)
Autoren: Dr. Holger Schwichtenberg
erschienen 2016, 996 Seiten, 49,99 €
ISBN: 3446446435
Bestellung: Amazon.de oder im Buchhandel über ISBN 3446446435

Schulungen/Seminare

Offene Seminare zur PowerShell
In-House-Seminare zur PowerShell