Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 24th October 7.30 AM IST to 9.00 AM IST 45 Days WeekDay 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