Thread: windows api file functions

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    windows api file functions

    Hello all. I am relatively new to Windows programming. I can make it do fanciful stuff like show windows, but i was wondering what kind of functions the windows api provides for things like opening, closing, and reading files, making directories, and things of that nature. If you can point me to a good document besides the MSDN about the api, i would much appreciate it.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    27
    Why not MSDN? o.O

    MSDN is one of the most helpful resources to Windows programmers, it covers pretty much every function, structure, message and macro efficiently, and even has procedures set by...

    But if you must... This covers opening/saving files: http://www.winprog.org/tutorial/app_two.html

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    150
    I admit, the MSDN is very helpful, if you have a question about a specific function. I'm not one for the organization of the website. How are you supposed to find anything on there? But anyways thanks for the help

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can download the Windows SDK which comes with the compiled help. It uses the same format but you can use the index which is quite nice for finding what you want.

    I normally have the index open and I also bookmarked the page that breaks each Windows API function down by category. This page is very useful since it gives a good overview of the API from a functional perspective.

    Remember that MSDN has a lot more than just the Windows API on it and at times this makes searching it a bit confusing. It has everything from SQL Server to Direct3D to .NET.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    150
    Very true. I have another question. Is there an efficient way to check for directory existence using the windows API? i found alot on files, but not much on directories...

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Code:
    WIN32_FIND_DATA stFind;
    HANDLE hFindFile;
    hFindFile=FindFirstFile("fileordirname",&stFind);
    if(hFindFile!=INVALID_HANDLE_VALUE){
        //exists
        if(stFind.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
            //it's a directory
        }
        else {
            //it's a file
        }
        FindClose(hFindFile);
    }
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    150
    I'm now trying to use the shell function SHCreateDirectory. I have included <shlobj.h> and have linked to shell32.lib, but the compiler is telling me that SHCreateDirectory is undeclared. is there another file i should be including?

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    #define _WIN32_WINNT 0x0500
    #define WINVER 0x0500
    Last edited by Elysia; 07-01-2008 at 03:45 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    150
    Quote Originally Posted by Elysia View Post
    #define _WIN32_WINNT 0x0500
    #define WINVER 0x0500
    its still saying that SHCreateDirectory hasnt been defined and now its giving me warnings about redefining

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM