Hi,
Can anybody tell me how to access hard disk partition information or MBR content through Visual C++ Programming?
Suggest me how should i do programming and which API i should use for this purpose.
Bye.....

Re: how to access hard disk through visual C++ programming 80 80
Re: how to access hard disk through visual C++ programming 80 80

Hi,
Thanks for your reply. I got the very useful information.
Can i get any code samples regarding this hard disk access? please send, if any.

Thanks & Regards.

Re: how to access hard disk through visual C++ programming 80 80

I could, but I'd rather see how good you are at digging out information for yourself.
Try using the information, don't just thank me for it.

The only thing I would add is make sure you're testing this on a machine you don't mind trashing. You're only a few keystrokes away from "Damn, where are my install disks" because you've completely trashed your hard disk.

Re: how to access hard disk through visual C++ programming 80 80

Hi Salem,
I find out how to read hard disk programmatically in Visual C++ by using CreateFile and DeviceIoControl function.
But I am not able find the file vwin32.vxd in windows xp operating system for getting the disk information.
This vwin32.vxd will only exist in win9x series. so, is there any alternative for this in windows xp.
Please solve my problem.

Bye....

Re: how to access hard disk through visual C++ programming 80 80

http://msdn2.microsoft.com/en-us/library/aa363858.aspx
Then scroll down to "Physical Disks and Volumes"

The last time I tried this stuff, it worked "out of the box", without messing with a 9x driver.

Post a simple attempt which just opens/closes the physical device.

Re: how to access hard disk through visual C++ programming 80 80

Hi,
I found out some useful information from "Physical Disks and Volumes" but still i am not able to read data from hard disk sectors.

Bye...

Re: how to access hard disk through visual C++ programming 80 80

OK, getting bored of you saying "it doesn't work" and you NOT posting the code.
Since I'm not interested in playing 20 questions just to figure out which of many 1000's of possible mistakes you might have made, I'm done here.

Re: how to access hard disk through visual C++ programming 80 80

Hi Salem,
I need some help from you regarding the extended boot record.
May i know exactly where the EBR will be present? I found starting sector location of extended partition. I am expecting the EBR will present in this starting sector of Extended partition. But the last two bytes of that sector is not equal to 55 AA.
Then how could i know whether this sector is the one i m expecting as ebr? How could i know the exact location of EBR?
Please reply me as quickly as possible..........
Bye....

Re: how to access hard disk through visual C++ programming 80 80

The following piece of code works exactly as what you want to do, I use this method to write my own MBR boot loader code for booting into multiple OS selectively (holding Ctrl to boot into Ubuntu, holding Alt to boot into Window 98, otherwise boot into Window XP):

int		res;
	DWORD	nRead, nWritten;
	char	buf[4096];
	MSG		msg;
	HACCEL	hAccelTable;

	HANDLE hDisk = CreateFile("\\\\.\\PhysicalDrive0", GENERIC_READ | GENERIC_WRITE,
		FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
	res = SetFilePointer(hDisk, 0, 0, FILE_BEGIN);
	res = ReadFile(hDisk, buf, 512, &nRead, NULL);
	res = WriteFile(hDisk, buf, 512, &nWritten, NULL);
	CloseHandle(hDisk);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.