鉴于某些注册表值的关键(例如HKEY_LOCAL_MACHINE\blah\blah\blah\foo)我该如何:
我绝对没有打算将任何东西写回注册表(如果我可以提供帮助的话,我的职业生涯期间).因此,如果我错误地写入注册表,我们可以跳过关于我体内每个分子以光速爆炸的讲座.
首选C++中的答案,但大多只需要知道特殊的Windows API咒语是什么.
假设有类似的东西:
void mask_bytes(unsigned char* dest, unsigned char* src, unsigned char* mask, unsigned int len)
{
unsigned int i;
for(i=0; i<len; i++)
{
dest[i] = src[i] & mask[i];
}
}
Run Code Online (Sandbox Code Playgroud)
通过编写类似下面的内容,我可以更快地在非对齐访问机器(例如x86)上运行
void mask_bytes(unsigned char* dest, unsigned char* src, unsigned char* mask, unsigned int len)
{
unsigned int i;
unsigned int wordlen = len >> 2;
for(i=0; i<wordlen; i++)
{
((uint32_t*)dest)[i] = ((uint32_t*)src)[i] & ((uint32_t*)mask)[i]; // this raises SIGBUS on SPARC and other archs that require aligned access.
}
for(i=wordlen<<2; i<len; i++){ …
Run Code Online (Sandbox Code Playgroud) 我编写了一个函数,试图通过管道读取子进程的命令行输出.这应该是MSDN创建具有重定向输入和输出的子进程的一个简单子集,但我显然是在做某种错误.
无论是在WaitForSingleObject(...)调用之前还是之后将ReadFile(...)调用放在子进程结束时,下面的ReadFile(...)调用都会永久阻塞.
我已经阅读了所有建议"使用异步ReadFile"的答案,如果有人能让我知道如何在管道上完成,我对这个建议持开放态度.虽然我不明白为什么在这种情况下需要异步I/O.
#include "stdafx.h"
#include <string>
#include <windows.h>
unsigned int launch( const std::string & cmdline );
int _tmain(int argc, _TCHAR* argv[])
{
launch( std::string("C:/windows/system32/help.exe") );
return 0;
}
void print_error( unsigned int err )
{
char* msg = NULL;
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msg,
0, NULL );
std::cout << "------ Begin Error Msg ------" << std::endl;
std::cout << msg << std::endl;
std::cout << "------ End Error Msg ------" << std::endl;
LocalFree( …
Run Code Online (Sandbox Code Playgroud) 如何确定哪个特定工具选择为"cxx_compiler"等?免责声明:
def configure(ctx):
print('Running ' + ctx.cmd + ' in ' + ctx.path.abspath() )
ctx.load('compiler_c')
ctx.load('compiler_cxx')
def build(ctx):
print('Running ' + ctx.cmd + ' in ' + ctx.path.abspath() )
# Here print which C++ compiler was chosen
print 'Building cpp files with %s' % WHAT_GOES_HERE
Run Code Online (Sandbox Code Playgroud)