Hello, Is there a tutorial on reading files? I would like to read a data file in so I can put each line in a listbox.
Hello Frank, I am working on something similar. For now I have a program that takes a txt file, reads out every line and displays it in a messagebox. It should not be a big problem to put them into a listbox. Since it is not yet ready I cannot post it on my website and the code is more than scrambled but it works. I will send a copy to you. If anybody else wants this then mail me and I will see if I can load it up to my website. Just the small steps: * First you have to CreateFile using the OPEN_EXISTING param * Then you have to GetFileSize * Afterwards you GlobalAlloc the file * The you ReadFile it completely (there you need the size of file) * Afterwards you can CloseHandle * Last thing is that you have to analyse the buffer and search the string for CR/LF (=new line) * Put the string in the listbox (if you don't know them look at Icz's tut #31 (I think) Maybe the way is not described n 101% perfect ASM way but this is what you should know. Stefan
Thanks Stefan!!! I will check out your code that you sent me. I am sure it can get me started!!!
An alternative would be: 1. call CreateFile to open the file with GENERIC_READ and GENERIC_WRITE 2. call CreateFileMapping with PAGE_WRITECOPY flag 3. call MapViewOfFile with FILE_MAP_COPY flag you will have the file in memory and furthermore you can modify the content without affecting the original file 4. Search the whole file for 0Dh/0Ah and replace them with 0s. You will have an array of null-terminated strings which you can pass to the listbox easily. However, you have to beware of the "last string" problem. The last string may not be null-terminated because it may not be followed by cr-lf.