Thread: Writefile

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    48

    Writefile

    Q) What is the last parameter of Writefile (lpOverlapped)? What is it. And why it should be set to null. (I tried reading msdn. But couldn't understand)
    And how to use Offset and OffsetHigh member.
    Last edited by freiza; 10-29-2011 at 05:18 PM.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The perhaps you should also read THIS

    Offset and OffseHigh are explained HERE

    Both of these references were taken from the writeup for WriteFile() ... I suggest that instead of reading to find quick answers, at this point you should be reading to learn... that is, read every word, follow the links, and actually study the topics.

    I trust that when you get to ReadFile() you'll use this new strategy.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    48
    @CommonTater: I have already learnt ReadFile.
    Before asking question to forum. I try my best to understand. But all the people are not same. Some are less intelligent and needs push to run.
    And Msdn just tells "What" and not "How" and "Why"?

    Btw I am happy that you are keeping track of my progress.
    Thank You

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Yes, well... MSDN is a reference source, a place to look up functions and see how they are used. You're going to have to learn to read them eventually, now is as good a time as any. (and by "read", I mean READ; every word, as many times as it takes to understand.) There is no better source of Windows API information than Microsoft's own documentation.

    And FWIW... claiming stupid is not how you make points with your helpers.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    48
    MSDN is a reference source and a place to look up functions --> yes
    But you cannot see how the functions are actually used. For ex:
    Code:
    typedef struct _OVERLAPPED {   ULONG_PTR Internal;   ULONG_PTR InternalHigh;   union {     struct {       DWORD Offset;       DWORD OffsetHigh;     };     PVOID  Pointer;   };   HANDLE    hEvent; } OVERLAPPED, *LPOVERLAPPED;
    This does not give me clue how to put all of these in Writefile's lpOverlapped parameter.
    And actually I don't understand how do you people learn it without seeing any examples.

    Thank You

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, first off... are you doing overlapped I/O? (as in specifying FILE_FLAG_OVERLAPPED)

    If not, then just put NULL in there. If MSDN's documentation says it can be NULL or 0... then put NULL or 0 unless you are explicitly using that feature. Seriously... that's what they intended for you to do.

    More detail on Synchronous vs Overlapped I/O is HERE

    There are usage examples HERE


    Where did I get this information? By following and reading links in the WriteFile() documentation. Now each of these sections will have their own set of references... follow them too!

    For a clean start: File (and other) I/O is explained HERE and HERE... which I found by following links from the CreateFile() function.

    How do we learn it? By studying the supplied documentation... Not just opening the page expecting to find copy and paste examples then glazing over when thery're not there... We read the text, ALL of it, as often as it takes to understand, we follow the references and we read ALL of them as well... Knowledge does not just drop out of the sky... you have to go get it.

    Right now --this minute-- I have no utter idea how to use DirectShow ... but by the time I need to add it to a project, I will have read up on it on MSDN and elsewhere written small test programs to make sure I understand it and I will have my code planned out and ready to enter and test...

    The real skill here is not typing C syntax... that's easy stuff. The real deal that makes or breaks a programmer is the ability to look stuff up when he or she needs it... If you can't cultivate this skill (especially with an API exceeding 20,000 function calls) you should give it up right now. None of us, not a single one of us, can even hope to remember all this stuff.
    Last edited by CommonTater; 10-30-2011 at 08:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WriteFile and fwrite
    By George2 in forum C Programming
    Replies: 4
    Last Post: 08-10-2007, 04:33 AM
  2. WriteFile issue
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-26-2007, 08:46 AM
  3. It doesn't like my WriteFile();
    By Queatrix in forum Windows Programming
    Replies: 11
    Last Post: 04-21-2005, 06:37 PM
  4. WriteFile()
    By shane1985 in forum Windows Programming
    Replies: 6
    Last Post: 08-17-2003, 03:19 AM
  5. WriteFile help (Win32).
    By Sindolist in forum Windows Programming
    Replies: 1
    Last Post: 10-28-2002, 04:23 PM