简体   繁体   English

没有重载函数“”的实例与参数列表错误匹配

[英]no instance of overloaded function “” matches the argument list error

I'm Getting the following errors in my cpp and I'm not quite sure how to fix them (I'm new to C++) 我在cpp中遇到以下错误,但我不确定如何解决(我是C ++的新手)

Errors: 错误:

Severity    Code    Description Project File    Line    Suppression State
Error (active)      no instance of overloaded function "std::basic_string<_Elem, _Traits, _Alloc>::compare [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" matches the argument list    KernelHop   c:\Users\Root\Downloads\KernelHop-master (1)\KernelHop-master\KernelHop\KernelHop.cpp   102 


Severity    Code    Description Project File    Line    Suppression State
Error (active)      no instance of overloaded function "std::basic_string<_Elem, _Traits, _Alloc>::compare [with _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" matches the argument list    KernelHop   c:\Users\Root\Downloads\KernelHop-master (1)\KernelHop-master\KernelHop\KernelHop.cpp   110 

My Code: 我的代码:

DWORD FindProcessId(const std::string processName)
{
    PROCESSENTRY32 processInfo;
    processInfo.dwSize = sizeof(processInfo);

    HANDLE processSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if (processSnapshot == INVALID_HANDLE_VALUE)
        return 0;

    Process32First(processSnapshot, &processInfo);
    if (!processName.compare(processInfo.szExeFile))
    {
        CloseHandle(processSnapshot);
        return processInfo.th32ProcessID;
    }

    while (Process32Next(processSnapshot, &processInfo))
    {
        if (!processName.compare(processInfo.szExeFile))
        {
            CloseHandle(processSnapshot);
            return processInfo.th32ProcessID;
        }
    }

    CloseHandle(processSnapshot);
    return 0;
}

Anyone know what I'm doing wrong? 有人知道我在做什么错吗?

You are probably compiling as Unicode, in which case PROCESSENTRY32::szExeFile will be a wide string ( wchar_t[] ), but std::string::compare() expects a byte string ( char[] ). 您可能正在使用Unicode进行编译,在这种情况下, PROCESSENTRY32::szExeFile将是一个宽字符串( wchar_t[] ),但std::string::compare()需要一个字节字符串( char[] )。 So try using std::wstring instead. 因此,请尝试使用std::wstring代替。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:多个重载函数实例与参数列表匹配 - Error: more than one instance of overloaded function matches argument list 错误没有重载函数的实例“getline”匹配参数列表c ++ - error no instance of overloaded function “getline” matches the argument list c++ 错误:多个重载函数实例与参数列表匹配 - Error: More than one instance of overloaded function matches the argument list 错误:没有重载函数“ mbed :: Ticker :: attach”的实例与参数列表匹配 - Error: No instance of overloaded function “mbed::Ticker::attach” matches the argument list KEIL错误:没有重载函数“ std :: transform”的实例与参数列表匹配 - KEIL error: no instance of overloaded function “std::transform” matches the argument list “没有重载函数“转换”的实例与参数列表匹配”并行执行时出错 - "no instance of overloaded function "transform" matches the argument list" error with parallel execution 错误没有重载的实例 function “getline” 与参数列表匹配 - Error No instance of overloaded function “getline” matches the argument list 没有重载函数findcontours的实例与参数列表匹配 - No instance of overloaded function findcontours matches the argument list 没有重载的实例 function “AfxBeginThread” 与参数列表匹配 - no instance of overloaded function "AfxBeginThread" matches the argument list 没有重载 function “strstr”实例与参数列表匹配 - no instance of overloaded function “strstr” matches the argument list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM