Have you tried running this as an 'Administrator' under Vista? Remeber for that particular OS, Security Center was a little anal when it came to programs accessing the systemroot, especially if they claimed to run as a priviledged account. Also try running your app through the Schedular in Vista, this should run it as the System user and by-pass all of that Psuedo-Security nonsense.
EDIT: As for the "Memory Leak" thing, I'm sorry I cannot explain what seems to be a psuedo-intellectualls cop-out because they cannot answer an posters question. If for some reason your computers name would take up more then 16 chars, then do as MSDN says here: http://msdn.microsoft.com/en-us/library/ms724295(VS.85).aspx and call "GetLastError()" to see what it is and run the value up against this: http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
Let us know what you find.
Yes, I tried running as administrator, but the program still crashes.
I also tried to change the 16chars into MAX_PATH, but no changes as well :(
I know about GetLastError, but my program needs to be a console for that (and not a win32 app), and because of that I need to leave some things out of the program, like GDI, as they only work as win32 apps. I will try that tomorrow if there is no new solution :)
You could not use "GetLastError()" OR you could pipe the output to a "error.txt" file with 'ofstream'; the CLI console is not the only output option you have.