WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Searcher
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Box with SrchNext Function Problem


Question:

I am having a problem with the following code:
AddExtender("wsrch34i.dll")
hand=SrchInit("c:\","TRAIN.EXE","","",16)
BoxOpen("Search Progress","" )
While 1
   BoxText("Warning")
   ; Works when srchNext is removed
   ; Fails when srchNext is included
   a=SrchNext(hand)
   If a=="" Then Break
EndWhile
SrchFree(hand)
Run the above code. Once the box is on the screen (Notice the x on the system menu is greyed out). I then switch focus to any other window, then back to the box. The x on the system menu is nolonger greyed out! Also the text in the box has disapeared.

The really strange things is if I then comment out the SrchNext and the following if condition, and take the same steps the x on the system menu is ALWAYS greyed out and the text remains in the box.

WHY?

Answer:

The problem seems to be that srchNext is so CPU intensive that Windows is not allowing the box to refresh. The srchNext function is not going to return until it finds a file named TRAIN.EXE. This is so CPU insensive tha the operating system is adding the system close menu back to the dialog of all windows as a free public service.

The only workaround I can think of is the tell the SrchInit function to return all directories using flag 32. This will cause srchNext to retrun everytime a new directory is found. You can then ignore those returns, but at least now the box is given a chance to update and not be seen as non responsive by the operating system.

AddExtender("wsrch34i.dll")
hand=SrchInit("c:\","TRAIN.EXE","","",16+32)    ;   Added 32 to get directories
BoxOpen("Search Progress","" )
While 1
   a=SrchNext("Warning")
   If a=="" Then Break
   BoxText(a)
   If StrSub(a,StrLen(a),1) == "\" Then Continue  ; ignore directories
EndWhile
SrchFree(hand)

Article ID:   W16857
File Created: 2017:07:28:13:58:29
Last Updated: 2007:07:03:14:26:36