Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "system" in [All]

wlanapi

.
Summary
Enumerates all of the wireless NICs currently plugged into the system.
.

- The string that is returned is localized (seems to use the system language).

kernel32

.

    rgchFullModulePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

.

[System.String.Intern] is the closest thing, although an atom is different from a string.

.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

.
Summary
Is used to get OSVERSIONINFOEX, you can try the System.Environment.OSVersion class.
.

    Dim si As New SYSTEM_INFO

.

        GetSystemInfo(si)

.

System.Environment.OSVersion is provided in all .Net versions and has the same information.

.

OperatingSystem Class from System namespace has similar properties and methods

7: Beep
.

using System;

.

using System.Runtime.InteropServices;

.

System.Console.Beep

.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

using System;

.

using System.Text;

.

using System.Runtime.InteropServices;

.

        public COLORREF(System.Drawing.Color color)

.

        public System.Drawing.Color GetColor()

.

        return System.Drawing.Color.FromArgb((int)(0x000000FFU & ColorDWORD),

.

        public void SetColor(System.Drawing.Color color)

.

using System.Runtime.InteropServices; // Needed for the DllImport Attribute

.

        throw new System.ComponentModel.Win32Exception(err);

.

    var security = new System.Security.AccessControl.DirectorySecurity();

.

System.IO.Directory.CreateDirectory

.

using System;

.

using System.Runtime.InteropServices;

.

I think that in .NET 2.0 the System.Threading.EventWaitHandle class does the same that the example.

.

    <System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _

.

$DynAssembly = New-Object System.Reflection.AssemblyName("DynamicAssembly")

.

$AssemblyBuilder = $Domain.DefineDynamicAssembly($DynAssembly, [System.Reflection.Emit.AssemblyBuilderAccess]::Run)

.

     [System.Reflection.MethodAttributes] "Public, Static", # Method Attributes

.

$CreateFileDllImport = [System.Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String]))

.

$CreateFileFieldArray = [System.Reflection.FieldInfo[]] @(

.

     [System.Runtime.InteropServices.DllImportAttribute].GetField("EntryPoint"),

.

     [System.Runtime.InteropServices.DllImportAttribute].GetField("PreserveSig"),

.

     [System.Runtime.InteropServices.DllImportAttribute].GetField("SetLastError"),

.

     [System.Runtime.InteropServices.DllImportAttribute].GetField("CallingConvention"),

.

     [System.Runtime.InteropServices.DllImportAttribute].GetField("CharSet")

.

     [System.Runtime.InteropServices.CallingConvention]::Winapi,

.

     [System.Runtime.InteropServices.CharSet]::Auto

.

$CreateFileCustomAttribute = New-Object System.Reflection.Emit.CustomAttributeBuilder(

.

$Kernel32::CreateFile(\\.\PHYSICALDRIVE0, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read, [System.IntPtr]::Zero, [System.IO.FileMode]::Open, [System.UInt32]0x02000000 )

.

      System.IO.FileAccess access,

.

      System.IO.FileShare share,

.

      System.IO.FileMode creationDisposition,

.

$createFile[0]::CreateFileW('\\?\C:\path\to\dir', [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read, [System.IntPtr]::Zero, [System.IO.FileMode]::Open, [System.UInt32]0x02000000, [System.IntPtr]::Zero

.

        AccessSystemSecurity = 0x1000000,   // AccessSystemAcl access type

.

   System           = 0x00000004,

.

Friend Enum EFileAccess As System.Int32

.

     '' AccessSystemAcl access type

.

     ACCESS_SYSTEM_SECURITY = &H1000000

.

     FILE_ATTRIBUTE_SYSTEM = &H4

.

///            using System.Runtime.InteropServices;

.

///            using System.IO;

.

     //Buff = System.Text.Encoding.Unicode.GetBytes(Temp);

.

     Buff = System.Text.Encoding.ASCII.GetBytes(Temp);

.

     Buff = System.Text.Encoding.ASCII.GetBytes(prnCmdCut);

.

using System.IO;

.

using System.Runtime.InteropServices;

.

       if ( (sizeToRead < 1) || (sizeToRead == null) ) throw new System.ArgumentException("Size parameter cannot be null or 0 or less than 0!");

.

    if (dataToWrite == null) throw new System.ArgumentException("dataToWrite parameter cannot be null!");

.

  using System.Runtime.InteropServices;

.

  using System;

.

    public class frmMain : System.Windows.Forms.Form

.
See
System.Threading.Mutex in .NET Framework 1.1
.

        ACCESS_SYSTEM_SECURITY = 0x01000000L

.

using System;

.

using System.IO;

.

using System.Runtime.InteropServices;

.

using System.ComponentModel;

.

using System.Text;

.

    /// and a System.IO.Stream subclass.  Basically, it simplifies the unnecessarily horrific process

.

            System.Threading.Thread.Sleep(dataRead ? 50 : 1000);

.

            System.Threading.Thread.Sleep(1000);

.

[System.Diagnostics.Process.Start]

.
Summary
Creates a symbolic link in the filesystem. Requires Vista or higher. Requires administrator access.
.

[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I1)]

.

new System.ComponentModel.Win32Exception()  // gets last WinAPI error, e.g., File Exists

.

   SecurityAttributes, uint StackSize, System.Threading.ThreadStart StartFunction,

.

Try System.Threading.Thread.Start. It doesn't give you all the control of directly calling CreateThread, (such as specifing the flags), but it will get you a vanilla thread to spin up.

.

    /// The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.

.

    /// The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.

.

using System;

.

using System.Runtime.InteropServices;

.

using System.Diagnostics;

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

    internal const uint DDD_NO_BROADCAST_SYSTEM = 0x00000008;

.

System.IO.File:

.

    ByRef Overlapped As System.Threading.NativeOverlapped) As Boolean

.

If you want x64 proccessor support, you CANNOT use the System.Threading.NativeOverlapped structure as a ref parameter described above. The overlap structure must be allocated in global memory space. See the section "DeviceIoControl w/x64 support":

.

       dwErrorCode.ToString, New System.ComponentModel.Win32Exception(dwErrorCode))

.

using System;

.

using System.Threading;

.

using System.IO;

.

using System.Runtime.InteropServices;

.

    DiskFileSystem        = 0x00000008,

.

    FileSystem            = 0x00000009,

.

    NetworkFileSystem    = 0x00000014,

.

    TapeFileSystem        = 0x00000020,

.

    DfsFileSystem        = 0x00000035,

.

     // FILESYSTEM

.

     FsctlRequestOplockLevel1 = (EFileDevice.FileSystem << 16) | (0 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlRequestOplockLevel2 = (EFileDevice.FileSystem << 16) | (1 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlRequestBatchOplock = (EFileDevice.FileSystem << 16) | (2 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlOplockBreakAcknowledge = (EFileDevice.FileSystem << 16) | (3 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlOpBatchAckClosePending = (EFileDevice.FileSystem << 16) | (4 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlOplockBreakNotify = (EFileDevice.FileSystem << 16) | (5 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlLockVolume = (EFileDevice.FileSystem << 16) | (6 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlUnlockVolume = (EFileDevice.FileSystem << 16) | (7 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlDismountVolume = (EFileDevice.FileSystem << 16) | (8 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlIsVolumeMounted = (EFileDevice.FileSystem << 16) | (10 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlIsPathnameValid = (EFileDevice.FileSystem << 16) | (11 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlMarkVolumeDirty = (EFileDevice.FileSystem << 16) | (12 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlQueryRetrievalPointers = (EFileDevice.FileSystem << 16) | (14 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlGetCompression = (EFileDevice.FileSystem << 16) | (15 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSetCompression = (EFileDevice.FileSystem << 16) | (16 << 2) | EMethod.Buffered | (FileAccess.ReadWrite << 14),

.

     FsctlMarkAsSystemHive = (EFileDevice.FileSystem << 16) | (19 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlOplockBreakAckNo2 = (EFileDevice.FileSystem << 16) | (20 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlInvalidateVolumes = (EFileDevice.FileSystem << 16) | (21 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlQueryFatBpb = (EFileDevice.FileSystem << 16) | (22 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlRequestFilterOplock = (EFileDevice.FileSystem << 16) | (23 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlFileSystemGetStatistics = (EFileDevice.FileSystem << 16) | (24 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetNtfsVolumeData = (EFileDevice.FileSystem << 16) | (25 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetNtfsFileRecord = (EFileDevice.FileSystem << 16) | (26 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetVolumeBitmap = (EFileDevice.FileSystem << 16) | (27 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlGetRetrievalPointers = (EFileDevice.FileSystem << 16) | (28 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlMoveFile = (EFileDevice.FileSystem << 16) | (29 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlIsVolumeDirty = (EFileDevice.FileSystem << 16) | (30 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetHfsInformation = (EFileDevice.FileSystem << 16) | (31 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlAllowExtendedDasdIo = (EFileDevice.FileSystem << 16) | (32 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlReadPropertyData = (EFileDevice.FileSystem << 16) | (33 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlWritePropertyData = (EFileDevice.FileSystem << 16) | (34 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlFindFilesBySid = (EFileDevice.FileSystem << 16) | (35 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlDumpPropertyData = (EFileDevice.FileSystem << 16) | (37 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlSetObjectId = (EFileDevice.FileSystem << 16) | (38 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetObjectId = (EFileDevice.FileSystem << 16) | (39 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlDeleteObjectId = (EFileDevice.FileSystem << 16) | (40 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSetReparsePoint = (EFileDevice.FileSystem << 16) | (41 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlGetReparsePoint = (EFileDevice.FileSystem << 16) | (42 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlDeleteReparsePoint = (EFileDevice.FileSystem << 16) | (43 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlEnumUsnData = (EFileDevice.FileSystem << 16) | (44 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlSecurityIdCheck = (EFileDevice.FileSystem << 16) | (45 << 2) | EMethod.Neither | (FileAccess.Read << 14),

.

     FsctlReadUsnJournal = (EFileDevice.FileSystem << 16) | (46 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlSetObjectIdExtended = (EFileDevice.FileSystem << 16) | (47 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlCreateOrGetObjectId = (EFileDevice.FileSystem << 16) | (48 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSetSparse = (EFileDevice.FileSystem << 16) | (49 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSetZeroData = (EFileDevice.FileSystem << 16) | (50 << 2) | EMethod.Buffered | (FileAccess.Write << 14),

.

     FsctlQueryAllocatedRanges = (EFileDevice.FileSystem << 16) | (51 << 2) | EMethod.Neither | (FileAccess.Read << 14),

.

     FsctlEnableUpgrade = (EFileDevice.FileSystem << 16) | (52 << 2) | EMethod.Buffered | (FileAccess.Write << 14),

.

     FsctlSetEncryption = (EFileDevice.FileSystem << 16) | (53 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlEncryptionFsctlIo = (EFileDevice.FileSystem << 16) | (54 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlWriteRawEncrypted = (EFileDevice.FileSystem << 16) | (55 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlReadRawEncrypted = (EFileDevice.FileSystem << 16) | (56 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlCreateUsnJournal = (EFileDevice.FileSystem << 16) | (57 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlReadFileUsnData = (EFileDevice.FileSystem << 16) | (58 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlWriteUsnCloseRecord = (EFileDevice.FileSystem << 16) | (59 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlExtendVolume = (EFileDevice.FileSystem << 16) | (60 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlQueryUsnJournal = (EFileDevice.FileSystem << 16) | (61 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlDeleteUsnJournal = (EFileDevice.FileSystem << 16) | (62 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlMarkHandle = (EFileDevice.FileSystem << 16) | (63 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSisCopyFile = (EFileDevice.FileSystem << 16) | (64 << 2) | EMethod.Buffered | (0 << 14),

.

     FsctlSisLinkFiles = (EFileDevice.FileSystem << 16) | (65 << 2) | EMethod.Buffered | (FileAccess.ReadWrite << 14),

.

     FsctlHsmMsg = (EFileDevice.FileSystem << 16) | (66 << 2) | EMethod.Buffered | (FileAccess.ReadWrite << 14),

.

     FsctlNssControl = (EFileDevice.FileSystem << 16) | (67 << 2) | EMethod.Buffered | (FileAccess.Write << 14),

.

     FsctlHsmData = (EFileDevice.FileSystem << 16) | (68 << 2) | EMethod.Neither | (FileAccess.ReadWrite << 14),

.

     FsctlRecallFile = (EFileDevice.FileSystem << 16) | (69 << 2) | EMethod.Neither | (0 << 14),

.

     FsctlNssRcontrol = (EFileDevice.FileSystem << 16) | (70 << 2) | EMethod.Buffered | (FileAccess.Read << 14),

.

   Imports System.Runtime.InteropServices

.

   Imports System.Text  

.

   Private Const FILE_ATTRIBUTE_SYSTEM As Short = &H4S

.

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

.

   FileStream f=File.Open(filename,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,System.IO.FileShare.None);

.

Sample and signature code originally used System.Runtime.InteropServices.FILETIME, but this uses ints instead of uints (DWORDs) meaning that this line:

.

    /// The system will raise an exception to indicate a function failure,

.

    /// The system may create additional threads within the application's process, such

.

  using System;

.

  using System.Runtime.InteropServices;

.

      throw new System.NotSupportedException("value is not an ID!");

.
Summary
.

static extern bool EnumSystemCodePages(EnumCodePagesProcDlgt lpCodePageEnumProc,

.

I needed to enumerate the installed code pages on a Windows machine, and wanted to present the possible encoding interpretations to a user via a ComboBox. By using the Win32 API ::EnumSystemCodePages() via PInvoke, and the System.Text.Encoding.GetEncoding() static method, I could get the mapping from the code page to an Encoding instance which returns "pretty" names like 'Japanese (Shift-JIS)'.

.

      if (!EnumSystemCodePages(dlgt, CP_INSTALLED))

.

    Debug.WriteLine(string.Format("EnumSystemCodePages failed with errno = {0}", errno));

.

    private static extern bool EnumSystemCodePages(EnumCodePagesProcDlgt lpCodePageEnumProc, uint dwFlags);

.
Documentation
[EnumSystemCodePages] on MSDN
.

    public static extern bool EnumSystemLocalesEx(EnumLocalesProcExDelegate pEnumProcEx, LOCALETYPE dwFlags, int lParam, IntPtr lpReserved);

.

Declare Function EnumSystemLocalesEx Lib "kernel32.dll" (TODO) As TODO

.

      Private Declare PtrSafe Function EnumSystemLocalesEx Lib "kernel32.dll" ( _

.

      Private Declare Function EnumSystemLocalesEx Lib "kernel32.dll" ( _

.

    using System;

.

    using System.Text;

.

    using System.Globalization;

.

    using System.Runtime.InteropServices;

.

        // Try enumSystemLocalesEx

.

        Console.WriteLine("\nEnumSystemLocalesEx()");

.

        DoEnumSystemLocalesEx(LOCALETYPE.LOCALE_ALL);

.

    static void DoEnumSystemLocalesEx(LOCALETYPE dwFlags)

.

        if (!LocaleFunctions.EnumSystemLocalesEx(enumCallback, dwFlags, 0, (IntPtr)0))

.

    public static extern bool EnumSystemLocalesEx(EnumLocalesProcExDelegate pEnumProcEx, LOCALETYPE dwFlags, int lParam, IntPtr lpReserved);

.
Documentation
[EnumSystemLocalesEx] on MSDN
.

    public static extern bool EnumSystemLocalesEx(EnumLocalesProcExDelegate pEnumProcEx, LOCALETYPE dwFlags, int lParam, IntPtr lpReserved);

.

Declare Function EnumSystemLocalesEx Lib "kernel32.dll" (TODO) As TODO

.

using System;

.

using System.Text;

.

using System.Globalization;

.

using System.Runtime.InteropServices;

.

    // Try enumSystemLocalesEx

.

    Console.WriteLine("\nEnumSystemLocalesEx()");

.

    DoEnumSystemLocalesEx(LOCALETYPE.LOCALE_ALL);

.

    static void DoEnumSystemLocalesEx(LOCALETYPE dwFlags)

.

    if (!LocaleFunctions.EnumSystemLocalesEx(enumCallback, dwFlags, 0, (IntPtr)0))

.

    public static extern bool EnumSystemLocalesEx(EnumLocalesProcExDelegate pEnumProcEx, LOCALETYPE dwFlags, int lParam, IntPtr lpReserved);

.
Documentation
[EnumSystemLocalesEx] on MSDN
.

http://www.hanselman.com/blog/PerformanceOfSystemIOPortsVersusUnmanagedSerialPortCode.aspx

.

static void System.Environment.Exit(int exitCode);

.

                                <MarshalAs(UnmanagedType.LPTStr)>lpDst As System.Text.StringBuilder, _

.

System.Environment.ExpandEnvironmentVariables I think

.

   out SYSTEMTIME lpLocalFileTime);

.

FileTimeToLocalFileTime converts a time from UTC time (also known as Greenwich Mean Time) to "local time" (inside the computer's selected time zone). The source and target times are stored in FILETIME structures. The function returns 1 if successful, or 0 if an error occurs.FileTimeToLocalFileTime Converts a UTC file time to a local file time. System.DateTime.ToFileTime FileTimeToLocalFileTime Converts a UTC file time to a local file time. System.DateTime.ToLocalTime

.
Summary
.

static extern bool FileTimeToSystemTime([In] ref FILETIME lpFileTime,

.

   out SYSTEMTIME lpSystemTime);

.

   Friend Shared Function FileTimeToSystemTime( _

.

                        <Out()> ByRef lpSystemTime As SYSTEMTIME) _

.

FileTime and SystemTime.

.

By setting the SetLastError property to true, a System.ComponentModel.Win32Exception will generated if the function fails.

.

    public static DateTime FileTimeToSystemTime(string hexTS) {

.

        fileTime.dwHighDateTime = int.Parse(highDT, System.Globalization.NumberStyles.HexNumber);

.

        fileTime.dwLowDateTime = int.Parse(lowDT, System.Globalization.NumberStyles.HexNumber);

.
Documentation
[FileTimeToSystemTime] on MSDN
.

[System.String.IsInterned] is the closest thing, although an atom is different from a string.

.

System.IO.FileSystemWatcher

.

System.IO.FileSystemWatcher

.

System.IO.FileSystemWatcher

.

  Declare Function FindFirstVolumeW Lib "kernel32.dll" (ByVal lpszVolumeName As System.Text.StringBuilder, ByVal cchBufferLength As UInteger) As IntPtr

.

            throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());

.

System.IO.FileSystemWatcher

.

    if (error != 0) throw new System.ComponentModel.Win32Exception(error);

.

    const uint FORMAT_MESSAGE_FROM_SYSTEM    = 0x00001000;

.

        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

.

                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, (uint)Marshal.GetLastWin32Error(), 0, msgBuilder, 101, null);

.

This functionality is also given by System.ComponentModel.Win32Exception:

.

Yet the sample might still be useful for messages not provided by the system.

.

    FROM_SYSTEM = 0x00001000,

.

       int size = FormatMessage(FORMAT_MESSAGE.ALLOCATE_BUFFER | FORMAT_MESSAGE.FROM_SYSTEM | FORMAT_MESSAGE.IGNORE_INSERTS,

.

    const uint FORMAT_MESSAGE_FROM_SYSTEM    = 0x00001000;

.

        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

.

            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, (uint)Marshal.GetLastWin32Error(), 0, msgBuilder, 101, null);

.

    <System.Runtime.InteropServices.DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Unicode)>

.

    <System.Runtime.InteropServices.DllImport("Kernel32.dll", SetLastError:=True)>

.

    FORMAT_MESSAGE_FROM_SYSTEM = &H1000

.

    Dim dwChars As Integer = FormatMessage(Format_Message.FORMAT_MESSAGE_ALLOCATE_BUFFER Or Format_Message.FORMAT_MESSAGE_FROM_SYSTEM Or Format_Message.FORMAT_MESSAGE_IGNORE_INSERTS,

.

    FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,

.

        FormatMessageFlags flags = FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM;

.

        FormatMessageFlags flags = FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM |

.

This functionality is also given by System.ComponentModel.Win32Exception:

.

Yet the sample might still be useful for messages not provided by the system.

.

                #in the windows system32 directory by bypassing filesystem redirection using "sysnative",

.

private static extern System.IntPtr GetCommandLine();

.

The original GetCommandLine function returns a pointer to a buffer allocated and owned by the operating system. When marshaling strings as return types, the interop marshaler assumes it must free the memory that the original LPTSTR type pointed to by the function. To prevent the marshaler from automatically reclaiming this memory, the managed GetCommandLine prototype returns an IntPtr type instead of a string. The Marshal.PtrToStringAuto method copies the unmanaged LPSTR type to a managed string object, widening the character format, if required.

.

System.IntPtr ptr = GetCommandLine();

.

Imports System.IO

.

      using System;

.

      using System.Text;

.

      using System.Runtime.InteropServices;

.

    $str_builder_obj = [System.Text.StringBuilder]::new($size)

.

System.Console.InputEncoding.CodePage

.

    TextWriterTraceListener ConsoleListener = new TextWriterTraceListener(System.Console.Out);

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

using System.Runtime.InteropServices;

.

using System;

.

  System.AppDomain.GetCurrentThreadId() (This is deprecated in .NET 2.0)

.

static extern int GetDateFormat(uint locale, uint dwFlags, ref SystemTime date, string format, StringBuilder sb, int sbSize);

.

SYSTEMTIME in Win32 is different then DateTime in CLR. This structure may represent SYSTEMTIME in CLR world:

.

    private struct SystemTime {

.

    using System;

.

    using System.Text;

.

    using System.Globalization;

.

    using System.Runtime.InteropServices;

.

    static extern int GetDateFormat(int locale, uint dwFlags, ref SystemTime sysTime,

.

    private struct SystemTime {

.

        public SystemTime(DateTime dateTime) {

.

        SystemTime st = new SystemTime(dt);

.

    throw new System.ComponentModel.Win32Exception();

.

Starting in v2.0 (Whidbey) of the .NET Framework, this is exposed through the System.Io.DriveInfo class.

.

    throw new System.ComponentModel.Win32Exception();

.

Starting in v2.0 (Whidbey) of the .NET Framework, this is exposed through the System.Io.DriveInfo class.

.

using System.Runtime.InteropServices;

.

using System.IO;

.

System.IO.[DriveInfo].[DriveType]

.

Public Shared Function GetExitCodeProcess(ByVal hProcess As IntPtr, ByRef lpExitCode As System.UInt32) As Boolean

.

            throw new System.Runtime.InteropServices.ExternalException(" GetExitCodeProcess Error " + lastError, lastError);

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: