Compartir a través de


Vector.SetFromString method

Stores the String value into the Vector of bytes including the terminating null character. Value might be truncated unless Resizable is True. The string is stored as an ANSI string unless Unicode is True, in which case it is stored as a Unicode string.

Syntax

Vector.SetFromString( _
  ByVal Value As BSTR, _
  [ ByVal Resizable As VARIANT_BOOL ], _
  [ ByVal Unicode As VARIANT_BOOL ] _
) As HRESULT

Parameters

Value [in]

Type: BSTR

Required. String value.

Resizable [in, optional]

Type: VARIANT_BOOL

Boolean value.

Value Meaning
False
Not resizable.
True
Default. Resizable.

Unicode [in, optional]

Type: VARIANT_BOOL

Boolean value.

Value Meaning
False
Not Unicode.
True
Default. Unicode.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Because vectors of bytes can actually be strings, this method provides a way to set the contents of a Vector of bytes from a String in either Unicode or ANSI form. Note that since all strings are Unicode in Microsoft Visual Basic, you need to specify which way you would like the string stored.

One common point of confusion is how to create a Vector of bytes. Many Visual Basic developers might be tempted to try the following:

'Do not follow this example
Dim v 'As Vector

Set v = CreateObject("WIA.Vector")

v.Add "A"

However, the previous example does not work as expected. It actually creates a Vector of strings where the first element contains the string "A". Instead, to create a Vector containing bytes you can use the SetFromString method or the CByte function in Visual Basic as follows:

Dim v 'As Vector
Dim b 'As Byte

Set v = CreateObject("WIA.Vector")

b = Asc("A")
v.Add CByte(b)

For example code, see Exif Filter: Write a New Title Tag to an Image.

Requirements

Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 R2 [desktop apps only]
Header
Wiaaut.h
IDL
Wiaaut.idl

See also

Vector

Reference

Value (Property)

Value (Rational)

Add (Vector)