我是编码新手,我不太确定如何解决这个问题。错误如下:
错误 C2664: 'BOOL GetVolumeInformationA(LPCSTR,LPSTR,DWORD,LPDWORD,LPDWORD,LPDWORD,LPSTR,DWORD)': 无法将参数 7 从 'TCHAR (*)[261]' 转换为 'LPSTR'
只想要一个关于如何解决这个问题的明确答案以及我做错了什么的解释。太感谢了!
我遇到问题的部分:
TCHAR volumeName[MAX_PATH + 1] = { 0 };
TCHAR fileSystemName[MAX_PATH + 1] = { 0 };
DWORD serialNumber = 0;
DWORD maxComponentLen = 0;
DWORD fileSystemFlags = 0;
if (GetVolumeInformation(_T("C:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, &fileSystemName, ARRAYSIZE(fileSystemName)));
我的源代码是:
#include <Windows.h>
#include <iostream>
#include <stdlib.h>
#include <tchar.h>
#include <intrin.h>
#include <algorithm>
#include <TlHelp32.h>
#include <string>
#include <vector>
void setcolor(unsigned short color)
{
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon, color);
}
using namespace std;
vector<string> serial;
void loadserial()
{
serial.push_back("HWIDS");
serial.push_back("HWIDS");
serial.push_back("HWIDS");
}
int main()
{
loadserial();
setcolor(10);
std::cout << "Checking Whitelist...\n";
Sleep(240);
TCHAR volumeName[MAX_PATH + 1] = { 0 };
TCHAR fileSystemName[MAX_PATH + 1] = { 0 };
DWORD serialNumber = 0;
DWORD maxComponentLen = 0;
DWORD fileSystemFlags = 0;
if (GetVolumeInformation(_T("C:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, &fileSystemName, ARRAYSIZE(fileSystemName)));
while (true)
{
if (find(serial.begin(), serial.end(), to_string(serialNumber)) != serial.end())
{
std::cout << "Whitelisted\n";
Sleep(2000);
setcolor(15);
system("cls");
SetConsoleTitle("Loading Cheat...");
setcolor(15);
std::cout << "Loading...\n";
Sleep(100);
std::cout << "Loading (25%)\n";
Sleep(200);
std::cout << "Loading (50%)\n";
Sleep(200);
std::cout << "Loading (75%)\n";
Sleep(200);
std::cout << "Loading (100%)\n";
Sleep(200);
std::cout << "Done!\n";
Sleep(1000);
system("cls");
SetConsoleTitle("Affinity");
setcolor(5);
setcolor(5);
std::cout << "Welcome to Affinity\n";
std::cout << "_________________\n";
setcolor(12);
std::cout << "\n";
std::cout << "Pick Your Hack: \n";
setcolor(10);
std::cout << "Wallhacks: F5\n";
setcolor(3);
std::cout << "Bunnyhop: F6\n";
setcolor(9);
std::cout << "Radar: F7\n";
setcolor(5);
std::cout << "Exit: F8\n";
std::cout << "\n";
while (true)
{
if (GetAsyncKeyState(VK_F5))
{
std::cout << "next episode\n";
Sleep(200);
}
if (GetAsyncKeyState(VK_F6))
{
std::cout << "next episode\n";
Sleep(200);
}
if (GetAsyncKeyState(VK_F7))
{
std::cout << "next episode\n";
Sleep(200);
}
if (GetAsyncKeyState(VK_F8))
{
std::cout << "Closing\n";
Sleep(200);
system("cls");
std::cout << "Closing..\n";
Sleep(200);
system("cls");
std::cout << "Closing...\n";
Sleep(200);
system("cls");
std::cout << "Closing..\n";
Sleep(200);
system("cls");
std::cout << "Closing.\n";
Sleep(200);
system("cls");
std::cout << "Closing..\n";
Sleep(200);
system("cls");
std::cout << "Closing...\n";
Sleep(200);
system("cls");
exit(0);
}
}
}
else
{
setcolor(12);
SetConsoleTitle("You're Not On The Whitelist ;(");
std::cout << "You're not on the whitelist.\n";
std::cout << "Your Serial/HWID is:";
std::cout << serialNumber << std::endl;
Sleep(15000);
exit(0);
}
}
}