Solved

Please help me

Posted on 1998-10-01
1
189 Views
Last Modified: 2010-04-01
I would like to find the media id of a compact disc
anyone can help???
0
Comment
Question by:Tonyleung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
roaknog earned 10 total points
ID: 1174254
#define VWIN32_DIOC_DOS_IOCTL 1

#include <windows.h>
#include <fstream.h>//for ofstream

//DECLARE SOME VARIABLES
      UINT nDrive = 4; //for cd drive d
      HANDLE hDevice;
      BOOL fResult;
      DWORD cb;
      char hexarray[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
      DWORD hfst, hscd, htrd, hfth, lfst, lscd, ltrd, lfth;

      typedef struct _midSN {
            WORD SNHighPart;
            WORD SNLowPart;
      } midSN;


      typedef struct _MID
      {
            WORD midInfoLevel;
            midSN midSerialNum;
            BYTE midVolLabel[11];
            BYTE midFileSysType[8];
      } MID, *PMID;

      MID mid;
      PMID pmid = &mid;

      typedef struct _DEVICEIOCTL_REGISTETRS
      {
            DWORD reg_EBX;
            DWORD reg_EDX;
            DWORD reg_ECX;
            DWORD reg_EAX;
            DWORD reg_EDI;
            DWORD reg_ESI;
            DWORD reg_Flags;
      } DEVIOCTL_REGISTERS, *PDEVIOCTL_REGISTERS;


void main()
      {
      DEVIOCTL_REGISTERS roakreg;
      PDEVIOCTL_REGISTERS preg = &roakreg;
      roakreg.reg_EAX = 0x440D;
      roakreg.reg_EBX = nDrive;
      roakreg.reg_ECX = 0x866;
      roakreg.reg_EDX = (DWORD)pmid;
      roakreg.reg_Flags = 0x8000;


// GET HANDLE
      hDevice = CreateFile("\\\\.\\vwin32",
            0,
            0,
            NULL,
            0,
            FILE_FLAG_DELETE_ON_CLOSE,
            NULL);

      fResult = DeviceIoControl(hDevice,
            VWIN32_DIOC_DOS_IOCTL,
            &roakreg,
            sizeof(roakreg),
            &roakreg,
            sizeof(roakreg),
            &cb,
            0);

//CLOSE HANDLE
      CloseHandle(hDevice);

//convert serial number to hex
      hfst = mid.midSerialNum.SNHighPart/4096;
      hscd = (mid.midSerialNum.SNHighPart-(hfst*4096))/256;
      htrd = (mid.midSerialNum.SNHighPart-(hfst*4096)-(hscd*256))/16;
      hfth = (mid.midSerialNum.SNHighPart-(hfst*4096)-(hscd*256)-(htrd*16));
      lfst = mid.midSerialNum.SNLowPart/4096;
      lscd = (mid.midSerialNum.SNLowPart-(lfst*4096))/256;
      ltrd = (mid.midSerialNum.SNLowPart-(lfst*4096)-(lscd*256))/16;
      lfth = (mid.midSerialNum.SNLowPart-(lfst*4096)-(lscd*256)-(ltrd*16));

//OUTPUT
      ofstream q("c:\\temp\\dioc.doc");
      q << "cb = " << cb << 
            ".\vhDevice = " << hDevice << 
            ".\v(HANDLE)INVALID_HANDLE_VALUE = " << (HANDLE)INVALID_HANDLE_VALUE << 
            ".\vfResult = " << fResult << 
            ".\vVWIN32_DIOC_DOS_IOCTL = " << VWIN32_DIOC_DOS_IOCTL <<
            ".\vnDrive = " << nDrive <<
            ".\vmid.midInfoLevel = " << mid.midInfoLevel <<
            ".\vWORD mid.midSerialNum.SNHighPart = " << mid.midSerialNum.SNHighPart <<
            ".\vWORD mid.midSerialNum.SNLowPart = " << mid.midSerialNum.SNLowPart <<
            ".\v&mid.midSerialNum.SNHighPart = " << &mid.midSerialNum.SNHighPart <<
            ".\v&mid.midSerialNum.SNLowPart = " << &mid.midSerialNum.SNLowPart <<
            ".\vhexadecimal mid.midSerialNum.SNHighPart = " << hexarray[hfst] << hexarray[hscd] << hexarray[htrd] << hexarray[hfth] <<
            ".\vhexadecimal mid.midSerialNum.SNLowPart = " << hexarray[lfst] << hexarray[lscd] << hexarray[ltrd] << hexarray[lfth] <<
            ".\vThe Serial Number is: " << hexarray[lfst] << hexarray[lscd] << hexarray[ltrd] << hexarray[lfth] << "-" << hexarray[hfst] << hexarray[hscd] << hexarray[htrd] << hexarray[hfth] <<
            ".\vmid.midVolLabel = " << mid.midVolLabel <<
            ".\vmid.midFileSysType = " << mid.midFileSysType <<
            ".\vmid->pmidInfoLevel = " << pmid->midInfoLevel <<
            ".\vmid->pmidVolLabel = " << pmid->midVolLabel <<
            ".\vmid->pmidFileSysType = " << pmid->midFileSysType <<
            ".\v(DWORD) pmid = " << (DWORD)pmid <<
            ".\vroakreg.reg_EDX = (DWORD) pmid = " << roakreg.reg_EDX  <<
            ".\vroakreg.reg_EBX = nDrive = " << roakreg.reg_EBX <<
            ".\vroakreg.reg_ECX = 0x866 = " << roakreg.reg_ECX <<
            ".\vroakreg.reg_Flags = 0x8000 = " << roakreg.reg_Flags <<
            ".\vroakreg.reg_EAX = " << roakreg.reg_EAX <<
            ".\v";

      cout << "\n     This program gets the media id of a cd at drive D:\\!\n\n     Function 440Dh of interrupt 21h is used!\n\n     The information is put into file c:\\temp\\dioc.doc!\n\n     This is not to be confused with the media in the FAT!\n\n     To get the media you could use function 1h of interrupt 25\n\n     with a boot structure, or offset 15h of a buffer!\n\n     (C) 1998 Inniea Publishing Company ROAK NOG!\n\n     ";
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question