CS609 Assignment 1
CS609 Assignment 1
BC170202271
Question 1:
1. The file is created for read/write both.
FILE_ATTRIBUTES_NORMAL
2. The file is not required to be created for sharing.
dwShareMode: 0 Signature That File will Not Be Shared
3. Security attributes should be default.
IpsecurityAttributes
4. If the same name filename exists, then it is overwritten by the new file.
CREATE_ALWAYS
5. Set all other parameters as NULL.
array_create(NULL,10);
Question 2:
#include <windows.h>
#include <everything.h>
#include <strsafe.h>
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
ExitProcess(dw);
void main()
if(!GetProcessId(NULL))
ErrorExit(TEXT("GetProcessId"));