Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / File browser errors

Author
Message
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 12th Apr 2009 17:35 Edited at: 12th Apr 2009 17:36
This problem has been mentioned once before, but I can't remeber there being a definite solution so I'm asking for help. If you call:

Windows throws up a series of error messages - one for each drive which does not exist. You can't even run checks on Path Exist("A:"), as the same error appears.

Now I could just disable the Windows Mode, but I'd prefer not to (it means I can minimise the program and have it restore and keep running without the screen turining to a mass of fuzzy lines.) So - does anyone have any ideas how I can successfully build up a list of drives?

I'm not sure if there's a dll call to obtain the drive list from windows (it's bound to have it somewhere) or change my file browser system to one that directly accesses the Windows Open File browser. Any help would be most appreciated!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Apr 2009 22:11
Kinda irritatingly basic, but you could do:



Then you know that if drives(i)=1 then it exists. Conversely, it could probably be better to just us a repeat until the path doesn't exist, but this should work.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Apr 2009 02:02 Edited at: 13th Apr 2009 02:07
Quote: "Windows throws up a series of error messages - one for each drive which does not exist. You can't even run checks on Path Exist("A:"), as the same error appears."


You mean windows crashes DB with an error and won't let you go on? What errors are you getting?

BN2's method should work.

We could try the same thing BN2 is doing except use the win32 api for all of the calls. Maybe using the win api directly in windows mode will circumvent the problems. The following example retrieves the root drive letters and loads them into a memblock. Each byte=0 in the memblock indicates the end of a string. The returned size of all the drive strings combined is returned by the win api call. Using this value and dividing it by 4 (the length of each drive string) I can determine the number of drives. I dimension a string array to copy the memblock string into.

I test each drive in the array by calling SetCurrentDirectory to that drive letter through the win api. If it returns a 0 (fail), I check for an error code (I know error 21 = device not ready) and display a message. This error check could be used to deactivate a drive from your drive list in your file browser. The errors are returned as codes to your app so windows or db shouldn't quit on an exception. A list of the system error codes can be found on the msdn site.



Enjoy your day.
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 13th Apr 2009 18:39
Sorry I wasn't more clear - I've tried all your suggested methods, and in each case I get the attached error message. It appears whenever a check is run on a drive that could exist but doesn't - for example, when it looks at the empty floppy drive, or my XD/SD card readers. If you click Continue, or cancel, it just moves on to the next drive.

I don't think its a problem with Dark Basic - I've been trying to change drives in Delphi and it gives the same error message.

This line highlights the problem:

Merely attempting to set the path to something like the A:\ drive will give an error.

If you aren't getting errors, then it has to be something wrong with my computer but I've no idea what - file browsers, "My Computer" etc. all work perfectly. Rather than trying to patch up my file browser, is there a dll call to access the standard Windows file browser?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Attachments

Login to view attachments
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th Apr 2009 19:59
What os are you running?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Apr 2009 22:16 Edited at: 13th Apr 2009 22:42
@RTR
Take a look at this:

Exception Processing Message

Reading through this article provides a possible solution to the problem and seems to indicate that there has been an internal change with the drive letters as the result of installing software, or a virus/malware.

I'm not getting the error and since there was a DB challenge about a file browser, many others aren't getting the error, it may be machine specific as the link suggests. If the fix(es) outlined in the link don't work, there is a way to turn system error reporting off from displaying a message box - though the error is returned to the calling app.

Enjoy your day.
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 15th Apr 2009 18:59
@BN2 Productions
I'm running Windows XP, Service Pack 2 (5.1)

@Latch
Thanks for the info, Latch, I've tried some of the solutions that website recommended but without much success. A full system scan using Norton Anti-Virus found no problems (step 1), and clearing out the most recently used files (step 4) did no good either.

Placing a floppy disc into the A: drive removed the error when that disc is checked for existance, but it's not possible to fill all the drives - my computer came with a multiple card-reader slot, but I just don't have the different cards to fill the slots.

I don't really want to try any of the other steps as I really wouldn't know what I was doing. The site suggests changing drive letters, uninstalling the floppy drives or even editing the registry, and I think I'm in great danger of messing up an otherwise perfectly functional computer. (I'm reminded of a friend who couldn't get a new USB pen drive to work properly on Windows 98, he wound up in a part of My Computer I'd never seen before, and then he clicked something like "Remove USB" thinking that it would stop the pen drive. It did. It also stopped every USB port on the computer and he never figured out how turn them on again.)

Interestingly, though, I've been running some more tests and I don't actually get that error for the empty D Drive (CD-Rom drive). I've no idea why that should be - maybe it's to do with the way the computer ports are hardwired in. I've run your code on another computer (one with Windows XP, the latest updates, and it only has a disc drive) and there's been no problem. So it looks like its just my computer at fault - and given that there's nothing else the matter, I think I'll just have to put up with the errors!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th Apr 2009 19:09
Quote: "I've no idea why that should be"

I have noticed that Windows doesn't mind accessing an empty cd drive. It will usually just produce an empty explorer window (my guess is for burning files), so that probably has something to do with it.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 15th Apr 2009 19:12
Ah, right. I didn't know that...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Apr 2009 21:07
@RTR
I'm not quite out of tricks yet! For fun (yeah fun!) try this variation of the posted code. It accesses the drives differently by testing the size of each disk. The return error codes are different than in the previous example. Maybe these access methods will avoid the error message box...



Enjoy your day.
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 17th Apr 2009 14:14 Edited at: 17th Apr 2009 14:16
Where on Earth did you manage to learn so much about how Windows works? I just can't find anything online about the winapi calls, or how it all fits together!

Anyway, I'm afraid your new code still didn't work - each drive returned error 21, with the exception of my USB pen drive (the last drive in the list), which gave error 3. Why the system couldn't find the path specified is a mystery to me (I did manage to find the error list on msdn), it was plugged in and working, so there's nothing wrong with the extension cable.

If you've got any other ideas of things I could try, I'd be fascinated to hear them, but don't worry too much more about. I'm starting to get the feeling there's nothing that can really be done to sidestep the problem (aside from fiddling in the background of windows, which I really don't want to have to do!)

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 17th Apr 2009 14:54
Short of turning off the system error messages, here's one more idea. One can actually query the drive type. If the drive type is removable, then you could exclude it from your file browser. If it is a fixed drive, then you should be able to use it without error. This is also a handy bit of code to add icons for the relative drive type.



Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 17th Apr 2009 18:13
Quote: "Where on Earth did you manage to learn so much about how Windows works? I just can't find anything online about the winapi calls, or how it all fits together!"


http://msdn.microsoft.com/en-us/library/default.aspx

lol.

New Site! Check it out \/
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 19th Apr 2009 22:06
I'm afraid it still doesn't work. I don't think it's worth wasting any more time over, although the different win api calls you've shown me have been most interesting and very educational. I''ll certainly be spending a lot of time reading round that link Caleb1994 sent me!

Once again, thanks for all your help!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Login to post a reply

Server time is: 2025-06-08 05:36:26
Your offset time is: 2025-06-08 05:36:26