C ++ Processentry32

时间:2016-07-02 16:13:00

标签: c++ char wchar

请帮忙。

PROCESSENTRY32 entry; if (!strcmp(entry.szExeFile, process))

输入错误:WCHAR *类型的参数与const char *类型的参数不兼容

请不要恨我,我是初学者。

感谢您的帮助;)

1 个答案:

答案 0 :(得分:1)

您在某处或项目设置中的代码中定义了UNICODE。

所以PROCESSENTRY32是unicode版本,但你使用strcmp的ASCII版本

解决方案是使用其他功能

#include <wchar.h>
...
if (!wcscmp(entry.szExeFile, process))

或仅限Windows(WinApi函数)

#include <windows.h>
...
if (!lstrcmpW(entry.szExeFile, process))

请注意, process 变量必须是wchar_t *或LPWSTR类型。

例如:

#include <windows.h>
....

    wchar_t process[] = L"browser.exe"
    ...
    if (!lstrcmpW(entry.szExeFile, process))
相关问题