DebugAgent.TreatPCharAsVType Method

Applies to TestComplete 15.0, last modified on October 22, 2021

Description

If the tested application is an Open Application that is compiled with debug information, TestComplete has access to the application’s internal methods, properties and objects. Methods can have parameters that are pointers to one- or two-byte values (for instance, a short int *, wchar_t * or bool * in C++ or PWideChar, PSmallInt or PWordBool in Delphi). The debug information treats these parameters as a pointer to a string, so when calling the method from scripts, TestComplete will attempt to pass a string to the parameter and the method call will fail.

Using the TreatPCharAsVType method, you can specify whether the scripting engine should treat these parameters as integer, boolean or string values. TestComplete will automatically transform the parameter value specified in scripts to the value of the appropriate type.

Declaration

DebugAgent.TreatPCharAsVType(VType)

VType [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

VType

One of the following constants that specify how the problematic pointers should be treated:

Constant Value Description
varInteger or VT_I4 3 The parameter will be treated as a pointer to an integer value.
varOleStr or VT_BSTR 8 The parameter will be treated as a pointer to a string.
varBoolean or VT_BOOL 11 The parameter will be treated as a pointer to a boolean value.

Result Value

None.

Remarks

Settings made by a call to the TreatPCharAsVType method effect it until you call a method with another value. To restore the default parameter processing (that is, to treat problematic parameters as strings), pass the varOleStr (or VT_BSTR, or 8) value to the TreatPCharAsVType method.

Example

The code below demonstrates how you can use the TreatPCharAsVType method to specify the type of the values used by TestComplete to treat pointer-to-string parameters in a certain way.

JavaScript, JScript

function TreatPCharAsVType()
{
  DebugAgent.TreatPCharAsVType(varInteger);
  // All the pointer-to-string parameters are treated as integer values
  // ...
  DebugAgent.TreatPCharAsVType(varBoolean);
  // All the pointer-to-string parameters are treated as boolean values
  // ...
  DebugAgent.TreatPCharAsVType(varOleStr);
  // All the pointer-to-string parameters are treated as strings
  // ...
}

Python

def TreatPCharAsVType():
  DebugAgent.TreatPCharAsVType(varInteger)
  # All the pointer-to-string parameters are treated as integer values
  # ...
  DebugAgent.TreatPCharAsVType(varBoolean)
  # All the pointer-to-string parameters are treated as boolean values
  # ...
  DebugAgent.TreatPCharAsVType(varOleStr)
  # All the pointer-to-string parameters are treated as strings
  # ...

VBScript

Sub TreatPCharAsVType
  DebugAgent.TreatPCharAsVType(varInteger)
  ' All the pointer-to-string parameters are treated as integer values
  ' ...
  DebugAgent.TreatPCharAsVType(varBoolean)
  ' All the pointer-to-string parameters are treated as boolean values
  ' ...
  DebugAgent.TreatPCharAsVType(varOleStr)
  ' All the pointer-to-string parameters are treated as strings
  ' ...
End Sub

DelphiScript

function TreatPCharAsVType;
begin

  DebugAgent.TreatPCharAsVType(varInteger);
  // All the pointer-to-string parameters are treated as integer values
  // ...
  DebugAgent.TreatPCharAsVType(varBoolean);
  // All the pointer-to-string parameters are treated as boolean values
  // ...
  DebugAgent.TreatPCharAsVType(varOleStr);
  // All the pointer-to-string parameters are treated as strings
  // ...

end;

C++Script, C#Script

function TreatPCharAsVType()
{
  DebugAgent["TreatPCharAsVType"]( varInteger );
  // All the pointer-to-string parameters are treated as integer values
  // ...
  DebugAgent["TreatPCharAsVType"]( varBoolean );
  // All the pointer-to-string parameters are treated as boolean values
  // ...
  DebugAgent["TreatPCharAsVType"]( varOleStr );
  // All the pointer-to-string parameters are treated as strings
  // ...
}

See Also

About Open Applications
Debug Info Agent
Calling Methods and Properties of Open Applications' Objects

Highlight search results