Thread: CREATEFILE function

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80

    CREATEFILE function

    Guys, i need to know something, can someone clarify it for me ?
    in the function CreateFile() i created, the following is an example
    Code:
    CreateFile(ofn.lpstrFile,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,0)
    CreateFile(filename,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
    Ok, this is something i need to know. How can i make a file, lets say .txt file as a hidden mode ? Another thing is, can i give my file an extension of its own, lets say .retard ? is it possible, maybe .ret, more appropriate. Because i dun wan the users to open the file and if they do, my program could open it for them instead. Is this achieveable ?
    /* Have a nice day */

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    >> Ok, this is something i need to know. How can i make a file, lets say .txt file as a hidden mode ? <<

    Use FILE_ATTRIBUTE_HIDDEN as the second last argument to CreateFile. If the file already exists you can use the SetFileAttributes function. Hidden files are usually anti-social and many users set Explorer to show hidden files.

    >> Another thing is, can i give my file an extension of its own, lets say .retard ? is it possible, maybe .ret, more appropriate. <<

    The file name you provide to CreateFile can have any extension (excluding bad characters and length restrictions).

    >> Because i dun wan the users to open the file and if they do <<

    A user can open and read the files they control. Only malware would seek to take away this right.

    >> my program could open it for them instead. <<

    You can setup a file association so that your program will be activated when a user double clicks on a file with the specified file extension.

  3. #3
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    anonymouse, Whats a malware ?
    /* Have a nice day */

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Wikipedia: Malware (a portmanteau of "malicious software") is any software program developed for the purpose of causing harm to a computer system, similar to a virus or trojan horse. More...
    ~~~~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM