How to open a filename given in Main’s argv[] (say, D:\a.txt) by CreateFile API?
CreateFile( ReadBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL );
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks to me that your problem is simply that you are trying to call a function like this
and don’t know how to get hold of the first command-line argument. Do it like this:
Note that
argvis an array containingargcitems where each item is of typechar*. So you simply want the item at index 1. The item at index 0 is the process name.