C# Class Opc.Ua.Com.ComUtils

Exposes WIN32 and COM API functions.
Mostrar archivo Open project: OPCFoundation/UA-.NET

Private Properties

Property 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

Public Methods

Method 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

Method 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 method

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
return int

ChangeTypeForCOM() public static method

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
return int

CompareLocales() public static method

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

CreateComException() public static method

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

CreateComException() public static method

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
return System.Exception

CreateComException() public static method

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

CreateComException() public static method

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

CreateException() public static method

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

CreateInstance() public static method

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
return object

CreateInstance1() public static method

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
return object

CreateInstance2() public static method

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
return object

CreateInstanceWithLicenseKey() public static method

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
return object

EnumComputers() public static method

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

GetAccessRights() public static method

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

GetDataTypeId() public static method

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

GetDataTypeId() public static method

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

GetDateTime() public static method

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

GetDateTime() public static method

Unmarshals a WIN32 FILETIME.
public static GetDateTime ( System filetime ) : System.DateTime
filetime System
return System.DateTime

GetDateTimes() public static method

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
return System.DateTime[]

GetErrorCode() public static method

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.
return int

GetErrorText() public static method

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

GetFILETIME() public static method

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
return System.Runtime.InteropServices.ComTypes.FILETIME

GetFILETIMEs() public static method

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
return System.IntPtr

GetFILETIMEs() public static method

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

GetGUIDs() public static method

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
return System.Guid[]

GetHdaAggregateId() public static method

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

GetHdaAggregateId() public static method

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

GetHdaQualityCode() public static method

Converts a HDA quality code to a StatusCode.
public static GetHdaQualityCode ( uint quality ) : StatusCode
quality uint
return StatusCode

GetHdaQualityCode() public static method

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

GetInt16s() public static method

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

GetInt16s() public static method

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
return short[]

GetInt32s() public static method

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

GetInt32s() public static method

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
return int[]

GetLocale() public static method

Converts a Locale string to a LCID.
public static GetLocale ( string input ) : int
input string
return int

GetLocale() public static method

Converts a LCID to a Locale string.
public static GetLocale ( int input ) : string
input int
return string

GetPrincipalFromUserIdentity() public static method

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

GetQualityCode() public static method

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

GetQualityCode() public static method

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

GetStatusCodes() public static method

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

GetSystemMessage() public static method

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

GetSystemType() public static method

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

GetUInt32s() public static method

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
return int[]

GetUnicodeStrings() public static method

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

GetUnicodeStrings() public static method

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
return string[]

GetVARIANT() public static method

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.
return object

GetVARIANT() public static method

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.
return object

GetVARIANT() public static method

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.
return object

GetVARIANTs() public static method

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.
return System.IntPtr

GetVARIANTs() public static method

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

GetValueRank() public static method

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

GetVarType() public static method

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

GetVarType() public static method

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

GetVarType() public static method

Returns the VARTYPE for the value.
public static GetVarType ( object input ) : VarEnum
input object
return VarEnum

InitializeSecurity() public static method

Initializes COM security.
public static InitializeSecurity ( ) : void
return void

IsRpcError() public static method

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

IsUnknownError() public static method

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

IsValidComType() public static method

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

Match() public static method

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
return bool

ProcessComValue() public static method

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

ReleaseServer() public static method

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

SetProxySecurity() public static method

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

SetProxySecurity() public static method

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

TraceComError() public static method

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