当前位置: 首页>>代码示例>>C++>>正文


C++ COptions::get_Command方法代码示例

本文整理汇总了C++中COptions::get_Command方法的典型用法代码示例。如果您正苦于以下问题:C++ COptions::get_Command方法的具体用法?C++ COptions::get_Command怎么用?C++ COptions::get_Command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COptions的用法示例。


在下文中一共展示了COptions::get_Command方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _tmain


//.........这里部分代码省略.........

            OutputWriter::WriteLine(TEXT("Calling CalculateSourcePath")); 
            // TODO: We'll eventually have to deal with mount points
            CString wszSource;
            CalculateSourcePath(
                snapshotProperties.m_pwszSnapshotDeviceObject, 
                options.get_Source(),
                wszVolumePathName, 
                wszSource
                );

            OutputWriter::WriteLine(TEXT("Calling DefineDosDevice to mount device.")); 
            if (0 == wszSource.Find(TEXT("\\\\?\\GLOBALROOT")))
            {
                wszSource = wszSource.Mid(_tcslen(TEXT("\\\\?\\GLOBALROOT")));
            }
            bWorked = DefineDosDevice(DDD_RAW_TARGET_PATH, options.get_Device(), wszSource); 
            if (!bWorked)
            {
                DWORD error = ::GetLastError(); 
                CString errorMessage; 
                Utilities::FormatErrorMessage(error, errorMessage); 
                CString message; 
                message.AppendFormat(TEXT("There was an error calling DefineDosDevice when mounting a device. Error: %s"), errorMessage); 
                throw new CShadowSpawnException(message.GetString()); 
            }
            mountedDevice = options.get_Device();

            STARTUPINFO startUpInfo;
            memset(&startUpInfo, 0, sizeof(startUpInfo));
            startUpInfo.cb = sizeof(startUpInfo);

            PROCESS_INFORMATION processInformation;
            size_t commandLength = options.get_Command().size();
            wchar_t* copyCommand = (wchar_t*)_alloca((commandLength+1)*sizeof(wchar_t));
            options.get_Command().copy(copyCommand, commandLength);
            copyCommand[commandLength] = L'\0';

            message.Format(TEXT("Launching command: %s"), options.get_Command().c_str());
            OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); 
            bWorked = CreateProcess(NULL, copyCommand, NULL, NULL, FALSE, 0, NULL, 
                                    NULL, &startUpInfo, &processInformation);
            if (!bWorked)
            {
                DWORD error = ::GetLastError(); 
                CString errorMessage; 
                Utilities::FormatErrorMessage(error, errorMessage); 
                CString message; 
                message.AppendFormat(TEXT("There was an error calling CreateProcess. Process: %s Error: %s"), 
                    options.get_Command().c_str(), errorMessage); 
                throw new CShadowSpawnException(message.GetString()); 
            }

            WaitForSingleObject(processInformation.hProcess, INFINITE);

            bWorked = GetExitCodeProcess(processInformation.hProcess, &exitCode);
            if (!bWorked)
            {
                DWORD error = ::GetLastError(); 
                CString errorMessage; 
                Utilities::FormatErrorMessage(error, errorMessage); 
                CString message; 
                message.AppendFormat(TEXT("There was an error calling GetExitCodeProcess. Error: %s"), errorMessage); 
                throw new CShadowSpawnException(message.GetString()); 
            }
开发者ID:EntityReborn,项目名称:shadowspawn,代码行数:66,代码来源:ShadowSpawn.cpp


注:本文中的COptions::get_Command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。