Windows vs. Standard

This is a discussion on Windows vs. Standard within the C++ Programming forums, part of the General Programming Boards category; Hey guys, I was looking at some code in a tutorial, and I noticed that it used these functions: ReadFile(HANDLE, ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Windows vs. Standard

    Hey guys, I was looking at some code in a tutorial, and I noticed that it used these functions:

    ReadFile(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED)
    CopyMemory(PVOID, const VOID*, DWORD)


    I also noticed that there are these equivalent standard(?) functions:

    ifstream::read(char*, int)
    memcpy(void*, const void*, size_t)


    Can someone tell me what advantages there would be in using the former Windows functions instead of the latter standard functions?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    You get slightly better performance from the windows api functions but for it you give up portability. iostreams are portable. Win32 api to a large extent isnt.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh, I see. Thanks for your explanation, I was thinking it would be something along those lines but I wasn't sure. Heh well, portability isn't too much of an issue since this is a DirectX app anyways
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    148
    On x86, CopyMemory == memcpy,It's defined as such in ntddk.h.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Stoned_Coder
    You get slightly better performance from the windows api functions but for it you give up portability. iostreams are portable. Win32 api to a large extent isnt.
    It's not as clean cut as that...some APIs map to std C funcs (as Wledge pointed out).

    msvcrt.dll ( and it's updates) export std c funcs like fgets, fopen, malloc, memcopy...etc...and functions like ZeroMemory wrap around these.

    Windows also exports some of these functions in another form to drivers running in kernel mode (wledge's example)....

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hm, ok. But if portability has already been compromised anyways, you can't go wrong with using the Windows API functions, right?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM
  5. a simple C question...
    By DramaKing in forum C Programming
    Replies: 10
    Last Post: 07-28-2002, 03:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21