namespace Vanara.PInvoke;
public static partial class WinSCard
{
/// A return code for SCard functions.
///
[StructLayout(LayoutKind.Sequential)]
public struct SCARD_RET : IErrorProvider, IEquatable
{
private readonly uint value;
/// Initializes a new instance of the struct with an error value.
/// The error value.
public SCARD_RET(uint i) => value = i;
/// Performs an explicit conversion from to .
/// The value.
/// The result of the conversion.
public static explicit operator uint(SCARD_RET value) => value.value;
/// Performs an explicit conversion from to .
/// The value.
/// The result of the conversion.
public static implicit operator SCARD_RET(uint value) => new(value);
/// Implements the operator !=.
/// The error left.
/// The error right.
/// The result of the operator.
public static bool operator !=(SCARD_RET errLeft, SCARD_RET errRight) => errLeft.value != errRight.value;
/// Implements the operator !=.
/// The error left.
/// The error right.
/// The result of the operator.
public static bool operator !=(SCARD_RET errLeft, uint errRight) => errLeft.value != errRight;
/// Implements the operator ==.
/// The error left.
/// The error right.
/// The result of the operator.
public static bool operator ==(SCARD_RET errLeft, SCARD_RET errRight) => errLeft.value == errRight.value;
/// Implements the operator ==.
/// The error left.
/// The error right.
/// The result of the operator.
public static bool operator ==(SCARD_RET errLeft, uint errRight) => errLeft.value == errRight;
///
/// The client attempted a smart card operation in a remote session, such as a client session running on a terminal server, and the
/// operating system in use does not support smart card redirection.
///
public const uint ERROR_BROKEN_PIPE = 0x00000109;
/// An error occurred in setting the smart card file object pointer.
public const uint SCARD_E_BAD_SEEK = 0x80100029;
/// The action was canceled by an SCardCancel request.
public const uint SCARD_E_CANCELLED = 0x80100002;
/// The system could not dispose of the media in the requested manner.
public const uint SCARD_E_CANT_DISPOSE = 0x8010000E;
/// The smart card does not meet minimal requirements for support.
public const uint SCARD_E_CARD_UNSUPPORTED = 0x8010001C;
/// The requested certificate could not be obtained.
public const uint SCARD_E_CERTIFICATE_UNAVAILABLE = 0x8010002D;
/// A communications error with the smart card has been detected.
public const uint SCARD_E_COMM_DATA_LOST = 0x8010002F;
/// The specified directory does not exist in the smart card.
public const uint SCARD_E_DIR_NOT_FOUND = 0x80100023;
/// The reader driver did not produce a unique reader name.
public const uint SCARD_E_DUPLICATE_READER = 0x8010001B;
/// The specified file does not exist in the smart card.
public const uint SCARD_E_FILE_NOT_FOUND = 0x80100024;
/// The requested order of object creation is not supported.
public const uint SCARD_E_ICC_CREATEORDER = 0x80100021;
/// No primary provider can be found for the smart card.
public const uint SCARD_E_ICC_INSTALLATION = 0x80100020;
/// The data buffer for returned data is too small for the returned data.
public const uint SCARD_E_INSUFFICIENT_BUFFER = 0x80100008;
/// An ATR string obtained from the registry is not a valid ATR string.
public const uint SCARD_E_INVALID_ATR = 0x80100015;
/// The supplied PIN is incorrect.
public const uint SCARD_E_INVALID_CHV = 0x8010002A;
/// The supplied handle was not valid.
public const uint SCARD_E_INVALID_HANDLE = 0x80100003;
/// One or more of the supplied parameters could not be properly interpreted.
public const uint SCARD_E_INVALID_PARAMETER = 0x80100004;
/// Registry startup information is missing or not valid.
public const uint SCARD_E_INVALID_TARGET = 0x80100005;
/// One or more of the supplied parameter values could not be properly interpreted.
public const uint SCARD_E_INVALID_VALUE = 0x80100011;
/// Access is denied to the file.
public const uint SCARD_E_NO_ACCESS = 0x80100027;
/// The supplied path does not represent a smart card directory.
public const uint SCARD_E_NO_DIR = 0x80100025;
/// The supplied path does not represent a smart card file.
public const uint SCARD_E_NO_FILE = 0x80100026;
/// The requested key container does not exist on the smart card.
public const uint SCARD_E_NO_KEY_CONTAINER = 0x80100030;
/// Not enough memory available to complete this command.
public const uint SCARD_E_NO_MEMORY = 0x80100006;
///
/// The smart card PIN cannot be cached.
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This error code is not available.
///
public const uint SCARD_E_NO_PIN_CACHE = 0x80100033;
/// No smart card reader is available.
public const uint SCARD_E_NO_READERS_AVAILABLE = 0x8010002E;
/// The smart card resource manager is not running.
public const uint SCARD_E_NO_SERVICE = 0x8010001D;
/// The operation requires a smart card, but no smart card is currently in the device.
public const uint SCARD_E_NO_SMARTCARD = 0x8010000C;
/// The requested certificate does not exist.
public const uint SCARD_E_NO_SUCH_CERTIFICATE = 0x8010002C;
/// The reader or card is not ready to accept commands.
public const uint SCARD_E_NOT_READY = 0x80100010;
/// An attempt was made to end a nonexistent transaction.
public const uint SCARD_E_NOT_TRANSACTED = 0x80100016;
/// The PCI receive buffer was too small.
public const uint SCARD_E_PCI_TOO_SMALL = 0x80100019;
///
/// The smart card PIN cache has expired.
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This error code is not available.
///
public const uint SCARD_E_PIN_CACHE_EXPIRED = 0x80100032;
/// The requested protocols are incompatible with the protocol currently in use with the card.
public const uint SCARD_E_PROTO_MISMATCH = 0x8010000F;
///
/// The smart card is read-only and cannot be written to.
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This error code is not available.
///
public const uint SCARD_E_READ_ONLY_CARD = 0x80100034;
/// The specified reader is not currently available for use.
public const uint SCARD_E_READER_UNAVAILABLE = 0x80100017;
/// The reader driver does not meet minimal requirements for support.
public const uint SCARD_E_READER_UNSUPPORTED = 0x8010001A;
/// The smart card resource manager is too busy to complete this operation.
public const uint SCARD_E_SERVER_TOO_BUSY = 0x80100031;
/// The smart card resource manager has shut down.
public const uint SCARD_E_SERVICE_STOPPED = 0x8010001E;
/// The smart card cannot be accessed because of other outstanding connections.
public const uint SCARD_E_SHARING_VIOLATION = 0x8010000B;
/// The action was canceled by the system, presumably to log off or shut down.
public const uint SCARD_E_SYSTEM_CANCELLED = 0x80100012;
/// The user-specified time-out value has expired.
public const uint SCARD_E_TIMEOUT = 0x8010000A;
/// An unexpected card error has occurred.
public const uint SCARD_E_UNEXPECTED = 0x8010001F;
/// The specified smart card name is not recognized.
public const uint SCARD_E_UNKNOWN_CARD = 0x8010000D;
/// The specified reader name is not recognized.
public const uint SCARD_E_UNKNOWN_READER = 0x80100009;
/// An unrecognized error code was returned.
public const uint SCARD_E_UNKNOWN_RES_MNG = 0x8010002B;
/// This smart card does not support the requested feature.
public const uint SCARD_E_UNSUPPORTED_FEATURE = 0x80100022;
/// An attempt was made to write more data than would fit in the target object.
public const uint SCARD_E_WRITE_TOO_MANY = 0x80100028;
/// An internal communications error has been detected.
public const uint SCARD_F_COMM_ERROR = 0x80100013;
/// An internal consistency check failed.
public const uint SCARD_F_INTERNAL_ERROR = 0x80100001;
/// An internal error has been detected, but the source is unknown.
public const uint SCARD_F_UNKNOWN_ERROR = 0x80100014;
/// An internal consistency timer has expired.
public const uint SCARD_F_WAITED_TOO_LONG = 0x80100007;
/// The operation has been aborted to allow the server application to exit.
public const uint SCARD_P_SHUTDOWN = 0x80100018;
/// No error was encountered.
public const uint SCARD_S_SUCCESS = 0;
/// The requested item could not be found in the cache.
public const uint SCARD_W_CACHE_ITEM_NOT_FOUND = 0x80100070;
/// The requested cache item is too old and was deleted from the cache.
public const uint SCARD_W_CACHE_ITEM_STALE = 0x80100071;
/// The new cache item exceeds the maximum per-item size defined for the cache.
public const uint SCARD_W_CACHE_ITEM_TOO_BIG = 0x80100072;
/// The action was canceled by the user.
public const uint SCARD_W_CANCELLED_BY_USER = 0x8010006E;
/// No PIN was presented to the smart card.
public const uint SCARD_W_CARD_NOT_AUTHENTICATED = 0x8010006F;
/// The card cannot be accessed because the maximum number of PIN entry attempts has been reached.
public const uint SCARD_W_CHV_BLOCKED = 0x8010006C;
/// The end of the smart card file has been reached.
public const uint SCARD_W_EOF = 0x8010006D;
/// The smart card has been removed, so further communication is not possible.
public const uint SCARD_W_REMOVED_CARD = 0x80100069;
/// The smart card was reset.
public const uint SCARD_W_RESET_CARD = 0x80100068;
/// Access was denied because of a security violation.
public const uint SCARD_W_SECURITY_VIOLATION = 0x8010006A;
/// Power has been removed from the smart card, so that further communication is not possible.
public const uint SCARD_W_UNPOWERED_CARD = 0x80100067;
/// The smart card is not responding to a reset.
public const uint SCARD_W_UNRESPONSIVE_CARD = 0x80100066;
/// The reader cannot communicate with the card, due to ATR string configuration conflicts.
public const uint SCARD_W_UNSUPPORTED_CARD = 0x80100065;
/// The card cannot be accessed because the wrong PIN was presented.
public const uint SCARD_W_WRONG_CHV = 0x8010006B;
///
public bool Failed => value != SCARD_S_SUCCESS;
///
public bool Succeeded => value == SCARD_S_SUCCESS;
///
public Exception GetException(string message = null) => ToHRESULT().GetException();
///
public void ThrowIfFailed(string message = null)
{ if (Failed) throw GetException(message); }
///
public HRESULT ToHRESULT() => unchecked((int)value);
///
public override bool Equals(object obj) => obj is SCARD_RET rET&&Equals(rET);
///
public bool Equals(SCARD_RET other) => value==other.value;
///
public override int GetHashCode() => -1584136870+value.GetHashCode();
}
}