SysEnvRec sysEnv;
OSErr err = SysEnvirons (1, &sysEnv);
sysVRefNum of SysEnvRec is a working directory ID, not a volume reference ID or a directory reference ID.
The currently running System file is always open. So you would get the file reference number (probably just kSystemResFile), and use...