.NET: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
Zeile 21: Zeile 21:
  
 
'''Call the function with the paramter "C:\"'''
 
'''Call the function with the paramter "C:\"'''
<source lang="powershell>$Kernel32::GetDriveTypeW('C:\')</source>
+
<source lang="powershell">$Kernel32::GetDriveTypeW('C:\')</source>
  
  

Version vom 14. April 2020, 12:56 Uhr

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

Using Add-Type to call the GetDriveTypeW function

$MethodDefinition = @'
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern int GetDriveTypeW(string lpRootPathName);
'@
 
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru

Call the function with the paramter "C:\"

$Kernel32::GetDriveTypeW('C:\')