.NET: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 5: | Zeile 5: | ||
=== Messagebox with Button === | === Messagebox with Button === | ||
<source lang="powershell">[System.Windows.Forms.MessageBox]::Show("Text","Überschrift",[System.Windows.Forms.MessageBoxButtons]::OK) </source> | <source lang="powershell">[System.Windows.Forms.MessageBox]::Show("Text","Überschrift",[System.Windows.Forms.MessageBoxButtons]::OK) </source> | ||
+ | |||
+ | |||
+ | |||
+ | == Call a Win32 API function with powershell == | ||
+ | === Example: GetDriveTypeW === | ||
+ | <source lang="powershell"> | ||
+ | $MethodDefinition = @' | ||
+ | [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] | ||
+ | public static extern int GetDriveTypeW(string lpRootPathName); | ||
+ | '@ | ||
+ | |||
+ | $Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru | ||
+ | </source> | ||
+ | |||
+ | |||
+ | |||
[[Kategorie:PowerShell]] | [[Kategorie:PowerShell]] |
Version vom 14. April 2020, 12:54 Uhr
Inhaltsverzeichnis
Get all actual loaded .NET Assemblies (per PowerShell Session)
[System.AppDomain]::CurrentDomain.GetAssemblies()
Messagebox with Button
[System.Windows.Forms.MessageBox]::Show("Text","Überschrift",[System.Windows.Forms.MessageBoxButtons]::OK)
Call a Win32 API function with powershell
Example: GetDriveTypeW
$MethodDefinition = @' [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] public static extern int GetDriveTypeW(string lpRootPathName); '@ $Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru