代码很简单,在前台用普通进程运行是可以访问共享磁盘,但在后台用服务运行时,却连文件属性都不能取到。
哪位老大能给点建议?谢谢!
void test(const char *pDir)
{
struct _stat buf;
int result = _stat(pDir, &buf);
if( result != 0 && errno == ENOENT) { // No such dir
LogMessage("No such file");
return;
}
}test("\\\\192.168.51.44\\share");
哪位老大能给点建议?谢谢!
void test(const char *pDir)
{
struct _stat buf;
int result = _stat(pDir, &buf);
if( result != 0 && errno == ENOENT) { // No such dir
LogMessage("No such file");
return;
}
}test("\\\\192.168.51.44\\share");
你的服务当中采用LogonUser + ImpersonateLoggedOnUser试试?用户就用能访问共享目录的用户。