Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,everyone.

I call NetShareGetInfo in my MFC project and then I do get the shared netware infomation.
But, I call this API "NetShareGetInfo" in my windows service project,
and then it returns "ERROR_ACCESS_DENIED". I do not know why.

Can you give me some sugestion?

Thanks!
Posted
Updated 23-Nov-10 23:50pm
v3

Hi Markliu,

a service runs under any windows account and you can specify which one. The account your windows service runs under probably doesn't have the appropriate access rights.

For starters you might try running your service under your account to see if it works. I presume your MFC project was not run as service but under your
user account (where the call worked as you noted).

Modification:

If its running as "LOCAL SERVICE" you can also try "NETWORK SERVICE".
These two are build in special windows accounts.
End Modification:


Cheers

Manfred
 
Share this answer
 
v8
Comments
Dalek Dave 25-Nov-10 5:01am    
Good Call.
Hi,

The error you are getting due to not having proper rights. Try to register your servics as Local service; but prior to that, you should logged in as an Admin of that system.

See the details usage of NetShareGetInfo() as below:
http://msdn.microsoft.com/en-us/library/bb525388(VS.85).aspx[^]

Also ref. to this post.

http://www.codeproject.com/Messages/84647/NetShareGetInfo-returns-ERROR_ACCESS_DENIED.aspx[^]

I hope this may help you a bit.

Bye.
 
Share this answer
 
Comments
Dalek Dave 25-Nov-10 5:01am    
Good Answer.
Hi Manfred and @Intersect,
The reason is "access rights", just as you said.
I set the logging account of my service as an Admin, then thing is OK.
Thanks you very much!
 
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