1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
fileHandle = CreateFile(ImagePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (fileHandle == INVALID_HANDLE_VALUE)
{
printf("Error CreateFile: %d\n", GetLastError());
}
DWORD dwFileSize = GetFileSize(fileHandle, NULL);
if (dwFileSize <= 0)
{
printf("Error filesize\n");
}
else
{
printf("Filesize: %d\n", dwFileSize);
char *szBuf = new char[dwFileSize + 1];
DWORD dwBytes = 0;
if (!ReadFile(fileHandle, szBuf, dwFileSize, &dwBytes, NULL))
{
printf("Readfile failed: %d\n", GetLastError());
}
else
{
printf("sizeof read: %d, nbtoread: %d\n", sizeof(szBuf) / sizeof(szBuf[0]), dwFileSize);
printf("file: %s\n", szBuf);
string filecontent = string(szBuf);
printf("filecontent %s\n", filecontent); |
Partager