winapi ReadFile() and WriteFile()

[color=brown]after making an extensive studies and research about these 2 functions, i'm still not completely able to use them the way i want them.

case one: "ReadFile()"
is there a way to be able to read one line at a time?

case two: "WriteFile()"
is there a way to be able to write one line at a time?
is there a way to be able to append to the file?


thanks very much,[/color]

Comments

  • : [color=brown]after making an extensive studies and research about these 2 functions, i'm still not completely able to use them the way i want them.
    :
    : case one: "ReadFile()"
    : is there a way to be able to read one line at a time?
    :

    What you can do is read all characters until you meet eoln (10, 13 ascii decimal).

    : case two: "WriteFile()"
    : is there a way to be able to write one line at a time?
    : is there a way to be able to append to the file?
    :

    Just like you read a line, you can write it... Write all the characters, and then add the eoln chars.

    Yes, you can append to a file. In order to do so you must open it using CreateFile and pass OPEN_EXISTING as the fifth parameters.

    :
    : thanks very much,[/color]
    :


    -----------------
    Dima Gornushkin

  • : : [color=brown]after making an extensive studies and research about these 2 functions, i'm still not completely able to use them the way i want them.
    : :
    : : case one: "ReadFile()"
    : : is there a way to be able to read one line at a time?
    : :
    :
    : What you can do is read all characters until you meet eoln (10, 13 ascii decimal).
    :
    : : case two: "WriteFile()"
    : : is there a way to be able to write one line at a time?
    : : is there a way to be able to append to the file?
    : :
    :
    : Just like you read a line, you can write it... Write all the characters, and then add the eoln chars.
    :
    : Yes, you can append to a file. In order to do so you must open it using CreateFile and pass OPEN_EXISTING as the fifth parameters.
    :
    : :
    : : thanks very much,[/color]
    : :
    :
    :
    : -----------------
    : Dima Gornushkin
    :
    :
    [blue]You also can use standard C functions - fopen()/fclose() to access a file - fread()/fwrite() to work with binary data and fgets()/fputs() to work with a text files line-by-line. On Win32 platform these function will be calling the pure Win32 API, like CreateFile()/ReadFile()/WriteFile(), etc.

    Or, you can create a class using ReadFile()/WriteFile() for binary file and then derive from that class, add a buffer and work with text files.[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories