Click here to Skip to main content
15,908,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problem with RegQueryValueEx Pin
Graham Bradshaw22-Dec-08 23:12
Graham Bradshaw22-Dec-08 23:12 
Questionmemset? Pin
dec8222-Dec-08 20:17
dec8222-Dec-08 20:17 
AnswerRe: memset? Pin
Paul M Watt22-Dec-08 20:46
mentorPaul M Watt22-Dec-08 20:46 
AnswerRe: memset? Pin
CPallini22-Dec-08 21:09
mveCPallini22-Dec-08 21:09 
AnswerRe: memset? Pin
toxcct22-Dec-08 21:37
toxcct22-Dec-08 21:37 
QuestionException in Multithreading.............. Pin
shaina223122-Dec-08 19:52
shaina223122-Dec-08 19:52 
QuestionRe: Exception in Multithreading.............. Pin
CPallini22-Dec-08 21:07
mveCPallini22-Dec-08 21:07 
QuestionFSCTL_GET_VOLUME_BITMAP Pin
john563222-Dec-08 19:10
john563222-Dec-08 19:10 
Hi all.

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);

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

		StartingLCN.StartingLcn.QuadPart=ullTmp*nBufferSize;
		Result = DeviceIoControl
			(
			hHandle,
			FSCTL_GET_VOLUME_BITMAP,
			&StartingLCN,
			nBufferSize,//sizeof (StartingLCN),
			Bitmap,
			nBufferSize,
			&BytesReturned,
			NULL
			);

		BitmapSize=BitmapSize-nBufferSize;

		
		}
	}

	return (true);
}

QuestionDrag and Drop between tree controls (Very Urgent........) Pin
AnithaSubramani22-Dec-08 18:32
AnithaSubramani22-Dec-08 18:32 
AnswerRe: Drag and Drop between tree controls (Very Urgent........) Pin
Hamid_RT22-Dec-08 19:09
Hamid_RT22-Dec-08 19:09 
QuestionProgramming time for algorithm? Anyone help me................. Pin
thuyphuongid22-Dec-08 16:46
thuyphuongid22-Dec-08 16:46 
AnswerRe: Programming time for algorithm? Anyone help me................. Pin
L. Madhavan22-Dec-08 19:41
L. Madhavan22-Dec-08 19:41 
Question[VC++6.0]Unhandled exception in **.exe, 0xc0000005:Access Vialation Pin
kaviniswell22-Dec-08 16:30
kaviniswell22-Dec-08 16:30 
AnswerRe: [VC++6.0]Unhandled exception in **.exe, 0xc0000005:Access Vialation Pin
Garth J Lancaster22-Dec-08 18:00
professionalGarth J Lancaster22-Dec-08 18:00 
GeneralRe: [VC++6.0]Unhandled exception in **.exe, 0xc0000005:Access Vialation Pin
kaviniswell22-Dec-08 18:18
kaviniswell22-Dec-08 18:18 
GeneralRe: [VC++6.0]Unhandled exception in **.exe, 0xc0000005:Access Vialation Pin
Garth J Lancaster22-Dec-08 18:27
professionalGarth J Lancaster22-Dec-08 18:27 
GeneralRe: [VC++6.0]Unhandled exception in **.exe, 0xc0000005:Access Vialation Pin
kaviniswell22-Dec-08 18:37
kaviniswell22-Dec-08 18:37 
QuestionCallback Intro Pin
codemunkeh22-Dec-08 15:45
codemunkeh22-Dec-08 15:45 
AnswerRe: Callback Intro Pin
CPallini23-Dec-08 3:05
mveCPallini23-Dec-08 3:05 
QuestionSetWindowSubclass is killing my app! Pin
KellyR22-Dec-08 14:17
KellyR22-Dec-08 14:17 
AnswerRe: SetWindowSubclass is killing my app! Pin
Naveen22-Dec-08 18:57
Naveen22-Dec-08 18:57 
GeneralRe: SetWindowSubclass is killing my app! Pin
KellyR22-Dec-08 19:19
KellyR22-Dec-08 19:19 
GeneralRe: SetWindowSubclass is killing my app! Pin
Mark Salsbery23-Dec-08 5:50
Mark Salsbery23-Dec-08 5:50 
QuestionVC Application with password Pin
sunny_vc22-Dec-08 13:38
sunny_vc22-Dec-08 13:38 
AnswerRe: VC Application with password Pin
Garth J Lancaster22-Dec-08 15:17
professionalGarth J Lancaster22-Dec-08 15:17 

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.