C# Class NanoByte.Common.Native.WindowsUtils

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

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat bool

AttachConsole() public static méthode

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

BroadcastMessage() public static méthode

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.
Résultat void

CreateHardlink() public static méthode

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.
Résultat void

CreateSymlink() public static méthode

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 ).
Résultat void

MoveFileOnReboot() public static méthode

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.
Résultat void

RegisterApplicationRestart() public static méthode

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!
Résultat void

RegisterWindowMessage() public static méthode

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.
Résultat int

SetCurrentProcessAppID() public static méthode

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.
Résultat void

UnregisterApplicationRestart() public static méthode

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

WriteAllBytes() public static méthode

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.
Résultat void