The companion of ReadFileToMem to write file to disc :
// pFileName : pointer fo file name
// pMemory : pointer to the data to be written
// nSize : number of bytes to be written
BOOL WriteFileToDisc (LPSTR pFileName,LPBYTE pMemory,DWORD nSize)
{
HANDLE hFile;
DWORD pWritten;
BOOL t;
hFile=CreateFile(pFileName,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
if(hFile==INVALID_HANDLE_VALUE ){
return 0;
}
t=WriteFile(hFile,pMemory,nSize, &pWritten,0);
if(!t){
return 0;
}
t=CloseHandle(hFile);
if(!t){
return 0;
}
return 1;
}