// Get size of file using only WinAPI
// By Ben 21:21 24/09/2016

#include <iostream>
#include <Windows.h>

using namespace std;
using std::cout;
using std::endl;

DWORD GetAFilesize(string Filename){
	HANDLE fh;
	wstring wFilename;
	DWORD fsize = 0;
	//Convert string to wide string
	wFilename = wstring(Filename.begin(), Filename.end());
	//Set  a handle to the file below.
	fh = CreateFile(wFilename.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,0,0);
	if (fh == INVALID_HANDLE_VALUE){
		return 0;
	}
	//Get filesize using files handle
	fsize = GetFileSize(fh, NULL);
	//Close file.
	CloseHandle(fh);
	//Return size
	return fsize;
}

int main(int argc, char *argv[]){
	SYSTEMTIME st;
	char *lzFile = "G:\\PRGMMING\\DOS\\BAS_LIBS\\AABAS.ZIP";
	//Fetch filesizze
	cout << "Filename    : " << lzFile << endl;
	cout << "Filesize    : " << GetAFilesize(lzFile) << endl;
	//Keep console open.
	system("pause");
	return 0;
}