Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Please help me

Posted on 1998-10-01
1
Medium Priority
?
193 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 30 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.
Suggested Courses

715 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