API now closer to real one

We take pascal strings and return res Ref Numbers now, and we can close a file and retrieve resources.
Implemented UseResFile and fixed dangling pointer when closing.