Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Thursday, September 2, 2010

Extern Object - Using DLL Functions in QTP

'###############################################
'           Extern Object 
'###############################################

' Purpose - Declares references to external procedures which are stored with a dynamic-link library (DLL). 

'Syntax:-  Extern.Declare(RetType, MethodName, LibName, Alias [, ArgType(s)]) 

'Ex:- 
'  FindWindowA is a function in user32.dll. This function is used to find a window which is currently opened on Desktop.
'  This function takes two string inputs NativeClass & Title of the Window.
'  This will return a handler value of the identified window.
'  If it is returned 0 then there is no window found

 'Declare FindWindow method 
 Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString 
 
 'Get HWND of the Notepad window 
 hwnd = Extern.FindWindow("Notepad", vbNullString) 
 
 If hwnd = 0 Then 
   MsgBox "Notepad window not found" 
  Else
   MsgBox "Notepad window found" 
 end if 

2 comments :

  1. HI,

    Very useful information, but I need small clarification like, when I am trying to execute this function, its asking like Object Required.

    But with my understanding, Extern is builtin function right?

    Could you please help me?

    Thanks in advance your your help,

    Rama

    ReplyDelete
  2. Can you clearly explain the functions present inside the dll files,eg..what is the use of findwindow and findwindowA... because i have a little bit of confusion in that can u rectify that as soon as possible

    ReplyDelete