Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm doing a windows service project.I'm trying to access to remote file in my service project.
but it's not ok. I tried GetLastError, which returns error code 5.
But the same code works well in my console project. My IDE is vc6.
thanks a lot .

C++
            FILE * infile;
char f[]="\\\\192.168.1.22\\123\\004.jpg";
if ((infile = fopen(f, "rb")) == NULL)
{
    printf("can not open file by fopen");
}
Posted
Comments
songtzu 18-Feb-14 20:22pm    
thanks, I got the same information from google.
Raul Iloc 19-Feb-14 7:32am    
Did you try my solution?
songtzu 20-Feb-14 20:12pm    
yes.I know it's because of authority.I tried give it administrator authority.but I failed.
the password of my admin account is empty.so I tried to give it a password, it works.
Raul Iloc 21-Feb-14 0:45am    
OK, that is great!

1 solution

Your service run on a default user like "LocalSystem" that may have limited rights, so you have two solutions:
1)create a new user on your server then give it to them access rights, then start your service by using this new user;
2)give the access rights to the existing default user used by your service, but this could create security issues for other services that are running on your server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900