C# Класс Abstractions.WindowsApi.pInvokes

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CloseHandle ( IntPtr handle ) : bool
CreateUserProfileDir ( IntPtr hToken, string username ) : string

calls API CreateProfile an empty string on error a null string on already exists a string on success

DeleteProfile ( System.Security.Principal.SecurityIdentifier sid ) : bool
DisconnectNetworkDrive ( string remoteUNC ) : System.Boolean

disconnecting an UNC share

DomainMember ( string domain ) : bool

query if the domain is part of a domain tree in which the local computer is a member of

GetCredentials ( string caption, string message ) : NetworkCredential
GetFreeShareSpace ( string share ) : long[]

Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread. based on http://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx

GetInteractiveUserList ( ) : List
GetMachineDomainMembership ( ) : string

get local machine domain membership as NETBIOS name

GetMachineDomainMembershipEX ( ) : string

get local machine domain membership as DNS name

GetOrSetUserProfileDir ( string username, string domain, string password ) : string

get or create user profile directory only if the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) an empty or null string means error

GetRegistryLocation ( structenums location ) : RegistryKey

get RegistryKey from structenums.RegistryLocation

GetSessionContext ( ) : List>.Dictionary

returns a Dictionary of SessionID Keys and a List of usernames based on context in which a program is running. a program running as administrator will add administrator to the list

GetSessionContext ( int sessionID ) : List

return username based on context in which a program is running. a program running as administrator will add administrator to the list session ID -1 retuns all sessions instead of a specific one

GetSessionContextParser ( int sessionID, Dictionary contextALL ) : List

return username based on context in which a program is running. a program running as administrator will add administrator to the list session ID -1 retuns all sessions instead of a specific one

GetSessionId ( ) : int
GetUserDomain ( int sessionId ) : string
GetUserName ( int sessionId ) : string
GetUserProfileDir ( IntPtr hToken ) : string

returns userprofile based on GetUserProfileDirectory only if the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) empty string means error

GetUserProfilePath ( IntPtr hToken ) : string

returns userprofile based on SHGetFolderPath only if the profile realy exists and the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) empty string means error

GetUserToken ( string username, string domain, string password ) : IntPtr

Create a handle to the user token make sure to close the handle!!!

IsSessionLoggedOFF ( int session ) : bool
LastError ( ) : string

returns GetLastWin32Error as string

LastError ( int error ) : string

returns GetLastWin32Error as string

LogoffSession ( int sessionId ) : bool
MapNetworkDrive ( string remoteUNC, string username, string password ) : Boolean

connect to a remote computer based on http://social.msdn.microsoft.com/Forums/et-EE/netfxbcl/thread/58159e0e-aa45-4d46-a128-596c3d23ff5c

MapNetworkDrive ( string remoteUNC, string username, string password, bool promptUser ) : Boolean

connect to a remote computer based on http://social.msdn.microsoft.com/Forums/et-EE/netfxbcl/thread/58159e0e-aa45-4d46-a128-596c3d23ff5c

MapNetworkDrive ( string unc, string drive, string user, string password ) : int

Map a network drive.

RegistryCloseKey ( UIntPtr hKey ) : Boolean
RegistryCopyKey ( UIntPtr hKey_src, string SubKey, UIntPtr hKey_dst ) : Boolean
RegistryCreateKey ( structenums RootKey, string SubKey ) : UIntPtr
RegistryDeleteTree ( structenums RootKey, string SubKey ) : Boolean
RegistryLoad ( structenums where, string name, string file ) : Boolean

load a regfile at hklm or hku

RegistryOpenKey ( structenums RootKey, string SubKey ) : UIntPtr
RegistryUnLoad ( structenums where, string name ) : Boolean

unload regfile from regkey

SendMessageToUser ( int sessionID, string title, string message ) : Boolean

send a messagebox to a session

SetPreshutdownTimeout ( SafeHandle handle, structenums &myServiceStatus ) : bool
SetServiceStopped ( IntPtr handle, structenums &myServiceStatus ) : bool
ShutdownPending ( IntPtr handle, structenums &myServiceStatus, TimeSpan wait ) : bool
StartProcessInSession ( int sessionId, string cmdLine ) : Process
StartProcessInSessionWait ( int sessionId, string cmdLine ) : bool
StartProcessWithToken ( IntPtr token, string cmdLine ) : Process
StartUserProcessInSession ( int sessionId, string cmdLine ) : bool
StartUserProcessInSessionWait ( int sessionId, string cmdLine ) : bool
UserADD ( string username, string password, string comment ) : Boolean

add user to the local system based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD

UserChangePassword ( string domainname, string username, string oldpassword, string newpassword ) : string
UserDel ( string username ) : Boolean

delete a local user based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD

UserExists ( string username ) : Boolean

return true if a local user exists

UserExists ( string username, string domain ) : Boolean

return true if a local user exists

UserGet ( string username, string domain, structenums &userinfo4 ) : Boolean

returns local user settings as a ref of an USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD

UserGet ( string username, structenums &userinfo4 ) : Boolean

returns local user settings as a ref of an USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD

UserMod ( string username, structenums userInfo4 ) : Boolean

modify local user settings based on a USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD

ValidateCredentials ( string username, string password ) : bool

Attempts to validate the user's credentials for a local account using a pInvoke to LogonUser.

ValidateCredentials ( string username, string domain, string password ) : bool

Attempts to validate the user's credentials using a pInvoke to LogonUser.

ValidateUser ( string username, string domain, string password ) : bool

Attempts to validate the user's credentials using a pInvoke to LogonUser but ignores password change response.

VersionsInfo ( ) : structenums.OSVERSIONINFOW

get the real windows version http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe

WTSQueryUserToken ( int sessionId ) : IntPtr
WTSRegister ( IntPtr handle ) : bool
WTSUnRegister ( IntPtr handle ) : bool

Приватные методы

Метод Описание
GetDomainInfo ( string domain ) : pInvokes.SafeNativeMethods.DOMAIN_CONTROLLER_INFO
LogonUser ( string username, string domain, string password ) : int
RegistryLoadSetPrivilege ( ) : Boolean

Описание методов

CloseHandle() публичный статический Метод

public static CloseHandle ( IntPtr handle ) : bool
handle System.IntPtr
Результат bool

CreateUserProfileDir() публичный статический Метод

calls API CreateProfile an empty string on error a null string on already exists a string on success
public static CreateUserProfileDir ( IntPtr hToken, string username ) : string
hToken System.IntPtr
username string
Результат string

DeleteProfile() публичный статический Метод

public static DeleteProfile ( System.Security.Principal.SecurityIdentifier sid ) : bool
sid System.Security.Principal.SecurityIdentifier
Результат bool

DisconnectNetworkDrive() публичный статический Метод

disconnecting an UNC share
public static DisconnectNetworkDrive ( string remoteUNC ) : System.Boolean
remoteUNC string
Результат System.Boolean

DomainMember() публичный статический Метод

query if the domain is part of a domain tree in which the local computer is a member of
public static DomainMember ( string domain ) : bool
domain string
Результат bool

GetCredentials() публичный статический Метод

public static GetCredentials ( string caption, string message ) : NetworkCredential
caption string
message string
Результат System.Net.NetworkCredential

GetFreeShareSpace() публичный статический Метод

Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread. based on http://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
public static GetFreeShareSpace ( string share ) : long[]
share string
Результат long[]

GetInteractiveUserList() публичный статический Метод

public static GetInteractiveUserList ( ) : List
Результат List

GetMachineDomainMembership() публичный статический Метод

get local machine domain membership as NETBIOS name
public static GetMachineDomainMembership ( ) : string
Результат string

GetMachineDomainMembershipEX() публичный статический Метод

get local machine domain membership as DNS name
public static GetMachineDomainMembershipEX ( ) : string
Результат string

GetOrSetUserProfileDir() публичный статический Метод

get or create user profile directory only if the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) an empty or null string means error
public static GetOrSetUserProfileDir ( string username, string domain, string password ) : string
username string
domain string
password string
Результат string

GetRegistryLocation() публичный статический Метод

get RegistryKey from structenums.RegistryLocation
public static GetRegistryLocation ( structenums location ) : RegistryKey
location structenums
Результат Microsoft.Win32.RegistryKey

GetSessionContext() публичный статический Метод

returns a Dictionary of SessionID Keys and a List of usernames based on context in which a program is running. a program running as administrator will add administrator to the list
public static GetSessionContext ( ) : List>.Dictionary
Результат List>.Dictionary

GetSessionContext() публичный статический Метод

return username based on context in which a program is running. a program running as administrator will add administrator to the list session ID -1 retuns all sessions instead of a specific one
public static GetSessionContext ( int sessionID ) : List
sessionID int the seesion ID or -1 for all sessions
Результат List

GetSessionContextParser() публичный статический Метод

return username based on context in which a program is running. a program running as administrator will add administrator to the list session ID -1 retuns all sessions instead of a specific one
public static GetSessionContextParser ( int sessionID, Dictionary contextALL ) : List
sessionID int the seesion ID or -1 for all sessions
contextALL Dictionary a GetSessionContext() Directory
Результат List

GetSessionId() публичный статический Метод

public static GetSessionId ( ) : int
Результат int

GetUserDomain() публичный статический Метод

public static GetUserDomain ( int sessionId ) : string
sessionId int
Результат string

GetUserName() публичный статический Метод

public static GetUserName ( int sessionId ) : string
sessionId int
Результат string

GetUserProfileDir() публичный статический Метод

returns userprofile based on GetUserProfileDirectory only if the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) empty string means error
public static GetUserProfileDir ( IntPtr hToken ) : string
hToken IntPtr
Результат string

GetUserProfilePath() публичный статический Метод

returns userprofile based on SHGetFolderPath only if the profile realy exists and the ProfileList regkey is not of SID.bak (Abstractions.User.FixProfileList) empty string means error
public static GetUserProfilePath ( IntPtr hToken ) : string
hToken IntPtr
Результат string

GetUserToken() публичный статический Метод

Create a handle to the user token make sure to close the handle!!!
public static GetUserToken ( string username, string domain, string password ) : IntPtr
username string
domain string
password string
Результат IntPtr

IsSessionLoggedOFF() публичный статический Метод

public static IsSessionLoggedOFF ( int session ) : bool
session int
Результат bool

LastError() публичный статический Метод

returns GetLastWin32Error as string
public static LastError ( ) : string
Результат string

LastError() публичный статический Метод

returns GetLastWin32Error as string
public static LastError ( int error ) : string
error int
Результат string

LogoffSession() публичный статический Метод

public static LogoffSession ( int sessionId ) : bool
sessionId int
Результат bool

MapNetworkDrive() публичный статический Метод

connect to a remote computer based on http://social.msdn.microsoft.com/Forums/et-EE/netfxbcl/thread/58159e0e-aa45-4d46-a128-596c3d23ff5c
public static MapNetworkDrive ( string remoteUNC, string username, string password ) : Boolean
remoteUNC string
username string better use the domainname\username format
password string
Результат Boolean

MapNetworkDrive() публичный статический Метод

connect to a remote computer based on http://social.msdn.microsoft.com/Forums/et-EE/netfxbcl/thread/58159e0e-aa45-4d46-a128-596c3d23ff5c
public static MapNetworkDrive ( string remoteUNC, string username, string password, bool promptUser ) : Boolean
remoteUNC string
username string better use the domainname\username format
password string
promptUser bool true to for a promt, if needed
Результат Boolean

MapNetworkDrive() публичный статический Метод

Map a network drive.
public static MapNetworkDrive ( string unc, string drive, string user, string password ) : int
unc string The full UNC path.
drive string The drive letter (e.g. "Z:", "X:", etc.)
user string The username, null if you want the current user.
password string The password, null to use the default password.
Результат int

RegistryCloseKey() публичный статический Метод

public static RegistryCloseKey ( UIntPtr hKey ) : Boolean
hKey UIntPtr
Результат Boolean

RegistryCopyKey() публичный статический Метод

public static RegistryCopyKey ( UIntPtr hKey_src, string SubKey, UIntPtr hKey_dst ) : Boolean
hKey_src UIntPtr
SubKey string
hKey_dst UIntPtr
Результат Boolean

RegistryCreateKey() публичный статический Метод

public static RegistryCreateKey ( structenums RootKey, string SubKey ) : UIntPtr
RootKey structenums
SubKey string
Результат UIntPtr

RegistryDeleteTree() публичный статический Метод

public static RegistryDeleteTree ( structenums RootKey, string SubKey ) : Boolean
RootKey structenums
SubKey string
Результат Boolean

RegistryLoad() публичный статический Метод

load a regfile at hklm or hku
public static RegistryLoad ( structenums where, string name, string file ) : Boolean
where structenums hklm or hku
name string The name of the key to be created under hKey. This subkey is where the registration information from the file will be loaded
file string
Результат Boolean

RegistryOpenKey() публичный статический Метод

public static RegistryOpenKey ( structenums RootKey, string SubKey ) : UIntPtr
RootKey structenums
SubKey string
Результат UIntPtr

RegistryUnLoad() публичный статический Метод

unload regfile from regkey
public static RegistryUnLoad ( structenums where, string name ) : Boolean
where structenums hklm or hku
name string
Результат Boolean

SendMessageToUser() публичный статический Метод

send a messagebox to a session
public static SendMessageToUser ( int sessionID, string title, string message ) : Boolean
sessionID int
title string
message string
Результат Boolean

SetPreshutdownTimeout() публичный статический Метод

public static SetPreshutdownTimeout ( SafeHandle handle, structenums &myServiceStatus ) : bool
handle SafeHandle
myServiceStatus structenums
Результат bool

SetServiceStopped() публичный статический Метод

public static SetServiceStopped ( IntPtr handle, structenums &myServiceStatus ) : bool
handle IntPtr
myServiceStatus structenums
Результат bool

ShutdownPending() публичный статический Метод

public static ShutdownPending ( IntPtr handle, structenums &myServiceStatus, TimeSpan wait ) : bool
handle IntPtr
myServiceStatus structenums
wait TimeSpan
Результат bool

StartProcessInSession() публичный статический Метод

public static StartProcessInSession ( int sessionId, string cmdLine ) : Process
sessionId int
cmdLine string
Результат System.Diagnostics.Process

StartProcessInSessionWait() публичный статический Метод

public static StartProcessInSessionWait ( int sessionId, string cmdLine ) : bool
sessionId int
cmdLine string
Результат bool

StartProcessWithToken() публичный статический Метод

public static StartProcessWithToken ( IntPtr token, string cmdLine ) : Process
token IntPtr
cmdLine string
Результат System.Diagnostics.Process

StartUserProcessInSession() публичный статический Метод

public static StartUserProcessInSession ( int sessionId, string cmdLine ) : bool
sessionId int
cmdLine string
Результат bool

StartUserProcessInSessionWait() публичный статический Метод

public static StartUserProcessInSessionWait ( int sessionId, string cmdLine ) : bool
sessionId int
cmdLine string
Результат bool

UserADD() публичный статический Метод

add user to the local system based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD
public static UserADD ( string username, string password, string comment ) : Boolean
username string
password string
comment string
Результат Boolean

UserChangePassword() публичный статический Метод

public static UserChangePassword ( string domainname, string username, string oldpassword, string newpassword ) : string
domainname string
username string
oldpassword string
newpassword string
Результат string

UserDel() публичный статический Метод

delete a local user based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD
public static UserDel ( string username ) : Boolean
username string
Результат Boolean

UserExists() публичный статический Метод

return true if a local user exists
public static UserExists ( string username ) : Boolean
username string
Результат Boolean

UserExists() публичный статический Метод

return true if a local user exists
public static UserExists ( string username, string domain ) : Boolean
username string
domain string
Результат Boolean

UserGet() публичный статический Метод

returns local user settings as a ref of an USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD
public static UserGet ( string username, string domain, structenums &userinfo4 ) : Boolean
username string
domain string
userinfo4 structenums a ref of an USER_INFO_4 struct
Результат Boolean

UserGet() публичный статический Метод

returns local user settings as a ref of an USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD
public static UserGet ( string username, structenums &userinfo4 ) : Boolean
username string
userinfo4 structenums a ref of an USER_INFO_4 struct
Результат Boolean

UserMod() публичный статический Метод

modify local user settings based on a USER_INFO_4 struct based on http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/B70B79D9-971F-4D6F-8462-97FC126DE0AD
public static UserMod ( string username, structenums userInfo4 ) : Boolean
username string
userInfo4 structenums
Результат Boolean

ValidateCredentials() публичный статический Метод

Attempts to validate the user's credentials for a local account using a pInvoke to LogonUser.
public static ValidateCredentials ( string username, string password ) : bool
username string The username
password string The password
Результат bool

ValidateCredentials() публичный статический Метод

Attempts to validate the user's credentials using a pInvoke to LogonUser.
public static ValidateCredentials ( string username, string domain, string password ) : bool
username string The username
domain string The domain
password string The password
Результат bool

ValidateUser() публичный статический Метод

Attempts to validate the user's credentials using a pInvoke to LogonUser but ignores password change response.
public static ValidateUser ( string username, string domain, string password ) : bool
username string The username
domain string The domain
password string The password
Результат bool

VersionsInfo() публичный статический Метод

get the real windows version http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
public static VersionsInfo ( ) : structenums.OSVERSIONINFOW
Результат structenums.OSVERSIONINFOW

WTSQueryUserToken() публичный статический Метод

public static WTSQueryUserToken ( int sessionId ) : IntPtr
sessionId int
Результат IntPtr

WTSRegister() публичный статический Метод

public static WTSRegister ( IntPtr handle ) : bool
handle IntPtr
Результат bool

WTSUnRegister() публичный статический Метод

public static WTSUnRegister ( IntPtr handle ) : bool
handle IntPtr
Результат bool