你好我正在创建一个文件加密代码我读取一个文件,我需要将我正在读取的文件转换为 BYTE* 我尝试搜索但每次我得到"CL.exit"
。这就是我阅读文件的方式。
HANDLE getFile = createFile();
DWORD reciveBytes = 0;
//If it's byte or kilobyte the size of the buffer will be 1024.
//If it's megabytes or gigabyte the size of the buffer will be 4096.
const DWORD Buffersize = 66232; // gave me warning for 1024
DWORD buffer[Buffersize];
string fileInput;
if (ReadFile(
getFile,
buffer,
Buffersize,
&reciveBytes,
NULL
)) {
}
else {
cout << "Faild!" << endl;
cout << GetLastError() << endl;
}
/*
for (unsigned int i = 0; i < reciveBytes; i++) {
if (buffer[i] != '\0') {
fileInput = fileInput + buffer[i];
}
}
*/
return buffer[reciveBytes];
现在,我需要做的是将返回类型转换为 BYTE*,这样我就可以执行以下操作: BYTE* protect = (BYTE*)"Hello world!";
这是 createFile():
HANDLE getFile = CreateFileA(
fileName,
GENERIC_READ,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);