visual c++ - fopen fwrite work but no file is created -
below here simple program. if run guest (not administrator) , file didn't exist @ moment of execution, program tells "ok" (that is, fopen , fwrite seem work) test.bin isn't created. expected fopen return null did not. correctly returns null if file created administrator , existed but, if there isn't file, tells ok file isn't created. win 7 professional, msvc 6.0 tommaso
#include "stdafx.h" #include "stdio.h" #include "conio.h" int main(int argc, char* argv[]) { file *fp; fp=fopen("c:\\test.bin","w+b"); if (fp==null) printf("fopen returned null\n"); else { if (fwrite("hello",5,1,fp)!=1) printf("fwrite failed\n"); else printf("ok\n"); } if (fp) fclose(fp); getch(); return 0; }
if have uac enabled on system , application not have manifest, uac virtualization system redirect writes protected locations.
this backwards compatibility - write permission denied system root virtualization system means older software can continue keep working rather failing outright.
if add manifest application seen uac aware , virtualization disabled. otherwise, find file underneath c:\users\<username>\appdata\local\virtualstore
.
Comments
Post a Comment