Click here to Skip to main content
15,925,723 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: i need help!!! please............. Pin
Martin Marvinski15-Jun-02 17:52
Martin Marvinski15-Jun-02 17:52 
GeneralRe: i need help!!! please............. Pin
Christian Graus15-Jun-02 18:00
protectorChristian Graus15-Jun-02 18:00 
GeneralRe: i need help!!! please............. Pin
Martin Marvinski15-Jun-02 18:52
Martin Marvinski15-Jun-02 18:52 
GeneralRe: i need help!!! please............. Pin
markkuk16-Jun-02 2:30
markkuk16-Jun-02 2:30 
GeneralLinking problem w/ Intel C++ Pin
15-Jun-02 13:39
suss15-Jun-02 13:39 
GeneralRe: Linking problem w/ Intel C++ Pin
Mike Nordell16-Jun-02 5:07
Mike Nordell16-Jun-02 5:07 
GeneralRe: Linking problem w/ Intel C++ Pin
16-Jun-02 11:52
suss16-Jun-02 11:52 
QuestionWhat causes the error "Incorrect function."? Pin
redeemer15-Jun-02 12:42
redeemer15-Jun-02 12:42 
When it comes to the "DeviceIoControl (hCD, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dgCDROM, sizeof(dgCDROM), &dwNotUsed, NULL)" function, the GetLastError returns 1, which is incorrect function, what is that?

code:


HANDLE  hCD, hFile;
DWORD   dwNotUsed;


hFile = CreateFile ("sector.dat",
                    GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
                    FILE_ATTRIBUTE_NORMAL, NULL);

hCD = CreateFile ("\\\\.\\D:", GENERIC_READ,
                  FILE_SHARE_READ|FILE_SHARE_WRITE,
                  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
                  NULL);

if (hCD != INVALID_HANDLE_VALUE)
{
   DISK_GEOMETRY         dgCDROM;
   PREVENT_MEDIA_REMOVAL pmrLockCDROM;

   pmrLockCDROM.PreventMediaRemoval = TRUE;
   DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
                    &pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
                    0, &dwNotUsed, NULL);

   if (DeviceIoControl (hCD, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dgCDROM, sizeof(dgCDROM), &dwNotUsed, NULL))
   {
      LPBYTE lpSector;
      DWORD  dwSize = 2 * dgCDROM.BytesPerSector;  // 2 sectors

      lpSector = (LPBYTE)VirtualAlloc (NULL, dwSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);

      SetFilePointer (hCD, dgCDROM.BytesPerSector * 16,
                      NULL, FILE_BEGIN);

      if (ReadFile (hCD, lpSector, dwSize, &dwNotUsed, NULL))
         WriteFile (hFile, lpSector, dwSize, &dwNotUsed, NULL);

      VirtualFree (lpSector, 0, MEM_RELEASE);
   }

   pmrLockCDROM.PreventMediaRemoval = FALSE;
   DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
                    &pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
                    0, &dwNotUsed, NULL);

   CloseHandle (hCD);
   CloseHandle (hFile);
}
r, true);

// Unlock the disc in the CD-ROM drive.
pmrLockCDROM.PreventMediaRemoval = FALSE;
DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
0, &dwNotUsed, NULL);

CloseHandle (hCD);
CloseHandle (hFile);
}

AnswerRe: What causes the error "Incorrect function."? Pin
Mike Nordell16-Jun-02 5:13
Mike Nordell16-Jun-02 5:13 
QuestionWhy can't i read from a cd-rom drive when i have opened it with CreateFIle? Pin
redeemer15-Jun-02 11:59
redeemer15-Jun-02 11:59 
AnswerRe: Why can't i read from a cd-rom drive when i have opened it with CreateFIle? Pin
JohnnyG15-Jun-02 12:17
JohnnyG15-Jun-02 12:17 
GeneralRe: Why can't i read from a cd-rom drive when i have opened it with CreateFIle? Pin
redeemer15-Jun-02 12:22
redeemer15-Jun-02 12:22 
GeneralRe: Why can't i read from a cd-rom drive when i have opened it with CreateFIle? Pin
Amit Dey15-Jun-02 14:24
Amit Dey15-Jun-02 14:24 
AnswerRe: Why can't i read from a cd-rom drive when i have opened it with CreateFIle? Pin
Amit Dey15-Jun-02 14:22
Amit Dey15-Jun-02 14:22 
Generalstrange... Pin
redeemer15-Jun-02 14:43
redeemer15-Jun-02 14:43 
GeneralRe: strange... Pin
Amit Dey15-Jun-02 15:07
Amit Dey15-Jun-02 15:07 
GeneralRe: strange... Pin
Amit Dey15-Jun-02 15:12
Amit Dey15-Jun-02 15:12 
Generaltoolbar on desktop Pin
slah15-Jun-02 11:16
slah15-Jun-02 11:16 
GeneralRe: toolbar on desktop Pin
Amit Dey15-Jun-02 11:58
Amit Dey15-Jun-02 11:58 
GeneralDataBase via Internet Pin
laphijia15-Jun-02 7:24
laphijia15-Jun-02 7:24 
GeneralRe: DataBase via Internet Pin
Jason Henderson15-Jun-02 7:44
Jason Henderson15-Jun-02 7:44 
QuestionHow to make a button usable when a for statement is running. (Non-MFC) Pin
redeemer15-Jun-02 6:58
redeemer15-Jun-02 6:58 
AnswerRe: How to make a button usable when a for statement is running. (Non-MFC) Pin
Jason Henderson15-Jun-02 7:49
Jason Henderson15-Jun-02 7:49 
GeneralRe: How to make a button usable when a for statement is running. (Non-MFC) Pin
redeemer15-Jun-02 8:29
redeemer15-Jun-02 8:29 
QuestionWriting a filesystem driver? Pin
clintsinger15-Jun-02 6:16
clintsinger15-Jun-02 6:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.