DbgServices.AttachToProcess Method

Applies to TestComplete 15.63, last modified on April 10, 2024

Description

The DbgServices.AttachToProcess method attaches the DbgServices object to the specified process. If successful, the method returns True, otherwise, it returns False. Once attached, DbgServices traces certain application events under test and posts them to the test log.

Declaration

DbgServices.AttachToProcess(Process)

Process [in]    Required    A Process object    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Process

A Process object that represents the currently running Win32 process to which you want to attach TestComplete. To get such a process, use the Sys.Process method.

Result Value

True if TestComplete attached to the specified process successfully and False otherwise.

Example

The code below launches Notepad and then attaches to it using the DbgServices.AttachToProcess method.

JavaScript, JScript

function AttachToNotepad()
 {
  // Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL);
  var Proc = Sys.Process("notepad");
  
  // Doesn't trace Notepad
  
  DbgServices.AttachToProcess(Proc);
  
  // Traces Notepad
   
 }

Python

def AttachToNotepad():
  # Launches notepad.exe
  WshShell.Run("notepad.exe", SW_NORMAL)
  Proc = Sys.Process("notepad")
  # Doesn't trace Notepad
  DbgServices.AttachToProcess(Proc)
  # Traces Notepad

VBScript

Sub AttachToNotepad

 ' Launches notepad.exe
  Call WshShell.Run("notepad.exe", SW_NORMAL)
  Set Proc = Sys.Process("notepad")
  
  ' Doesn't trace Notepad
  
  DbgServices.AttachToProcess(Proc)
  
  ' Traces Notepad
   
End Sub

DelphiScript

function AttachToNotepad;
var Proc;
begin

  // Launches notepad.exe
  WshShell.Run('notepad.exe', SW_NORMAL);
  Proc := Sys.Process('notepad');
  
  // Doesn't trace Notepad
  
  DbgServices.AttachToProcess(Proc);
  
  // Traces Notepad
   
end;

C++Script, C#Script

function AttachToNotepad()
 {
  // Launches notepad.exe
  WshShell["Run"]("notepad.exe", SW_NORMAL);
  var Proc = Sys["Process"]("notepad");
  
  // Doesn't trace Notepad
  
  DbgServices["AttachToProcess"](Proc);
  
  // Traces Notepad
   
 }

See Also

DbgServices.LaunchTestedApplication
DbgServices.LaunchAllTestedApplications
DbgServices.LaunchApplication
Sys.Process

Highlight search results