0

Kernel32.dll has an internal dll API-MS-WIN-CORE-FILE-L1-1-0.DLL used for file operations. FindFirstFile method available in the dll, is used to find files in a directory. Definition of FindFirstFile on msdn - https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx

I wanted to use this method in QTP/UFT for performing file operations using Extern object. But not able to come up with the declaration and usage.

Extern.Declare returntype, “FindFirstFile”, "Kernel32.dll”, “FindFirstFileA”, micString, secondparameter

Not able to figure what to provide in return type and second parameter? As per the definition of FindFirstFile, the return type is "search handle" and second parameter is a pointer to the WIN32_FIND_DATA structure.

After declaration how to use the method for finding files?

Akbar
  • 1,513
  • 4
  • 20
  • 34
  • Googling FindFirstFile Extern Declare gives this question as the first hit, and http://www.sqaforums.com/forums/hp-unified-functional-testing-uft-mercury-quicktest-pro-qtp/154719-extern-object-findfirstfile-method.html as the second, which might prove useful. – TheBlastOne Feb 29 '16 at 12:16
  • But why don´t you use the FileSystemObject COM object to scan directories? See f.e. https://msdn.microsoft.com/en-us/library/aa242706%28v=vs.60%29.aspx, used a la http://stackoverflow.com/questions/4200028/vbscript-list-all-pdf-files-in-folder-and-subfolders ? – TheBlastOne Feb 29 '16 at 12:25
  • Problem with the API function you refer to is that it receives a block of information (a target buffer) that you must supply a reference (i.e. a pointer) to. You will have a hard time providing such a pointer since a) VBScript does not know about pointers and b) VBScript does not support structs, which you would need to declare and allocate the block. – TheBlastOne Feb 29 '16 at 12:28

1 Answers1

0

Did you search QTP help? I have seen all the possible data types that can be used for Extern in QTP's help.

return type will be micHwnd in your case.

For any out parameter, micByRef

vins
  • 15,030
  • 3
  • 36
  • 47