管理模式下无法访问文件

时间:2013-07-26 12:13:58

标签: c++ windows boost privileges

我今天有个奇怪的问题......

我们的软件运行良好。打开文件,每天创建流程......

但今天,我们发现如果我们在管理员模式中运行我们的软件......它不起作用......

例如,当我们尝试创建流程时:

if( !CreateProcess( NULL,   // No module name (use command line)
#ifdef _UNICODE
    LPWSTR(m_Exec.c_str()),        // Command line
#else
    LPSTR(m_Exec.c_str()),
#endif
    NULL,           // Process handle not inheritable
    NULL,           // Thread handle not inheritable
    FALSE,          // Set handle inheritance to FALSE
    CREATE_NEW_CONSOLE,              // No creation flags
    NULL,           // Use parent's environment block
    LPSTR(execFolder),           // Use parent's starting directory 
    &si,            // Pointer to STARTUPINFO structure
    &pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
{
    cout <<  "[X] CreateProcess failed: " << GetLastError() << endl;
    HandleLastError("CreateProcess");
}

我们有这个错误:

[X] CreateProcess failed: 2
[X] ERROR: CreateProcess: File specified not found.

当我们尝试使用boost::filesystem加载一个简单的配置文件时,我们软件的另一部分出现了几乎相同的错误:

boost::filesystem::fstream exists(fPath);

返回file not found

但正如我所说,如果我们使用完全相同的操作运行相同的软件但不是在管理员模式下,它可以工作......

当我们在互联网上搜索时,我们总能找到相同的东西:通过管理模式,它会起作用......但对我们来说,它是相反的......

任何想法?

PS:我们使用的是Windows 7,我们使用Visual Studio 2012 Update 3编译软件。

0 个答案:

没有答案
相关问题