Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. I check, compile and run every program. Contact me at: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


6,846 questions

9,748 answers

573 users

How to get the size of a file in C Win32 API

1 Answer

0 votes
#include <stdio.h>
#include <windows.h> 

int main(void)
{
	HANDLE hFile;
	LPCWSTR fname = L"d:\\data.txt";
	DWORD dwFileSize;

	hFile = CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 
		                                                           FILE_ATTRIBUTE_NORMAL, 
																   NULL); 

	if (hFile == INVALID_HANDLE_VALUE)
		printf("Could not open %S file, error %d\n", fname, GetLastError());
	else
	{
		dwFileSize = GetFileSize(hFile, NULL);
		printf("%S size is %d bytes\n", fname, dwFileSize);
	}

	return 0;
}

/*
run:

d:\data.txt size is 5 bytes

*/

 




answered Jun 16, 2015 by avibootz
...