How to replace _wopen/_open by OpenFile

In my programe I need to replace _open and _wopen by windows api function, I think the function OpenFile should be the one.

Are their return values are same indeed, since _open/_wopen return int, while OpenFile return HFILE, and those enum type look confusing.

Any suggestion would be appreciated.

Thank you
Last edited on
OpenFile is not recommended, use CreateFile instead:
1
2
3
HANDLE hFile=CreateFile("file.txt",GENERIC_READ | GENERIC_ALL,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
 // Read/Write...
CloseHandle(hFile);


http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx

You will also need ReadFile and WriteFile functions
http://msdn.microsoft.com/en-us/library/aa365467(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx
Last edited on
Topic archived. No new replies allowed.