Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
UFT + UFTPro 20th September 2017 7.30 AM - 9.00 AM IST 25Days Classroom + Online Hitech City
Selenium+Appium 4th October 2017 4.30 PM - 6.00 PM IST 40Days Online -

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

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