| | |
Removable drives
![]() |
•
•
Join Date: May 2005
Posts: 508
Reputation:
Solved Threads: 19
C++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <stdlib.h> #include <dos.h> #include <memory.h> #include "fdc.h" int main() { int i, j, drive, head, track, start_sect, max_sect, type; int times; long size; int sector; char buf[BUFSIZ * 9 + 1]; char buf1[BUFSIZ * 9 + 1]; int fd; size = (long)(360l * 1024l); if((fd = mopen(size)) != -1) { fprintf(stderr, "Can't open the output file!\n"); exit(1); } for(times = 0; times < 1; ++times) { if(!times) { printf("insert the first diskette into the drive & hit enter "); gets(buf); } else { lseek(fd, 0l, 0); printf("insert the second diskette into the drive & hit enter "); gets(buf); } drive = 0; /* set drive to A */ type = 2; /* set 320/360K disk in 1.2 M drive */ start_sect = 1; max_sect = 9; if(setdasd(drive, type)) { fprintf(stderr, "Can't set the dasd for drive A!\n"); close(fd); exit(1); } for(track = 0; track < 40; track++) for(head = 0; head < 2; head++) for(sector = 1; sector < 10; sector++) for(i = 0; i < 3; i++) { if(rdtrack(drive, head, track, sector, 1, buf) == 0) { if(!times) { write(fd, buf, BUFSIZ); } else { read(fd, buf1, BUFSIZ); for(j = 0; j < BUFSIZ; j++) if(buf1[i] != buf[i]) { printf("difference at head %2d, track %2d, byte %5d \ %x %x\n", head, track, i, buf1[i], buf[i]); } } } else { fprintf(stderr, "failure %d on head %d, track %d, sector %d\n", i, head, track, sector); } } } close(fd); printf("done\n"); exit(0); }
•
•
Join Date: May 2005
Posts: 508
Reputation:
Solved Threads: 19
HAHAHAHAHA
Ok So I did not have my first cup of Coffee... I saw C++ and just went to work...
smmmmacccckkk...
Sorry for wrong info.. was just trying to help..
Ok So I did not have my first cup of Coffee... I saw C++ and just went to work...
smmmmacccckkk...
Sorry for wrong info.. was just trying to help..
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
Thank you Stoned_Coder very much.
Your Guides were very useful for me. My problem was solved. My main problem was this: The WinXP shows a message "No disk in CD-ROM ..." each time i reference a file in that drive. The SetErrorMode(SEM_FAILCRITICALERRORS) solved my problem.
I wrote (in C++Builder) the bellow function (Of cource WIN API have functions for this purpose but using them was very difficult and specific to each version of Windows) and tested it. It works.
Please help me if this function has any problem.
<< moderator edit: added [code][/code] tags >>
Your Guides were very useful for me. My problem was solved. My main problem was this: The WinXP shows a message "No disk in CD-ROM ..." each time i reference a file in that drive. The SetErrorMode(SEM_FAILCRITICALERRORS) solved my problem.
I wrote (in C++Builder) the bellow function (Of cource WIN API have functions for this purpose but using them was very difficult and specific to each version of Windows) and tested it. It works.
Please help me if this function has any problem.
C++ Syntax (Toggle Plain Text)
bool IsDriveReady(AnsiString tasDrive) { if(tasDrive.IsEmpty()) tasDrive = GetCurrentDir(); tasDrive = tasDrive.UpperCase(); int liDrive = tasDrive[1] - 'A' + 1; UINT luiOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); bool lbReady = (DiskFree(liDrive) >= 0); SetErrorMode(luiOldErrorMode); return lbReady; }
![]() |
Similar Threads
- New MP3 Player - need help (Windows NT / 2000 / XP)
- a non-destructive repartitioning tool? (*nix Software)
- "Disk in drive is not formatted" (can't access HD) (Windows NT / 2000 / XP)
- Installing Software (*nix Software)
- What exactly does this error message mean and how can I fix? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: CSocket: How do I do this?
- Next Thread: trial version of Microsft VC++
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code codesamplerunwhilecommands coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph guess gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker listing loop looping loops map math matrix memory multiple news node output pointer port problem proficiency program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets





