The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: jdoe on January 06, 2006, 04:41:07 AM

Title: ExitProcess and freeing resource
Post by: jdoe on January 06, 2006, 04:41:07 AM

Hi,

While surfing on MSDN, I've found this about ExitProcess()...


Remarks
     Exiting a process causes the following:
        1.  All of the object handles opened by the process are closed.



Does it mean, if I open a file with CreateFile(), map this file with CreateFileMapping() and get a view pointer with MapViewOfFile(), that I don't need to UnmapViewOfFile() and CloseHandle() ?


Thanks

Title: Re: ExitProcess and freeing resource
Post by: hutch-- on January 06, 2006, 08:10:34 AM
jd,

ExitProcess() does a clean exit from a created process, the old rule is anything you start, you finish because while you may get away with it in some places, it will come back to haunt you in others. Memory, device contexts, open files etc ... be tidy with all of them and you will write reliable software, try and take shortcuts and you will end up with trash.
Title: Re: ExitProcess and freeing resource
Post by: jdoe on January 06, 2006, 09:14:02 AM

Thanks hutch,

I must say that I was wishing this reply. The remark about ExitProcess confused me a little and I thought there was a simpler way I didn't knew, after all those time. I know we never stop learning but there's a limit.  :lol