Admin Production ni-theme
Current Publication

DS_GetAttrType

LabWindows/CVI

DS_GetAttrType

HRESULT DS_GetAttrType (DSHandle DSHandle, const char *attributeName, unsigned int *type, unsigned int *dimension1, unsigned int *dimension2);

Purpose

Returns the data type of the data value of a DataSocket object's attribute.

This function is a convenience function that performs, in a single operation, the same task as calling DS_GetAttrHandle to obtain a handle to an attribute and then calling DS_GetDataType to get the type of the data value of the attribute.

Parameters

Input
Name Type Description
DSHandle DSHandle Pass the handle you obtained from DS_Open, DS_GetAttrHandle, or DS_CreateAttrHandle to identify the DataSocket object.
attributeName const char * A string to specify the name of the attribute. If the attribute does not exist, this function returns E_INVALIDARG (0x80070057).
Output
Name Type Description
type unsigned int Returns a constant that indicates the type of the attribute's data value.

Pass NULL if you do not want this information. The data value can be one of the valid types or an array of one of the valid types other than CAVT_VARIANT. The following table lists the valid type constants and their corresponding C/Windows types:

Constant C/Windows type
CAVT_DOUBLE double
CAVT_FLOAT float
CAVT_LONG long
CAVT_SHORT short
CAVT_UCHAR unsigned char
CAVT_CSTRING char *
CAVT_BOOL short
CAVT_VARIANT VARIANT
If the attribute's data value is an array of one of the valid types, this parameter returns a bitwise OR (|) of the type and the CAVT_ARRAY flag. You can use the following code to determine whether the data value is an array:

int isArray = (type & CAVT_ARRAY);

Note    This function returns the CAVT_VARIANT constant for the type if the type of the Attribute value is not a valid ActiveX type. Some servers that use custom interfaces might support non-Automation types, such as unsigned short, unsigned long, and others.
dimension1 unsigned int Returns the length of the string if the type of the attribute's data value is CAVT_CSTRING. The length does not include the terminating NUL byte.

Returns the number of elements in the array if the attribute's data value is a 1D array of any type.

Returns the size of the first dimension of the array if the attribute's data value is a 2D array of any type.

If the attribute's data value is not a string or an array, the value returned is not defined.

Pass NULL if you do not want this value.
dimension2 unsigned int Returns the size of the second dimension of the array if the attribute's data value is 2D array of any type.

If the attribute's data value is not a 2D array, the value returned is not defined.

Pass NULL if you do not want this value.

Return Value

Name Type Description
status HRESULT The value that indicates whether an error occurred. A negative error code indicates function failure.

Error codes are defined in CVIversion\toolslib\datasock\dataskt.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. Other error codes in winerror.h are generated by ActiveX Servers and are passed on to you by the DataSocket Library.

Additional Information

Library: DataSocket Library

Include file: datasock\dataskt.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later