C# Class Opc.Ua.Com.ComUtils

Exposes WIN32 and COM API functions.
Afficher le fichier Open project: OPCFoundation/UA-.NET

Private Properties

Свойство Type Description
CloseHandle bool
CoCreateInstanceEx void
CoGetClassObject void
CoInitializeSecurity int
CoQueryProxyBlanket int
CoSetProxyBlanket int
ConvertCase char
DuplicateToken bool
FormatMessageW int
GetSystemDefaultLangID int
GetUserDefaultLangID int
IsLocalHost bool
LogonUser bool
NetApiBufferFree int
NetServerEnum int
VariantChangeTypeEx int
VariantClear void
VariantInit void
VariantToObjectArray System.Array

Méthodes publiques

Méthode Description
ChangeTypeForCOM ( object source, VarEnum sourceType, VarEnum targetType, object &target ) : int

Converts a value to the specified type using COM conversion rules.

ChangeTypeForCOM ( object source, VarEnum targetType, object &target ) : int

Converts a value to the specified type using COM conversion rules.

CompareLocales ( int localeId, string locale, bool ignoreRegion ) : bool

Compares a string locale to a WIN32 localeId

CreateComException ( Exception e ) : Exception

Converts an exception to an exception that returns a COM error code.

CreateComException ( Exception e, int errorId ) : Exception

Converts an exception to an exception that returns a COM error code.

CreateComException ( int errorId ) : Exception

Converts an exception to an exception that returns a COM error code.

CreateComException ( string message, int errorId ) : Exception

Creates a COM exception.

CreateException ( Exception e, string function ) : Exception

Creates an error message for a failed COM function call.

CreateInstance ( System.Guid clsid, string hostName, UserIdentity identity ) : object

Creates an instance of a COM server using the specified license key.

CreateInstance1 ( System.Guid clsid, string hostName, UserIdentity identity ) : object

Creates an instance of a COM server.

CreateInstance2 ( System.Guid clsid, string hostName, UserIdentity identity ) : object

Creates an instance of a COM server using the specified license key.

CreateInstanceWithLicenseKey ( System.Guid clsid, string hostName, UserIdentity identity, string licenseKey ) : object

Creates an instance of a COM server using the specified license key.

EnumComputers ( ) : string[]

Enumerates computers on the local network.

GetAccessRights ( byte accessLevel ) : int

Converts the UA access level to DA access rights.

GetDataTypeId ( short input ) : NodeId

Converts the VARTYPE to a UA Data Type ID.

GetDataTypeId ( short input, bool &isArray ) : NodeId

Converts the VARTYPE to a UA Data Type ID.

GetDateTime ( IntPtr pFiletime ) : System.DateTime

Unmarshals a WIN32 FILETIME from a pointer.

GetDateTime ( System filetime ) : System.DateTime

Unmarshals a WIN32 FILETIME.

GetDateTimes ( IntPtr &pArray, int size, bool deallocate ) : System.DateTime[]

Unmarshals an array of WIN32 FILETIMEs as DateTimes.

GetErrorCode ( Exception e, int defaultCode ) : int

Gets the error code for the exception.

This method ignores the exception but makes it possible to keep track of ignored exceptions.

GetErrorText ( Type type, int error ) : string

Returns the symbolic name for the specified error.

GetFILETIME ( System.DateTime datetime ) : System.Runtime.InteropServices.ComTypes.FILETIME

Marshals a DateTime as a WIN32 FILETIME.

GetFILETIMEs ( System.DateTime datetimes ) : IntPtr

Marshals an array of DateTimes into an unmanaged array of FILETIMEs

GetFILETIMEs ( IntPtr &pArray, int size ) : System.Runtime.InteropServices.ComTypes.FILETIME[]

Unmarshals an array of FILETIMEs

GetGUIDs ( IntPtr &pInput, int size, bool deallocate ) : System.Guid[]

Unmarshals an array of WIN32 GUIDs as Guid.

GetHdaAggregateId ( uint aggregateId ) : NodeId

Converts a HDA Aggregate ID to a UA aggregate ID

GetHdaAggregateId ( NodeId nodeId ) : uint

Converts a UA Aggregate ID to a HDA aggregate ID

GetHdaQualityCode ( uint quality ) : StatusCode

Converts a HDA quality code to a StatusCode.

GetHdaQualityCode ( StatusCode input ) : uint

Converts a UA status code to a HDA quality code.

GetInt16s ( short input ) : IntPtr

Allocates and marshals an array of 16 bit integers.

GetInt16s ( IntPtr &pArray, int size, bool deallocate ) : short[]

Unmarshals and frees a array of 16 bit integers.

GetInt32s ( int input ) : IntPtr

Allocates and marshals an array of 32 bit integers.

GetInt32s ( IntPtr &pArray, int size, bool deallocate ) : int[]

Unmarshals and frees an array of 32 bit integers.

GetLocale ( string input ) : int

Converts a Locale string to a LCID.

GetLocale ( int input ) : string

Converts a LCID to a Locale string.

GetPrincipalFromUserIdentity ( UserIdentity user ) : WindowsPrincipal

Returns the WindowsIdentity associated with a UserIdentity.

GetQualityCode ( short quality ) : StatusCode

Converts a DA quality code to a status code.

GetQualityCode ( StatusCode input ) : short

Converts a UA status code to a DA quality code.

GetStatusCodes ( IntPtr &pArray, int size, bool deallocate ) : int[]

Unmarshals and frees an array of HRESULTs.

GetSystemMessage ( int error, int localeId ) : string

Retrieves the system message text for the specified error.

GetSystemType ( short input ) : Type

Converts the VARTYPE to a SystemType

GetUInt32s ( IntPtr &pArray, int size, bool deallocate ) : int[]

Unmarshals and frees an array of 32 bit integers.

GetUnicodeStrings ( string values ) : IntPtr

Marshals an array of strings into a unmanaged memory buffer

GetUnicodeStrings ( IntPtr &pArray, int size, bool deallocate ) : string[]

Unmarshals and frees a array of unicode strings.

GetVARIANT ( Variant source ) : object

Converts an object into a value that can be marshalled to a VARIANT.

GetVARIANT ( object source ) : object

Converts an object into a value that can be marshalled to a VARIANT.

GetVARIANT ( object source, TypeInfo typeInfo ) : object

Converts an object into a value that can be marshalled to a VARIANT.

GetVARIANTs ( object values, bool preprocess ) : IntPtr

Marshals an array objects into an unmanaged array of VARIANTs.

GetVARIANTs ( IntPtr &pArray, int size, bool deallocate ) : object[]

Unmarshals an array of VARIANTs as objects.

GetValueRank ( short input ) : int

Converts the VARTYPE to a UA ValueRank.

GetVarType ( System type ) : VarEnum

Converts the system type to a VARTYPE.

GetVarType ( TypeInfo typeInfo ) : VarEnum

Converts the TypeInfo to a VARTYPE.

GetVarType ( object input ) : VarEnum

Returns the VARTYPE for the value.

InitializeSecurity ( ) : void

Initializes COM security.

IsRpcError ( Exception e ) : bool

Checks if the error is an RPC error.

IsUnknownError ( Exception e ) : bool

Checks if the error for the exception is one of the recognized errors.

IsValidComType ( object input ) : bool

Returns true is the object is a valid COM type.

Match ( string target, string pattern, bool caseSensitive ) : bool

Tests if the specified string matches the specified pattern.

ProcessComValue ( object value ) : object

Converts a COM value to something that UA clients can deal with.

ReleaseServer ( object server ) : void

Releases the server if it is a true COM server.

SetProxySecurity ( object server, IntPtr pAuthInfo ) : void

Sets the security settings for the proxy.

SetProxySecurity ( object server, UserIdentity user ) : void

Sets the security settings for the proxy.

TraceComError ( Exception e, string format ) : void

Reports an unexpected exception during a COM operation.

Private Methods

Méthode Description
CloseHandle ( IntPtr handle ) : bool
CoCreateInstanceEx ( System.Guid &clsid, [ punkOuter, uint dwClsCtx, [ pServerInfo, uint dwCount, [ pResults ) : void
CoGetClassObject ( [ clsid, uint dwClsContext, [ pServerInfo, [ riid, [ ppv ) : void
CoInitializeSecurity ( IntPtr pSecDesc, int cAuthSvc, SOLE_AUTHENTICATION_SERVICE asAuthSvc, IntPtr pReserved1, uint dwAuthnLevel, uint dwImpLevel, IntPtr pAuthList, uint dwCapabilities, IntPtr pReserved3 ) : int
CoQueryProxyBlanket ( [ pProxy, uint &pAuthnSvc, uint &pAuthzSvc, [ pServerPrincName, uint &pAuthnLevel, uint &pImpLevel, IntPtr &pAuthInfo, uint &pCapabilities ) : int
CoSetProxyBlanket ( [ pProxy, uint pAuthnSvc, uint pAuthzSvc, IntPtr pServerPrincName, uint pAuthnLevel, uint pImpLevel, IntPtr pAuthInfo, uint pCapabilities ) : int
ConvertCase ( char c, bool caseSensitive ) : char
DuplicateToken ( IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, IntPtr &DuplicateTokenHandle ) : bool
FormatMessageW ( int dwFlags, IntPtr lpSource, int dwMessageId, int dwLanguageId, IntPtr lpBuffer, int nSize, IntPtr Arguments ) : int
GetSystemDefaultLangID ( ) : int
GetUserDefaultLangID ( ) : int
IsLocalHost ( string hostName ) : bool

Determines if the host is the local host.

LogonUser ( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, IntPtr &phToken ) : bool
NetApiBufferFree ( IntPtr buffer ) : int
NetServerEnum ( IntPtr servername, uint level, IntPtr &bufptr, int prefmaxlen, int &entriesread, int &totalentries, uint servertype, IntPtr domain, IntPtr resume_handle ) : int
VariantChangeTypeEx ( IntPtr pvargDest, IntPtr pvarSrc, int lcid, ushort wFlags, short vt ) : int
VariantClear ( IntPtr pVariant ) : void
VariantInit ( IntPtr pVariant ) : void
VariantToObjectArray ( Array input ) : Array

Converts a Variant array to an Object array.

Method Details

ChangeTypeForCOM() public static méthode

Converts a value to the specified type using COM conversion rules.
public static ChangeTypeForCOM ( object source, VarEnum sourceType, VarEnum targetType, object &target ) : int
source object
sourceType VarEnum
targetType VarEnum
target object
Résultat int

ChangeTypeForCOM() public static méthode

Converts a value to the specified type using COM conversion rules.
public static ChangeTypeForCOM ( object source, VarEnum targetType, object &target ) : int
source object
targetType VarEnum
target object
Résultat int

CompareLocales() public static méthode

Compares a string locale to a WIN32 localeId
public static CompareLocales ( int localeId, string locale, bool ignoreRegion ) : bool
localeId int
locale string
ignoreRegion bool
Résultat bool

CreateComException() public static méthode

Converts an exception to an exception that returns a COM error code.
public static CreateComException ( Exception e ) : Exception
e System.Exception
Résultat System.Exception

CreateComException() public static méthode

Converts an exception to an exception that returns a COM error code.
public static CreateComException ( Exception e, int errorId ) : Exception
e System.Exception
errorId int
Résultat System.Exception

CreateComException() public static méthode

Converts an exception to an exception that returns a COM error code.
public static CreateComException ( int errorId ) : Exception
errorId int
Résultat System.Exception

CreateComException() public static méthode

Creates a COM exception.
public static CreateComException ( string message, int errorId ) : Exception
message string
errorId int
Résultat System.Exception

CreateException() public static méthode

Creates an error message for a failed COM function call.
public static CreateException ( Exception e, string function ) : Exception
e System.Exception
function string
Résultat System.Exception

CreateInstance() public static méthode

Creates an instance of a COM server using the specified license key.
public static CreateInstance ( System.Guid clsid, string hostName, UserIdentity identity ) : object
clsid System.Guid
hostName string
identity UserIdentity
Résultat object

CreateInstance1() public static méthode

Creates an instance of a COM server.
public static CreateInstance1 ( System.Guid clsid, string hostName, UserIdentity identity ) : object
clsid System.Guid
hostName string
identity UserIdentity
Résultat object

CreateInstance2() public static méthode

Creates an instance of a COM server using the specified license key.
public static CreateInstance2 ( System.Guid clsid, string hostName, UserIdentity identity ) : object
clsid System.Guid
hostName string
identity UserIdentity
Résultat object

CreateInstanceWithLicenseKey() public static méthode

Creates an instance of a COM server using the specified license key.
public static CreateInstanceWithLicenseKey ( System.Guid clsid, string hostName, UserIdentity identity, string licenseKey ) : object
clsid System.Guid
hostName string
identity UserIdentity
licenseKey string
Résultat object

EnumComputers() public static méthode

Enumerates computers on the local network.
public static EnumComputers ( ) : string[]
Résultat string[]

GetAccessRights() public static méthode

Converts the UA access level to DA access rights.
public static GetAccessRights ( byte accessLevel ) : int
accessLevel byte
Résultat int

GetDataTypeId() public static méthode

Converts the VARTYPE to a UA Data Type ID.
public static GetDataTypeId ( short input ) : NodeId
input short
Résultat NodeId

GetDataTypeId() public static méthode

Converts the VARTYPE to a UA Data Type ID.
public static GetDataTypeId ( short input, bool &isArray ) : NodeId
input short
isArray bool
Résultat NodeId

GetDateTime() public static méthode

Unmarshals a WIN32 FILETIME from a pointer.
public static GetDateTime ( IntPtr pFiletime ) : System.DateTime
pFiletime System.IntPtr A pointer to a FILETIME structure.
Résultat System.DateTime

GetDateTime() public static méthode

Unmarshals a WIN32 FILETIME.
public static GetDateTime ( System filetime ) : System.DateTime
filetime System
Résultat System.DateTime

GetDateTimes() public static méthode

Unmarshals an array of WIN32 FILETIMEs as DateTimes.
public static GetDateTimes ( IntPtr &pArray, int size, bool deallocate ) : System.DateTime[]
pArray System.IntPtr
size int
deallocate bool
Résultat System.DateTime[]

GetErrorCode() public static méthode

Gets the error code for the exception.
This method ignores the exception but makes it possible to keep track of ignored exceptions.
public static GetErrorCode ( Exception e, int defaultCode ) : int
e System.Exception The exception.
defaultCode int The default code.
Résultat int

GetErrorText() public static méthode

Returns the symbolic name for the specified error.
public static GetErrorText ( Type type, int error ) : string
type System.Type
error int
Résultat string

GetFILETIME() public static méthode

Marshals a DateTime as a WIN32 FILETIME.
public static GetFILETIME ( System.DateTime datetime ) : System.Runtime.InteropServices.ComTypes.FILETIME
datetime System.DateTime The DateTime object to marshal
Résultat System.Runtime.InteropServices.ComTypes.FILETIME

GetFILETIMEs() public static méthode

Marshals an array of DateTimes into an unmanaged array of FILETIMEs
public static GetFILETIMEs ( System.DateTime datetimes ) : IntPtr
datetimes System.DateTime The array of DateTimes to marshal
Résultat System.IntPtr

GetFILETIMEs() public static méthode

Unmarshals an array of FILETIMEs
public static GetFILETIMEs ( IntPtr &pArray, int size ) : System.Runtime.InteropServices.ComTypes.FILETIME[]
pArray System.IntPtr
size int
Résultat System.Runtime.InteropServices.ComTypes.FILETIME[]

GetGUIDs() public static méthode

Unmarshals an array of WIN32 GUIDs as Guid.
public static GetGUIDs ( IntPtr &pInput, int size, bool deallocate ) : System.Guid[]
pInput System.IntPtr
size int
deallocate bool
Résultat System.Guid[]

GetHdaAggregateId() public static méthode

Converts a HDA Aggregate ID to a UA aggregate ID
public static GetHdaAggregateId ( uint aggregateId ) : NodeId
aggregateId uint The aggregate id.
Résultat NodeId

GetHdaAggregateId() public static méthode

Converts a UA Aggregate ID to a HDA aggregate ID
public static GetHdaAggregateId ( NodeId nodeId ) : uint
nodeId NodeId The node id.
Résultat uint

GetHdaQualityCode() public static méthode

Converts a HDA quality code to a StatusCode.
public static GetHdaQualityCode ( uint quality ) : StatusCode
quality uint
Résultat StatusCode

GetHdaQualityCode() public static méthode

Converts a UA status code to a HDA quality code.
public static GetHdaQualityCode ( StatusCode input ) : uint
input StatusCode
Résultat uint

GetInt16s() public static méthode

Allocates and marshals an array of 16 bit integers.
public static GetInt16s ( short input ) : IntPtr
input short
Résultat System.IntPtr

GetInt16s() public static méthode

Unmarshals and frees a array of 16 bit integers.
public static GetInt16s ( IntPtr &pArray, int size, bool deallocate ) : short[]
pArray System.IntPtr
size int
deallocate bool
Résultat short[]

GetInt32s() public static méthode

Allocates and marshals an array of 32 bit integers.
public static GetInt32s ( int input ) : IntPtr
input int
Résultat System.IntPtr

GetInt32s() public static méthode

Unmarshals and frees an array of 32 bit integers.
public static GetInt32s ( IntPtr &pArray, int size, bool deallocate ) : int[]
pArray System.IntPtr
size int
deallocate bool
Résultat int[]

GetLocale() public static méthode

Converts a Locale string to a LCID.
public static GetLocale ( string input ) : int
input string
Résultat int

GetLocale() public static méthode

Converts a LCID to a Locale string.
public static GetLocale ( int input ) : string
input int
Résultat string

GetPrincipalFromUserIdentity() public static méthode

Returns the WindowsIdentity associated with a UserIdentity.
public static GetPrincipalFromUserIdentity ( UserIdentity user ) : WindowsPrincipal
user UserIdentity
Résultat System.Security.Principal.WindowsPrincipal

GetQualityCode() public static méthode

Converts a DA quality code to a status code.
public static GetQualityCode ( short quality ) : StatusCode
quality short
Résultat StatusCode

GetQualityCode() public static méthode

Converts a UA status code to a DA quality code.
public static GetQualityCode ( StatusCode input ) : short
input StatusCode
Résultat short

GetStatusCodes() public static méthode

Unmarshals and frees an array of HRESULTs.
public static GetStatusCodes ( IntPtr &pArray, int size, bool deallocate ) : int[]
pArray System.IntPtr
size int
deallocate bool
Résultat int[]

GetSystemMessage() public static méthode

Retrieves the system message text for the specified error.
public static GetSystemMessage ( int error, int localeId ) : string
error int
localeId int
Résultat string

GetSystemType() public static méthode

Converts the VARTYPE to a SystemType
public static GetSystemType ( short input ) : Type
input short
Résultat System.Type

GetUInt32s() public static méthode

Unmarshals and frees an array of 32 bit integers.
public static GetUInt32s ( IntPtr &pArray, int size, bool deallocate ) : int[]
pArray System.IntPtr
size int
deallocate bool
Résultat int[]

GetUnicodeStrings() public static méthode

Marshals an array of strings into a unmanaged memory buffer
public static GetUnicodeStrings ( string values ) : IntPtr
values string The array of strings to marshal
Résultat System.IntPtr

GetUnicodeStrings() public static méthode

Unmarshals and frees a array of unicode strings.
public static GetUnicodeStrings ( IntPtr &pArray, int size, bool deallocate ) : string[]
pArray System.IntPtr
size int
deallocate bool
Résultat string[]

GetVARIANT() public static méthode

Converts an object into a value that can be marshalled to a VARIANT.
public static GetVARIANT ( Variant source ) : object
source Variant The object to convert.
Résultat object

GetVARIANT() public static méthode

Converts an object into a value that can be marshalled to a VARIANT.
public static GetVARIANT ( object source ) : object
source object The object to convert.
Résultat object

GetVARIANT() public static méthode

Converts an object into a value that can be marshalled to a VARIANT.
public static GetVARIANT ( object source, TypeInfo typeInfo ) : object
source object The object to convert.
typeInfo System.Reflection.TypeInfo The type info.
Résultat object

GetVARIANTs() public static méthode

Marshals an array objects into an unmanaged array of VARIANTs.
public static GetVARIANTs ( object values, bool preprocess ) : IntPtr
values object An array of the objects to be marshalled
preprocess bool Whether the objects should have troublesome types removed before marhalling.
Résultat System.IntPtr

GetVARIANTs() public static méthode

Unmarshals an array of VARIANTs as objects.
public static GetVARIANTs ( IntPtr &pArray, int size, bool deallocate ) : object[]
pArray System.IntPtr
size int
deallocate bool
Résultat object[]

GetValueRank() public static méthode

Converts the VARTYPE to a UA ValueRank.
public static GetValueRank ( short input ) : int
input short
Résultat int

GetVarType() public static méthode

Converts the system type to a VARTYPE.
public static GetVarType ( System type ) : VarEnum
type System
Résultat VarEnum

GetVarType() public static méthode

Converts the TypeInfo to a VARTYPE.
public static GetVarType ( TypeInfo typeInfo ) : VarEnum
typeInfo System.Reflection.TypeInfo
Résultat VarEnum

GetVarType() public static méthode

Returns the VARTYPE for the value.
public static GetVarType ( object input ) : VarEnum
input object
Résultat VarEnum

InitializeSecurity() public static méthode

Initializes COM security.
public static InitializeSecurity ( ) : void
Résultat void

IsRpcError() public static méthode

Checks if the error is an RPC error.
public static IsRpcError ( Exception e ) : bool
e System.Exception
Résultat bool

IsUnknownError() public static méthode

Checks if the error for the exception is one of the recognized errors.
public static IsUnknownError ( Exception e ) : bool
e System.Exception
Résultat bool

IsValidComType() public static méthode

Returns true is the object is a valid COM type.
public static IsValidComType ( object input ) : bool
input object
Résultat bool

Match() public static méthode

Tests if the specified string matches the specified pattern.
public static Match ( string target, string pattern, bool caseSensitive ) : bool
target string
pattern string
caseSensitive bool
Résultat bool

ProcessComValue() public static méthode

Converts a COM value to something that UA clients can deal with.
public static ProcessComValue ( object value ) : object
value object
Résultat object

ReleaseServer() public static méthode

Releases the server if it is a true COM server.
public static ReleaseServer ( object server ) : void
server object
Résultat void

SetProxySecurity() public static méthode

Sets the security settings for the proxy.
public static SetProxySecurity ( object server, IntPtr pAuthInfo ) : void
server object
pAuthInfo System.IntPtr
Résultat void

SetProxySecurity() public static méthode

Sets the security settings for the proxy.
public static SetProxySecurity ( object server, UserIdentity user ) : void
server object
user UserIdentity
Résultat void

TraceComError() public static méthode

Reports an unexpected exception during a COM operation.
public static TraceComError ( Exception e, string format ) : void
e System.Exception
format string
Résultat void