C# Class NanoByte.Common.Native.WindowsUtils

Provides helper methods and API calls specific to the Windows platform.
Mostrar archivo Open project: nano-byte/common Class Usage Examples

Public Methods

Method Description
AreHardlinked ( [ path1, [ path2 ) : bool

Determines whether to files are hardlinked.

AttachConsole ( ) : bool

Tries to attach to a command-line console owned by the parent process.

BroadcastMessage ( int messageID ) : void

Sends a message of a specific type to all windows in the current session.

CreateHardlink ( [ sourcePath, [ targetPath ) : void

Creates a hard link between two files.

Only available on Windows 2000 or newer.

CreateSymlink ( [ sourcePath, [ targetPath ) : void

Creates a symbolic link for a file or directory.

MoveFileOnReboot ( [ sourcePath, [ destinationPath ) : void

Moves a file on the next reboot of the OS. Replaces existing files.

Useful for replacing in-use files.

RegisterApplicationRestart ( [ arguments ) : void

Registers the current application for automatic restart after updates or crashes.

RegisterWindowMessage ( [ message ) : int

Registers a new message type that can be sent to windows.

SetCurrentProcessAppID ( string appID ) : void

Sets the current process' explicit application user model ID.

The application ID is used to group related windows in the taskbar.

UnregisterApplicationRestart ( ) : void

Unregisters the current application for automatic restart after updates or crashes.

WriteAllBytes ( [ path, [ data ) : void

Writes the entire contents of a byte array to a file using the Win32 API. Existing files with the same name are overwritten.

This method works like File.WriteAllBytes, but bypasses .NET's file path validation logic.

Private Methods

Method Description
BuildException ( int error ) : Exception

Builds a suitable Exception for a given Win32Exception.NativeErrorCode.

GetFileIndex ( [ path ) : ulong
GetNetFxDirectory ( [ version ) : string
NotifyAssocChanged ( ) : void
NotifyEnvironmentChanged ( ) : void
ReadAllBytes ( [ path ) : byte[]
SplitArgs ( [ commandLine ) : string[]

Method Details

AreHardlinked() public static method

Determines whether to files are hardlinked.
There was an IO problem checking the files. You have insufficient rights to check the files. Checking the files failed. This method is called on a platform other than Windows NT.
public static AreHardlinked ( [ path1, [ path2 ) : bool
path1 [ The path of the first file.
path2 [ The path of the second file.
return bool

AttachConsole() public static method

Tries to attach to a command-line console owned by the parent process.
public static AttachConsole ( ) : bool
return bool

BroadcastMessage() public static method

Sends a message of a specific type to all windows in the current session.
public static BroadcastMessage ( int messageID ) : void
messageID int A unique ID number used to identify the message type session-wide.
return void

CreateHardlink() public static method

Creates a hard link between two files.
Only available on Windows 2000 or newer.
There was an IO problem creating the hard link. You have insufficient rights to create the hard link. The hard link creation failed. This method is called on a platform other than Windows NT.
public static CreateHardlink ( [ sourcePath, [ targetPath ) : void
sourcePath [ The path of the link to create.
targetPath [ The absolute path of the existing file to point to.
return void

CreateSymlink() public static method

Creates a symbolic link for a file or directory.
There was an IO problem creating the symlink. You have insufficient rights to create the symbolic link. The symbolic link creation failed. This method is called on a platform other than Windows NT 6.0 (Vista) or newer.
public static CreateSymlink ( [ sourcePath, [ targetPath ) : void
sourcePath [ The path of the link to create.
targetPath [ The path of the existing file or directory to point to (relative to ).
return void

MoveFileOnReboot() public static method

Moves a file on the next reboot of the OS. Replaces existing files.
Useful for replacing in-use files.
public static MoveFileOnReboot ( [ sourcePath, [ destinationPath ) : void
sourcePath [ The source path to move the file from.
destinationPath [ The destination path to move the file to. null to delete the file instead of moving it.
return void

RegisterApplicationRestart() public static method

Registers the current application for automatic restart after updates or crashes.
is too long.
public static RegisterApplicationRestart ( [ arguments ) : void
arguments [ The command-line arguments to pass to the application on restart. Must not be empty!
return void

RegisterWindowMessage() public static method

Registers a new message type that can be sent to windows.
public static RegisterWindowMessage ( [ message ) : int
message [ A unique string used to identify the message type session-wide.
return int

SetCurrentProcessAppID() public static method

Sets the current process' explicit application user model ID.
The application ID is used to group related windows in the taskbar.
public static SetCurrentProcessAppID ( string appID ) : void
appID string The application ID to set.
return void

UnregisterApplicationRestart() public static method

Unregisters the current application for automatic restart after updates or crashes.
public static UnregisterApplicationRestart ( ) : void
return void

WriteAllBytes() public static method

Writes the entire contents of a byte array to a file using the Win32 API. Existing files with the same name are overwritten.
This method works like File.WriteAllBytes, but bypasses .NET's file path validation logic.
There was an IO problem writing the file. Write access to the file was denied. There was a problem writing the file. This method is called on a platform other than Windows.
public static WriteAllBytes ( [ path, [ data ) : void
path [ The path of the file to write to.
data [ The data to write to the file.
return void