Filetype issues.

Blitz3D Forums/Blitz3D Programming/Filetype issues.

Nexinarus(Posted 2011) [#1]
Ok I wrote a program that shows everything in a current directory. No problems there.
As an advancement, I tried something similar with the harddrives.

Now when not compiled it shows all the drives that exist during the counting. no error messages.
When compiled i get the same thing but with this error message
"NO DISK"
"There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR#." #=3 4 5 etc...

I have to hit OK or CANCEL quite a few times before the program will run. due to the fact I can put different kinds of SD cards in my pc. E:\ F:\ G:\ H:\ I:\ are my SD cards slots. So this message shows up 5 times b4 the program starts.


when not compiled, i dont get that.
Blitz reads the c:\ D:\ E:\ etc... as folders. so if anyone can help thnx.

if you need to see the entire program to understand let me know.

here is some of the code.

Try it for yourself. Run the code as is. Then compile it and run the EXE.
you may have a better understanding of what I mean.

When testing this program
Make sure you have some other drives like a CD Drive or some SD Card slots. and make sure they are empty.




Last edited 2011


Kryzon(Posted 2011) [#2]
The problem is that you're trying to see if the drive has any files before checking if it has media in it, in case of media drives. If you try to read the root directory in a drive that doesn't have files you'll get that popup window.

You can use the Windows API functions to determine the type of filesystem each drive uses. If it's null, you know there is no media in there (no SD, CD or DVD). If there is media in the drive it should return FAT or NTFS, or at least anything BUT null.

Create a DECLS of these:

GetLogicalDriveStrings() - Use this to get a buffer with all the available drive letters. Use it like you see in this code, where it finds the buffer size before actually reading data.

GetVolumeInformation() - Use this to get information about each of the drives\volumes. Use the lpFileSystemNameBuffer pointer to get information about the file system the drive is currently using (null = no media, so don't try to read it with Blitz or you will get a popup window).


Nexinarus(Posted 2011) [#3]
but why didnt the program give me the pop up window when not compiled?
and which DLL would I have to load with the program?

Last edited 2011


Kryzon(Posted 2011) [#4]
1) I don't know; I hope someone else does.

2) You can see in which DLL the function is contained by scrolling to the bottom of the pages for those links.
GetLogicalDriveStrings(), for instance, is shown to be from Kernel32.DLL (there's already a DECLS for this DLL in the Code Archives).

All Windows API functions have their DLL of origin listed in Microsoft's website, so you can see this for other functions as well.

EDIT: You can also post your example on the Blitz3D's Bug Reports forum so the staff can take a look.

Last edited 2011


Nexinarus(Posted 2011) [#5]
i h8 to say this but i do not fully understand the loading library stuff yet.


jfk EO-11110(Posted 2011) [#6]
No rocket science there. You have to put a textfile into the "userlibs" folder. for functions of the kernel32.dll you would name it kernel32.decls. Inside the file you must declare the DLL name and the wanted functions, inclusing their parameters. Using the character # allows to use a bank handle as a pointer, for example when you want the DLL to write data to the bank.

If you can't find the DLL a certain function is part of, you may also use the systems file seach: just see what DLLs contain the functions name as a string, one of them should then be it.

You best try some of the simple examples in the code archives that are using some userlibs.
You can do both, use system functions as well as functions of DLLs you created using eg. C++, VB or eg. Purebasic.

Just a word about FIle access: file access and search became more and more unreliable in Blitz3D due to rising restrictions esp. for user accounts without admin privilegs. To see if you have read access to a certain folder you may write a dummy file to it and then open it. If you can open it, it may be likely that you got read access in the folder as well. If not, even don't try to browse the folder. ALso don't use FileExist on the created dummy file, it may cause your App to crash. Just open it and close it again, if it exists, and delete it again. Pretty slow, but at least it allows to browse a harddrive (ar the parts your allowed to do so) without any fatal errors.

BTW using Userlibs should not be confused with the LoadDLL (or was it OpenDLL?) Command in Blitz. The second was kind of replaced by the userlibs system.

Last edited 2011


Nexinarus(Posted 2012) [#7]
I don't fully understand banks either. Ill have to do some trial and error for that I guess. The docs don't fully make sense to me.


Yasha(Posted 2012) [#8]
A bank is just a block of bytes, to mutate and read as you please.

Unlike most things, it isn't broken up into variables: you have to manually specify which parts to read, how big they are, and what type they are, using position offsets from the start of the block with the relevant accessor functions.

There are a lot of ways to corrupt data (or "get interesting"), since you can write a value and read the bits back as a different type, or write a value and read part of it back by specifying a read position halfway into it, or... etc. Banks are also quite slow, both to create and to access.

There really aren't that many occasions when you actually need to use banks. You don't need to use them with DLLs at all, and doing so is better avoided (use instances of a custom type instead).