Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Failed or Cannot Open File errors from scan
#1
Hi Gintaras,
I have been getting intermittent errors in my error log for a function line that looks like this:

Code:
Copy      Help
RECT DRSBox_MonB.left=1920; DRSBox_MonB.top=0; DRSBox_MonB.right=3836; DRSBox_MonB.bottom=900;
if(scan("$common documents$\My QM Share\QM BMPs\Sample.bmp" 0 DRSBox_MonB 4))


Mostly they are "failed" but sometimes "cannot open file".
The local file is present and it works most of the time on most systems but there will be a run of these errors for one login session of a user.
The problem is not user specific as far as I know.

This may be too much of a unique kind of bug for you to help out much, but any thoughts on what could be going wrong with the scan function. Perhaps the mask flag is a problem or the size of the bmp is preventing quick loading depending on the resources available on the computer. The size of the bmp is only 1 kb however.
Thanks,
S
#2
Maybe this info can help to debug "cannot open file" error.

1. At first scan finds the file like str.searchpath does. Expands spec folder etc.
2. Then loads bitmap using API LoadImage.
3. If the file does not exist or LoadImage fails, throws error "cannot open file". Nothing else throws this error in scan.

I don't know reasons why LoadImage can fail even if file exists.
May fail if the file is locked by some program.
Or if not enough memory.
Or maybe too many open handles (bitmaps or other GDI objects). For example, if I call LoadImage 10000 times and don't close the handle, LoadImage then fails and QM stops working normally.

When LoadImage in scan fails, str.dllerror should give more info.
LoadImage in MSDN: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Also google for LoadImage error.

Can use this code to debug:
Code:
Copy      Help
str imgfile="$common documents$\My QM Share\QM BMPs\Sample.bmp"

str sf
if(!sf.searchpath(imgfile)) end "file not found"

__GdiHandle hbitmap=LoadImageW(0 @sf IMAGE_BITMAP 0 0 LR_LOADFROMFILE)
if(!hbitmap) end _s.dllerror("LoadImageW error:")

or
Code:
Copy      Help
int ok=scan("$common documents$\My QM Share\QM BMPs\Sample.bmp" 0 DRSBox_MonB 4)
err
,out _s.dllerror("dllerror:")
,out _error.description
,ret
#3
Error "failed" can have several reasons, but with your code only this is real:
Cannot get bitmap or screen pixels. Maybe not enough memory, or too many GDI object handles, or some other reason that I don't know. Need 4 bytes for each pixel. Try to make the search area smaller. Maybe something wrong with Windows memory settings.
#4
Both amazingly helpful...THank you so very much. Will make the RECT function smaller to start off with and go from there.

S
#5
I think it is a memory problem on the PC....seems to occur when all sorts of screen update issues arise....ghosting on the screen, etc...and then gets better after reboot.
S


Forum Jump:


Users browsing this thread: 4 Guest(s)