Click here to Skip to main content
15,897,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHoe to convert Hex string to Decimal String ? Pin
kapardhi23-Dec-08 19:00
kapardhi23-Dec-08 19:00 
AnswerRe: Hoe to convert Hex string to Decimal String ? Pin
Naveen23-Dec-08 20:48
Naveen23-Dec-08 20:48 
AnswerRe: Hoe to convert Hex string to Decimal String ? PinPopular
CPallini23-Dec-08 21:18
mveCPallini23-Dec-08 21:18 
GeneralRe: Hoe to convert Hex string to Decimal String ? Pin
Mark Salsbery25-Dec-08 7:13
Mark Salsbery25-Dec-08 7:13 
Questionsearching in outlook - where to start Pin
spicy_kid200023-Dec-08 18:41
spicy_kid200023-Dec-08 18:41 
AnswerRe: searching in outlook - where to start [modified] Pin
john563223-Dec-08 18:48
john563223-Dec-08 18:48 
GeneralRe: searching in outlook - where to start Pin
spicy_kid200023-Dec-08 19:25
spicy_kid200023-Dec-08 19:25 
QuestionFSCTL_GET_VOLUME_BITMAP [modified] Pin
john563223-Dec-08 18:04
john563223-Dec-08 18:04 
Hi all,

I have posted same question again, Nobody is responding me Please respond the query.

I uesd FSCTL_GET_VOLUME_BITMAP to get free cluster list but When bitmap is very large it can not be fit into buffer, So I tried to read the bitmap in small chunks of bytes but I am always getting the bitmap from startting 0 offset, How could I read bitmap in small chunks.

my code is here, Please correct if i am wrong

BOOL CFreeCluster::GetBitmap()
{
	STARTING_LCN_INPUT_BUFFER StartingLCN;
	VOLUME_BITMAP_BUFFER *Bitmap = NULL;
	ULONGLONG BitmapSize;
	DWORD BytesReturned;
	BOOL Result;

	StartingLCN.StartingLcn.QuadPart = 0;

	// Allocate buffer
	// Call FSCTL_GET_VOLUME_BITMAP once with a very small buffer
	// This will leave the total number of clusters in Bitmap->BitmapSize and we can
	// then correctly allocate based off that
	// I suppose this won't work if your drive has only 40 clusters on it or so :)
	BitmapSize = sizeof (VOLUME_BITMAP_BUFFER) + 4;
	Bitmap = (VOLUME_BITMAP_BUFFER *) malloc (BitmapSize);
	HANDLE hHandle=OpenDrive();

	Result = DeviceIoControl
		(
		hHandle,
		FSCTL_GET_VOLUME_BITMAP,
		&StartingLCN,
		sizeof (StartingLCN),
		Bitmap,
		BitmapSize,
		&BytesReturned,
		NULL
		);

	// Bad result?
	if (Result == FALSE  &&  GetLastError () != ERROR_MORE_DATA)
	{
		//wprintf ("\nDeviceIoControl returned false, GetLastError() was not ERROR_MORE_DATA\n");
		free (Bitmap);
		return (false);
	}

	// Otherwise, we're good
	//BitmapSize = sizeof (VOLUME_BITMAP_BUFFER) + (Bitmap->BitmapSize.QuadPart / 8) + 1;
	BitmapSize = (Bitmap->BitmapSize.QuadPart / 8) + 1;
	int nBufferSize=8*512*3;//3 cluster at a time
	ULONGLONG ullItr=BitmapSize/nBufferSize;
	
	if(BitmapSize%nBufferSize!=0)
		ullItr++;

	Bitmap = (VOLUME_BITMAP_BUFFER *) realloc (Bitmap, nBufferSize+1);

	ULONGLONG ullClusterNo=0;
	for (ULONGLONG ullTmp=0; ullTmp < ullItr; ullTmp++)
	{
		if(BitmapSize < nBufferSize)
			nBufferSize=BitmapSize;

		memset(Bitmap->Buffer,0x0,nBufferSize+1);
		StartingLCN.StartingLcn.QuadPart=ullTmp*nBufferSize;
		//Bitmap->StartingLcn.HighPart=ullTmp*nBufferSize;

		
		//StartingLCN.StartingLcn.LowPart=2560;//ullTmp*nBufferSize;
		//StartingLCN.StartingLcn.HighPart=2560+nBufferSize;//ullTmp*nBufferSize;
		//Bitmap->BitmapSize.LowPart=2560;
		
		//Bitmap->StartingLcn.QuadPart=ullTmp*nBufferSize;
		Result = DeviceIoControl
			(
			hHandle,
			FSCTL_GET_VOLUME_BITMAP,
			&StartingLCN,
			nBufferSize,//sizeof (StartingLCN),
			Bitmap,
			nBufferSize,
			&BytesReturned,
			NULL
			);
		int p=GetLastError();

		if (Result == FALSE  &&  GetLastError () != ERROR_MORE_DATA)
		{
			//wprintf ("\nDeviceIoControl returned false, GetLastError() was not ERROR_MORE_DATA\n");
			free (Bitmap);
			return (false);
		}

		BitmapSize=BitmapSize-nBufferSize;
       }

	return (true);
}


modified on Wednesday, December 24, 2008 12:18 AM

QuestionRe: FSCTL_GET_VOLUME_BITMAP Pin
john563223-Dec-08 19:56
john563223-Dec-08 19:56 
Questionhow to open .txt file using ShellExecute()? Pin
puppya23-Dec-08 17:26
puppya23-Dec-08 17:26 
AnswerRe: how to open .txt file using ShellExecute()? Pin
Richard Andrew x6423-Dec-08 17:46
professionalRichard Andrew x6423-Dec-08 17:46 
GeneralRe: how to open .txt file using ShellExecute()? Pin
puppya23-Dec-08 17:50
puppya23-Dec-08 17:50 
GeneralRe: how to open .txt file using ShellExecute()? Pin
john563223-Dec-08 18:30
john563223-Dec-08 18:30 
QuestionHow to set Icon to a CMFCToolBarButton Pin
N B sowmi23-Dec-08 17:21
N B sowmi23-Dec-08 17:21 
QuestionDrawing Inverse Rectangles Pin
Richard Andrew x6423-Dec-08 15:18
professionalRichard Andrew x6423-Dec-08 15:18 
AnswerRe: Drawing Inverse Rectangles Pin
bob1697223-Dec-08 16:45
bob1697223-Dec-08 16:45 
GeneralRe: Drawing Inverse Rectangles Pin
Richard Andrew x6423-Dec-08 17:18
professionalRichard Andrew x6423-Dec-08 17:18 
QuestionTo the regulars of forum 1647... (urgentz seasons greetings) Pin
Iain Clarke, Warrior Programmer23-Dec-08 10:01
Iain Clarke, Warrior Programmer23-Dec-08 10:01 
AnswerRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
CPallini23-Dec-08 10:09
mveCPallini23-Dec-08 10:09 
AnswerRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
Mark Salsbery23-Dec-08 10:23
Mark Salsbery23-Dec-08 10:23 
AnswerRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
Jijo.Raj23-Dec-08 11:22
Jijo.Raj23-Dec-08 11:22 
AnswerRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
john563223-Dec-08 21:31
john563223-Dec-08 21:31 
AnswerRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
Cedric Moonen23-Dec-08 21:52
Cedric Moonen23-Dec-08 21:52 
JokeRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
toxcct24-Dec-08 2:02
toxcct24-Dec-08 2:02 
GeneralRe: To the regulars of forum 1647... (urgentz seasons greetings) Pin
Iain Clarke, Warrior Programmer24-Dec-08 5:12
Iain Clarke, Warrior Programmer24-Dec-08 5:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.