如何解决错误C2664:“ wcscmp”:无法将参数1从“ CHAR [260]”转换为“ const wchar_t *”
我有可以在vs2019上运行的代码
#include <stdio.h>
#include <winsock2.h>
#include <iostream>
#include <tlhelp32.h>
#include <wchar.h>
#include <atlstr.h>
#include <windows.h>
PROCESSENTRY32 pe32 = { 0 };
HANDLE hSnap;
int iDone;
int iTime = 60;
bool bProcessFound;
using namespace std;
int x = 1;
int i = 0;
int main() {
system("cmd /C \"\"C:\\Windows\\System32\\tool.exe\"\"");
/*WinExec("cmd /C \"\"C:\\Windows\\System32\\tool.exe\"\"",SW_HIDE);*/
Sleep(1000);
/*for (i = 0; i < x; i++) {
Sleep(1000);
cout << i << "\n";
x++;
if (i == 10) i = 0;
}*/
while (true) // go forever
{
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
pe32.dwSize = sizeof(PROCESSENTRY32);
Process32First(hSnap,&pe32); // Can throw away,never an actual app
bProcessFound = false; //init values
iDone = 1;
while (iDone) // go until out of Processes
{
iDone = Process32Next(hSnap,&pe32);
if (wcscmp(pe32.szExeFile,CString("tool.exe")) == 0) // Did we find our process?
{
bProcessFound = true;
iDone = 0;
cout << "process found" << "\n";
}
}
if (!bProcessFound) // if we didn't find it running...
{
cout << "process not found" << "\n";
}
Sleep(iTime * 500); // delay x amount of seconds.
}
}
但是当我放入并使用旧版本的vs(2003版)进行编译时,出现此错误
错误C2664:'wcscmp':无法将参数1从'CHAR [260]'转换为'const wchar_t *';所指向的类型无关。转换需要reinterpret_cast,C样式转换或函数样式转换
我该怎么办?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。