Desktop Functions: Smart Device Functions:
|
GetWindowsDirectory (kernel32)
C# Signature:
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)] VB.NET Signature
<DllImport("kernel32.dll", SetLastError:=true, EntryPoint:="GetWindowsDirectoryW", CharSet:=CharSet.Unicode)> _ VB Signature
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _ User-Defined Types:None. Notes:Q. For the above VB DllImport declaration, Visual Studio's Code Analysis throws error 'CA2101: Specify marshaling for P/Invoke string arguments'. Should the marshalling not be: <MarshalAs(UnmanagedType.LPWStr)> Otherwise lpBuffer will be converted to Ansi and then passed to a Unicode API method. Q. For the above VB DllImport declaration, Visual Studio Code Analysis throws error 'CA2101: Specify marshaling for P/Invoke string arguments'. Should the marshalling not be: <MarshalAs(UnmanagedType.LPWStr)> ? Otherwise lpBuffer will be converted to Ansi and then passed to a Unicode API method. Tips & Tricks:Please add some! Here are two ways to get the Windows path
Private Sub test() VB Sample Code:
As SDim WinDir tring = Space(255) VB.NET Sample Code:
Shared Function wins() As String C# Sample Code:
const int MaxPathLength = 255; C# Sample Code (Alternative):
static string wins() Alternative Managed API:Environment.GetEnvironmentVariable("windir"); Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|