|
Just a guess: Open drive, read sector 1, cylinder 0.....
|
|
|
|
|
Nope.
I found it late yesterday. In the hardware SDK using DeviceIoControl(), however at the moment I am getting access errors, but I am sure I will get around those. Thanks for your help.
|
|
|
|
|
hDevice = CreateFile(disks[DriveNum].name, /* Open the argument drive */
GENERIC_READ|GENERIC_WRITE, /* Read-only access required */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* Shared read access */
NULL, /* Default security attributes */
OPEN_EXISTING, /* Disposition */
0, /* File attributes */
NULL); /* Don't copy any file's attributes */
if (hDevice == INVALID_HANDLE_VALUE)
memset(&scip, 0, sizeof(scip));
memset(IdOutCmd, 0, sizeof(IdOutCmd));
scip.cBufferSize = IDENTIFY_BUFFER_SIZE;
scip.irDriveRegs.bFeaturesReg = 0;
scip.irDriveRegs.bSectorCountReg = 1;
scip.irDriveRegs.bSectorNumberReg = 1;
scip.irDriveRegs.bCylLowReg = 0;
scip.irDriveRegs.bCylHighReg = 0;
//
// Compute the drive number.
//
scip.irDriveRegs.bDriveHeadReg = 0xA0;
//
// The command can either be IDE identify or ATAPI identify.
//
scip.irDriveRegs.bCommandReg =
(VersionParams.bIDEDeviceMap & 0x10) ? \
IDE_ATAPI_ID : IDE_ID_FUNCTION;
if( IDE_ATAPI_ID == scip.irDriveRegs.bCommandReg) {
LogMessage1("%s : ATAPI device",disks[DriveNum].name);
}
scip.bDriveNumber = 0;
scip.cBufferSize = IDENTIFY_BUFFER_SIZE;
if ( DeviceIoControl(hDevice, DFP_RECEIVE_DRIVE_DATA,
(LPVOID)&scip, sizeof(SENDCMDINPARAMS) - 1,
(LPVOID)&IdOutCmd, sizeof(SENDCMDOUTPARAMS) + IDENTIFY_BUFFER_SIZE - 1,
&cbBytesReturned, NULL) )
{
IDSECTOR *pids=(IDSECTOR *)((SENDCMDOUTPARAMS *)IdOutCmd)->bBuffer;
ChangeByteOrder(pids->sModelNumber, sizeof pids->sModelNumber);
memset(disks[DriveNum].model,0,sizeof(disks[DriveNum].model));
strncpy(disks[DriveNum].model,pids->sModelNumber,sizeof pids->sModelNumber);
/* Strip trailing whitespace from model number */
for(j=strlen(disks[DriveNum].model) ; (j>0) && isspace(disks[DriveNum].model[j-1]) ; j--);
disks[DriveNum].model[j]=0;
DriveSize=pids->ulTotalAddressableSectors;
}
|
|
|
|
|
where device
_snprintf(disks[DriveNum].name,sizeof(disks[DriveNum].name),"\\\\.\\PhysicalDrive%d",DriveNum);
|
|
|
|
|
It was the second parameter to CreateFile() that was giving the access problems, I have got it now, its easier to do this:
<snippet>
PARTITION_INFORMATION pti;
hDevice = CreateFile("\\\\.\\c:",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
bResult = DeviceIoControl(hDevice,
IOCTL_DISK_GET_PARTITION_INFO,
NULL, 0,
pti, sizeof(*pti),
&junk,
(LPOVERLAPPED) NULL);
if (bResult)
{
switch(pdi.PartitionType)
{
case PARTITION_LDM:
AfxMessageBox("Dynamic Drive Detected");
break;
case PARTITION_EXTENDED:
AfxMessageBox("Extended Partition Detected");
break;
case PARTITION_FAT32:
AfxMessageBox("FAT32 partiton Detected");
break;
case PARTITION_FAT_16:
AfxMessageBox("FAT16 partition Detected");
break;
default:
AfxMessageBox("None detected");
}
}
Just a note though. The doco says that PARTITION_INFORMATION and IOCTL_DISK_GET_PARTITION_INFO is obsolete, so you need to use the latest versions, however, this is fine for what we are doing.
|
|
|
|
|
Ok I wish to emulate the functionality that Windows Explorer uses when you select the Folders Explorer bar. I've used Spy++ and learned that the main Rebar sits ontop of a blank window (called BaseClass I think...?) within the rebar there are two other child windows: 1 to the ToolBar X button and the other is the Treeview window. Does anybody know how to achieve this?
Any help would be nice and appreciated. Thank you.
Ryan
|
|
|
|
|
|
#define INSTANCES 3 <br />
<br />
char FrameTitles[INSTANCES][]={"LineSync","DoorClosed","DoorLocked"};
I do this in Mainfrm.h . What is wrong here and why are these errors coming ?
<br />
:\Application_dev\SamplerApp\MainFrm.h(16) : error C2087: '<Unknown>' : missing subscript<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'LineSync' : array bounds overflow<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'DoorClosed' : array bounds overflow<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'DoorLocked' : array bounds overflow<br />
SamplerApp.cpp<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2087: '<Unknown>' : missing subscript<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'LineSync' : array bounds overflow<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'DoorClosed' : array bounds overflow<br />
C:\Application_dev\SamplerApp\MainFrm.h(16) : error C2117: 'DoorLocked' : array bounds overflow
|
|
|
|
|
You can't have jagged arrays in C. Try this:
char* FrameTitles[INSTANCES] = { "lineSync", "DoorClosed", "DoorLocked" }; And if you do that you can drop the INSTANCES constant as well.
--Mike--
PROCRASTINATION: Hard work often pays off after time, but laziness always pays off now.
BUY MY SOFTWARE!! (please?) RightClick-Encrypt | 1ClickPicGrabber
My IntarWeb Homepgae!!!11
|
|
|
|
|
I am trying to write a device install program to get around the problem of xp sp1 installing a driver that i do not wish to use. The ftdi usb-serial device has an approved driver in sp1 that is installed when the device is plugged in.
In order to install the device you must cancel the driver request from windows, go to device manager, and manually update the driver xp installed.
I have played with SetupCopyOEMInf(), UpdateDriverForPlugAndPlayDevices() and calling "rundll32 SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 c:\temp\drivers\ftd2xx.inf" with no real success.
Is there any way to automate the manual install process?
Cheers,
Dave
|
|
|
|
|
Hi all - new here, first post on CodeProject;
My simple, bottom line question : Is there a way to *reliably* install and *use* JUST THE GDI+ functionality from the Platform SDK CD (FEB 2001); without installing the entire Platform SDK? (feedback on a couple of the tutorials implies that there are problems with trying to JUST extract GDI+).
OR: If I *have* to install the Feb 2001 Platform SDK, please see "gotcha's" noted further down - I need advice on installing the Platform SDK (but again I'd rather not IF I can just extract the GDI+ stuff).
I've read a couple of the GDI+ tutorials here and now I am interested....
More detail / background ("experts" please read this, and "READ BETWEEN the LINES" and offer any advice you deem appropriate): I have Visual C++ 6 Professional Edition, Service Pack 5, the Processor Pack/MASM (which I'm thinking about NOT installing after my next HD reformat; I simply can't think of a good use for the Processor Pack and I haven't used assembly in quite a while); and I am using the MSDN Library OCT 2001 (my subscription ran out about a year after that, but for certain reasons I am sticking with OCT 2001 / and the MSDN->Web based Library - at present I am NOT getting into .NET); in addition to installing the simple one-CD MSDN Library that comes with VC+6.
MOST of my C++ experience has been with OLD DOS compilers (Borland C++ 3.0); on occasion I have played with Visual C++ using the WROX books as a guide, working my way through the tutorials. My experience with VC+6 should be considered : "Intimidated Beginner".
Platform SDK Gotchas: a long time ago (a couple of HD reformats ago) I ordered the Platform SDK (Feb2001); installed it ; it CRIPPLED my VC+6 installation (mainly DirectX SDK, but I am sure there where other "gotchas" waiting...). Apparantly the Platform SDK installs from DX 8.0a stuff (presently I am using DirectX *9* runtimes!). I stopped using the DirectX SDK a long time ago; got tired of re-learning it every time a new DX SDK came out.
After reading the beginners GDI+ tutorial here, I extracted the GDI+ stuff from the Platform SDK to examine it; they have peculiar names after extracting (and there are TWO .LIB files in there, I assume the larger of the two is a debug LIB). I need step-by-step instructions... ALSO reading the Platform SDK ReadMe implies that installing the entire Platform SDK MIGHT interfere with my computer (WinME, presently using DirectX *9* runtimes - again, I stopped messing with the DX SDK some time ago).
Also - apparantly there is an updated GDI+ DLL on Microsoft MSDN download (?) - is it safe / advised to use that newer DLL in conjunction with the FEB 2001 material (.LIB, *.h etc)?
Basically : I want to work my way through the GDI+ tutorials here; I want to install JUST GDI+ functionality WITHOUT installing the FEB 2001 Platform SDK CD if I can - the simplest and most trouble-free approach.
-Thanks
-JeffBAbil
|
|
|
|
|
I have never had problems with the Platform SDK. It don't change anything with your DirectX, because it only contains the header/lib-files, not the binary ones.
I really don't think you can use GDI+ without installing the Platform SDK, and there's a lot of other new stuff you can't use either, then.
IMHO it's hard to do any Windows development without installing the Platform SDK, the headerfiles included in your VC6 installation are old.... From 1996 or something.... Lot of stuff have changed since then.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
MS in their wisdom no longer supports devlopment on any 9x OS, so don't bother installing the Platform SDK as it won't work. Not that it's broken on 9x, MS just won't let you.
--Mike--
PROCRASTINATION: Hard work often pays off after time, but laziness always pays off now.
BUY MY SOFTWARE!! (please?) RightClick-Encrypt | 1ClickPicGrabber
My IntarWeb Homepgae!!!11
|
|
|
|
|
Michael Dunn wrote:
MS in their wisdom no longer supports devlopment on any 9x OS
I knew that for .NET and VS.NET, but don't the platform SDK work on Win9x anymore?
Hmmm, fortunately I have not used Win9x as platform for development, only for testing, since NT4 was released
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
|
Is there any easy way to determine the number of columns a CListCtrl has?
I have a base class function that iterates through derived class list controls, saving all the data. I can't see anything in the CListCtrl class that would indicate how many columns are being used in the control!
Any ideas?
|
|
|
|
|
If the control is in report mode, you can get the header control and call GetItemCount:
int a_iColumns = GetHeaderCtrl()->GetItemCount();
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
|
Thanks to everyone!
I knew it would be simple, I just couldn't find it. I opted for a quick and "dirty" approach of keeping track of it with an array of ints (yuk). I'll switch to GetItemCount now.
|
|
|
|
|
You can retrive it from the associated header control.
e.g.
CListCtrl m_lstItems;
int nNumCols = m_lstItems.GetHeaderCtrl()->GetItemCount();
Dave
|
|
|
|
|
Maybe i should refresh more often...
Dave
|
|
|
|
|
I'm set up to load every page... Of course DSL makes that an easy choice!
|
|
|
|
|
All I need are two buttons that have an up arrow and a down arrow. I looked at CBitmapButton class but I dont need it to look different when pressed etc. If I could just draw on a regular button - thats all I need.
So I am looking at the spinbutton ctrl. I dont need the autobuddy stuff, just access to a function that fires if I press the up arrrow, and a different one for the down arrow of the spinbutton ctrl.
If neither of these is suitable, I can just write the text "Up" and "down" on my regular old buttons ,,,,it just wont look so cool........
Suggestions?
Appreciate your help,
ns
|
|
|
|
|
Well, the spin button control sends a WM_VSCROLL message when you click on the arrows (if it's vertically aligned). Also the MSDN says it sends a UDN_DELTAPOS message, but I've never used that before. So, hook up a handler for WM_VSCROLLL and look for SB_LINEUP and SB_LINEDOWN or SB_PAGEUP and SB_PAGEDOWN (can't remember which ones are sent by the spin button).
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
|