I haven't heard of that particular IOCTL. By the way is is your program trying to send the device drivers IOCTL's?
Anyways here is a small app that can get this information using WMI.
I have not considered all errors in the sample below.
CODE
HRESULT GetWbemService(IWbemServices **pWbemService)
{
IWbemServices *pWbemServ = NULL;
IWbemLocator *pLoc = 0;
HRESULT hr;
hr = CoCreateInstance(CLSID_WbemLocator, 0,
CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hr))
{
cout << "Failed to create IWbemLocator object. Err code = 0x"
<< hex << hr << endl;
CoUninitialize();
return hr; // Program has failed.
}
// Connect to the root\default namespace with the current user.
hr = pLoc->ConnectServer(
BSTR(L"ROOT\\cimv2"),
NULL, NULL, 0, NULL, 0, 0, pWbemService);
if (FAILED(hr))
{
cout << "Could not connect. Error code = 0x"
<< hex << hr << endl;
pLoc->Release();
CoUninitialize();
return hr; // Program has failed.
}
return S_OK;
}
void InitCOM()
{
CoInitializeEx(0, COINIT_MULTITHREADED);
CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
}
void WMIQuery()
{
BSTR language = SysAllocString(L"WQL");
BSTR query = SysAllocString(L"Select * FROM Win32_DiskDrive");
// Other query otptions may be 1) Win32_LogicalDisk 2) Win32_DiskDrivePhysicalMedia
// Create querying object
IWbemClassObject *pObj = NULL;
IWbemServices *pServ = NULL;
IEnumWbemClassObject *pEnum = NULL;
HRESULT hRet;
if(FAILED(GetWbemService(&pServ))) { return; }
// Issue the query.
hRet = pServ->ExecQuery(
language,
query,
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, // Flags
0, // Context
&pEnum
);
SysFreeString(language);
SysFreeString(query);
if(FAILED(hRet)) { return; }
// Get the disk drive information
ULONG uTotal = 0;
// Retrieve the objects in the result set.
for (;;)
{
ULONG uReturned = 0;
hRet = pEnum->Next(
0, // Time out
1, // One object
&pObj,
&uReturned
);
uTotal += uReturned;
if (uReturned == 0)
break;
VARIANT val;
pObj->Get(L"Name", 0, &val, NULL, NULL);
wcout << "name: " << val.bstrVal << endl;
pObj->Release(); // Release objects not owned.
}
// All done.
pEnum->Release();
pServ->Release();
}
int main()
{
// Initialize COM
InitCOM();
WMIQuery();
CoUninitialize();
}