The documentation for OpenFile function in Windows is located here. And I am trying to do this:
#include "Tchar.h"
#include <windows.h>
int main(int argc, TCHAR *argv[]){
LPOFSTRUCT _buffer;
HFILE _hfile_ = OpenFile("E:\\mozunit.txt", _buffer, OF_READ);
LPVOID _buffer_read;
LPDWORD _bytes_read;
bool flag = ReadFile(_buffer, _buffer_read, 5, _bytes_read, NULL);
CloseHandle(_buffer);
return 0;
}
Now, when I run this I get an error that I have not initialized the _buffer
. So to counter that I initialized _buffer
like this:
LPOFSTRUCT _buffer = NULL;
Which gives me an access violation error. Why is that?