gpt4 book ai didi

c++ - 如何获取流程描述?

转载 作者:可可西里 更新时间:2023-11-01 11:59:25 25 4
gpt4 key购买 nike

我想在 Windows 中使用 C++ 获取进程的描述(在任务管理器中看到的描述)。

最佳答案

您很可能想从程序的主要 .exe 文件的版本资源中获取 FileDesription 字段,使用 VerQueryValue() API调用。这是该文档中的示例:

The following example shows how to enumerate the available version languages and retrieve the FileDescription string-value for each language.

Be sure to call the GetFileVersionInfoSize and GetFileVersionInfo functions before calling VerQueryValue to properly initialize the pBlock buffer.

// Structure used to store enumerated languages and code pages.

HRESULT hr;

struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;

// Read the list of languages and code pages.

VerQueryValue(pBlock,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslate,
&cbTranslate);

// Read the file description for each language and code page.

for( i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
{
hr = StringCchPrintf(SubBlock, 50,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
if (FAILED(hr))
{
// TODO: write error handler.
}

// Retrieve file description for language and code page "i".
VerQueryValue(pBlock,
SubBlock,
&lpBuffer,
&dwBytes);
}

关于c++ - 如何获取流程描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11843368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com