-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCDVDMain.cpp
1119 lines (1003 loc) · 41.9 KB
/
CDVDMain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <vcl.h>
#pragma hdrstop
#include "Aspi.h"
#include "Stdlib.h"
#include "Stdio.h"
#include "String.h"
#include "About.h"
#include "Extra.h"
#include "Searchf.h"
#include "Summary.h"
#include "Device.h"
#include "pngimage.hpp"
#include "CDVDMain.h"
// #define DISCInfo_DEBUG
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "VersionInfoComponent"
#pragma resource "*.dfm"
TMain_Form *Main_Form;
#ifdef DISCInfo_DEBUG
FILE *debug_file;
#endif
//---------------------------------------------------------------------------
__fastcall TMain_Form::TMain_Form(TComponent* Owner)
: TForm(Owner)
{
Main_Form->Caption=Application->Title;
int iOSVer = getOsVersion();
ASPI1->Enabled=false;
SPTI1->Enabled=false;
ASPI1->Checked=false;
SPTI1->Checked=false;
if (!InitASPI())
{
ASPI1->Enabled=true;
#ifdef DISCInfo_DEBUG
write_log("Found ASPI drivers");
#endif
}
if (iOSVer>=2)
{
SPTI1->Enabled=true;
SPTI1->Checked=true;
#ifdef DISCInfo_DEBUG
write_log("Operating system is NT or later");
write_log("SPTI selected");
#endif
if (Device::makeDeviceList() || !deviceCount)
{
// If still not found anything then try ASPI if avaible
if (!deviceCount)
{
if (ASPI1->Enabled!=true)
{
#ifdef DISCInfo_DEBUG
write_log("No drives found via SPTI and no ASPI found to try it. Program exit");
#endif
Application->MessageBox ("Can not locate any drives in this computer.\nPossible reason is that you don't have administration rights.\nRelogon with username that has administration rights.\nYou can also try to install ASPI drivers. ASPI can work on non admin user accounts.\nProgram will now exit!", "Program error", MB_OK | MB_ICONSTOP);
Close();
}
else
{
SPTI1->Enabled=false;
SPTI1->Checked=false;
ASPI1->Checked=true;
#ifdef DISCInfo_DEBUG
write_log("SPTI failed to find devices. Trying ASPI");
#endif
if (Device::makeDeviceList() || !deviceCount)
{
#ifdef DISCInfo_DEBUG
write_log("Still nothing found. Trying to look for all devices");
#endif
// If there are no CD/DVD devices then enable the lookup for other devices
Displayotherdevices1->Checked=true;
if (Device::makeDeviceList() || !deviceCount)
{
#ifdef DISCInfo_DEBUG
write_log("Still nothing found. Program exit");
#endif
Application->MessageBox ("Unable to populate the device list with ASPI driver.\nReinstall the ASPI driver with version 4.60.\nProgram will now exit!", "Program error", MB_OK | MB_ICONSTOP);
Close();
}
}
}
}
}
} else
{
ASPI1->Enabled=true;
ASPI1->Checked=true;
#ifdef DISCInfo_DEBUG
write_log("Operating system is Windows 95 or newer (Win32)");
write_log("ASPI selected");
#endif
if (InitASPI())
{
#ifdef DISCInfo_DEBUG
write_log("ASPI not or improperly installed. Program exit.");
#endif
Application->MessageBox ("ASPI driver not or improperly installed.\n It's advised to install ASPI driver version 4.60.", "ASPI error", MB_OK | MB_ICONSTOP);
Close();
}
if (Device::makeDeviceList())
{
#ifdef DISCInfo_DEBUG
write_log("Unable to populate devices");
#endif
Application->MessageBox ("Unable to populate the device list. Program will now exit!", "Program error", MB_OK | MB_ICONSTOP);
Close();
}
if (!deviceCount)
{
#ifdef DISCInfo_DEBUG
write_log("No devices found. Trying to show all devices");
#endif
// If there are no CD/DVD devices then enable the lookup for other devices
Displayotherdevices1->Checked=true;
if (Device::makeDeviceList())
{
#ifdef DISCInfo_DEBUG
write_log("Unable to populate devices. Program exit");
#endif
Application->MessageBox ("Unable to populate the device list. Program will now exit!", "Program error", MB_OK | MB_ICONSTOP);
Close();
}
// If still not found anything then display notice and exit
if (!deviceCount)
{
#ifdef DISCInfo_DEBUG
write_log("No devices found. Program exit");
#endif
Application->MessageBox ("Can not locate any drives in this computer. Program will now exit!", "Program error", MB_OK | MB_ICONSTOP);
Close();
}
}
}
ComboBoxChange(Main_Form);
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::Exit1Click(TObject *Sender)
{
#ifdef DISCInfo_DEBUG
write_log("Program exit");
#endif
Close();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int getOsVersion()
{
OSVERSIONINFO os;
ZeroMemory( &os, sizeof(os) );
os.dwOSVersionInfoSize = sizeof(os);
GetVersionEx( &os );
if ( os.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
if ( os.dwMajorVersion == 3 && os.dwMinorVersion >= 50 )
return OS_WINNT35;
else if ( os.dwMajorVersion == 4 )
return OS_WINNT4;
else if ( os.dwMajorVersion == 5 )
return OS_WIN2K;
}
else if ( os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
if ( os.dwMinorVersion == 0 )
return OS_WIN95;
else
return OS_WIN98;
}
return OS_UNKNOWN;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMain_Form::SaveData1Click(TObject *Sender)
{
TStringList *slInfo = new TStringList();
char forfile[100];
char rpc[10];
char firma[8];
char kater_model[16];
char DISCInfoVer[15];
int i;
bool first_time=true;
Device* dev = devices;
// Retrieve the File Version
DWORD h;
DWORD Size=GetFileVersionInfoSize(Application->ExeName.c_str(), &h);
if(Size==0)
sprintf(DISCInfoVer,"Unknowned");
char *buf;
char *ValueBuf;
buf=(char*)GlobalAlloc(GMEM_FIXED, Size);
if(GetFileVersionInfo(Application->ExeName.c_str(),
h,
Size,
buf)!=0)
{
UINT Len;
VerQueryValue(buf, "\\VarFileInfo\\Translation", &(void*)ValueBuf, &Len);
if(Len>=4)
{
AnsiString CharSet=IntToHex((int)MAKELONG(*(int*)(ValueBuf+2), *(int*)ValueBuf), 8);
/*
if(VerQueryValue(buf,
AnsiString("\\StringFileInfo\\"+CharSet+"\\ProductName").c_str(),
&(void*)ValueBuf,
&Len)!=0)
ShowMessage(ValueBuf);
if(VerQueryValue(buf,
AnsiString("\\StringFileInfo\\"+CharSet+"\\LegalCopyright").c_str(),
&(void*)ValueBuf,
&Len)!=0)
ShowMessage(ValueBuf);
if(VerQueryValue(buf,
AnsiString("\\StringFileInfo\\"+CharSet+"\\CompanyName").c_str(),
&(void*)ValueBuf,
&Len)!=0)
ShowMessage(ValueBuf);
*/
if(VerQueryValue(buf,
AnsiString("\\StringFileInfo\\"+CharSet+"\\FileVersion").c_str(),
&(void*)ValueBuf,
&Len)!=0)
sprintf(DISCInfoVer,"%s",ValueBuf);
}
} else
sprintf(DISCInfoVer,"Unknowned");
GlobalFree(buf);
for (i=0;i<deviceCount;i++)
{
if (dev->type==DTYPE_WORM || dev->type==DTYPE_CROM)
{
if (i!=0 && deviceCount>1 && !first_time)
{
slInfo->Add("<- ->");
}
memcpy(firma,dev->vendor_name,8);
firma[8]=0;
memcpy(kater_model,&dev->vendor_name[8],16);
firma[16]=0;
sprintf(forfile,"DISCINFO VERSION : %s",DISCInfoVer);
slInfo->Add(forfile);
sprintf(forfile,"VENDOR : %s",firma);
slInfo->Add(forfile);
sprintf(forfile,"MODEL : %s",kater_model);
slInfo->Add(forfile);
sprintf(forfile,"REVISION : %s",dev->firmware_version);
slInfo->Add(forfile);
if (dev->extra_info[0]!=0)
{
sprintf(forfile,"VENDOR SPECIFIC : %s",dev->extra_info);
slInfo->Add(forfile);
}
if (dev->mechanism[0]!=0)
{
sprintf(forfile,"LOADING MECHANISM : %s",AnsiString(dev->mechanism).Trim());
slInfo->Add(forfile);
}
if (dev->serial[0]!=0)
{
sprintf(forfile,"SERIAL NUMBER : %s",AnsiString(dev->serial).SubString(0,12));
slInfo->Add(forfile);
}
if (dev->levels > 0)
{
sprintf(forfile,"NUMBER VOL. LEVELS : %i",dev->levels);
slInfo->Add(forfile);
}
if (dev->buffersize > 0)
{
sprintf(forfile,"BUFFER SIZE : %iKB",dev->buffersize);
slInfo->Add(forfile);
}
if (dev->if_toshiba)
{
sprintf(forfile,"TOSHIBA CODE : %s",dev->fw_code);
slInfo->Add(forfile);
sprintf(forfile,"TOSHIBA MODEL : %s",dev->tosh_model);
slInfo->Add(forfile);
}
switch(dev->interfacex[0])
{
case 0x00:
sprintf(forfile,"INTERFACE : %s","ATAPI");
slInfo->Add(forfile);
break;
case 0x01:
sprintf(forfile,"INTERFACE : %s","SCSI 1");
slInfo->Add(forfile);
break;
case 0x02:
sprintf(forfile,"INTERFACE : %s","SCSI 2");
slInfo->Add(forfile);
break;
case 0x03:
sprintf(forfile,"INTERFACE : %s","SCSI 3");
slInfo->Add(forfile);
break;
default: // IF NOT FOUND
break;
}
if (dev->drive_status)
{
sprintf(rpc,"%s","YES");
rpc[3]=0;
} else
{
sprintf(rpc,"%s","NO");
rpc[2]=0;
}
sprintf(forfile,"RPC2 SCHEME : %s",rpc);
slInfo->Add(forfile);
if (dev->drive_status)
{
sprintf(forfile,"STATUS : %s",dev->region_status);
slInfo->Add(forfile);
sprintf(forfile,"USER CHANGES : %i",dev->user);
slInfo->Add(forfile);
sprintf(forfile,"VENDOR CHANGES : %i",dev->manufactor);
slInfo->Add(forfile);
sprintf(forfile,"CURRENT REGION : %s",dev->current_region);
slInfo->Add(forfile);
}
if (dev->iscdDrive || dev->iscdRRead || dev->iscdRWrite || dev->isdvdDrive)
{
if (dev->audioplay)
sprintf(forfile,"ANALOG AUDIO PLAY : %s","YES");
else
sprintf(forfile,"ANALOG AUDIO PLAY : %s","NO");
slInfo->Add(forfile);
if (dev->composite)
sprintf(forfile,"COMPOSITE OUTPUT : %s","YES");
else
sprintf(forfile,"COMPOSITE OUTPUT : %s","NO");
slInfo->Add(forfile);
if (dev->digport1)
sprintf(forfile,"DIGITAL PORT-PORT1 : %s","YES");
else
sprintf(forfile,"DIGITAL PORT-PORT1 : %s","NO");
slInfo->Add(forfile);
if (dev->digport2)
sprintf(forfile,"DIGITAL PORT-PORT2 : %s","YES");
else
sprintf(forfile,"DIGITAL PORT-PORT2 : %s","NO");
slInfo->Add(forfile);
if (dev->UPC)
sprintf(forfile,"READ UPC CODE : %s","YES");
else
sprintf(forfile,"READ UPC CODE : %s","NO");
slInfo->Add(forfile);
if (dev->multisession)
sprintf(forfile,"MULTISESSION READ : %s","YES");
else
sprintf(forfile,"MULTISESSION READ : %s","NO");
slInfo->Add(forfile);
if (dev->mode1form)
sprintf(forfile,"MODE 2 FORM 1 : %s","YES");
else
sprintf(forfile,"MODE 2 FORM 1 : %s","NO");
slInfo->Add(forfile);
if (dev->mode2form)
sprintf(forfile,"MODE 2 FORM 2 : %s","YES");
else
sprintf(forfile,"MODE 2 FORM 2 : %s","NO");
slInfo->Add(forfile);
if (dev->ISRC)
sprintf(forfile,"READ ISRC CODE : %s","YES");
else
sprintf(forfile,"READ ISRC CODE : %s","NO");
slInfo->Add(forfile);
if (dev->barcode)
sprintf(forfile,"READ BAR CODE : %s","YES");
else
sprintf(forfile,"READ BAD CODE : %s","NO");
slInfo->Add(forfile);
if (dev->buffunder)
sprintf(forfile,"BUFFER UNDER-RUN : %s","YES");
else
sprintf(forfile,"BUFFER UNDER-RUN : %s","NO");
slInfo->Add(forfile);
if (dev->mtrainier)
sprintf(forfile,"MT. RAINIER : %s","YES");
else
sprintf(forfile,"MT. RAINIER : %s","NO");
slInfo->Add(forfile);
if (dev->cdRRead)
sprintf(forfile,"CAN READ CDR : %s","YES");
else
sprintf(forfile,"CAN READ CDR : %s","NO");
slInfo->Add(forfile);
if (dev->cdRWRead)
sprintf(forfile,"CAN READ CDRW : %s","YES");
else
sprintf(forfile,"CAN READ CDRW : %s","NO");
slInfo->Add(forfile);
if (dev->cdMethod2Read)
sprintf(forfile,"CAN READ CDRM2 : %s","YES");
else
sprintf(forfile,"CAN READ CDRM2 : %s","NO");
slInfo->Add(forfile);
if (dev->cdRWrite)
sprintf(forfile,"CAN WRITE CDR : %s","YES");
else
sprintf(forfile,"CAN WRITE CDR : %s","NO");
slInfo->Add(forfile);
if (dev->cdRWWrite)
sprintf(forfile,"CAN WRITE CDRW : %s","YES");
else
sprintf(forfile,"CAN WRITE CDRW : %s","NO");
slInfo->Add(forfile);
if (dev->testWrite)
sprintf(forfile,"CAN TEST WRITE : %s","YES");
else
sprintf(forfile,"CAN TEST WRITE : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRomRead)
sprintf(forfile,"CAN READ DVD-ROM : %s","YES");
else
sprintf(forfile,"CAN READ DVD-ROM : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRRead)
sprintf(forfile,"CAN READ DVD-R : %s","YES");
else
sprintf(forfile,"CAN READ DVD-R : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRWRead)
sprintf(forfile,"CAN READ DVD-RW : %s","YES");
else
sprintf(forfile,"CAN READ DVD-RW : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRamRead)
sprintf(forfile,"CAN READ DVD-RAM : %s","YES");
else
sprintf(forfile,"CAN READ DVD-RAM : %s","NO");
slInfo->Add(forfile);
if (dev->dvdPRRead)
sprintf(forfile,"CAN READ DVD+R : %s","YES");
else
sprintf(forfile,"CAN READ DVD+R : %s","NO");
slInfo->Add(forfile);
if (dev->dvdPRWRead)
sprintf(forfile,"CAN READ DVD+RW : %s","YES");
else
sprintf(forfile,"CAN READ DVD+RW : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRWrite)
sprintf(forfile,"CAN WRITE DVD-R : %s","YES");
else
sprintf(forfile,"CAN WRITE DVD-R : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRWWrite)
sprintf(forfile,"CAN WRITE DVD-RW : %s","YES");
else
sprintf(forfile,"CAN WRITE DVD-RW : %s","NO");
slInfo->Add(forfile);
if (dev->dvdRamWrite)
sprintf(forfile,"CAN WRITE DVD-RAM : %s","YES");
else
sprintf(forfile,"CAN WRITE DVD-RAM : %s","NO");
slInfo->Add(forfile);
if (dev->dvdPRWrite)
sprintf(forfile,"CAN WRITE DVD+R : %s","YES");
else
sprintf(forfile,"CAN WRITE DVD+R : %s","NO");
slInfo->Add(forfile);
if (dev->dvdPRWWrite)
sprintf(forfile,"CAN WRITE DVD+RW : %s","YES");
else
sprintf(forfile,"CAN WRITE DVD+RW : %s","NO");
slInfo->Add(forfile);
}
if (dev->read_s > 0)
{
sprintf(forfile,"MAX CDR READ SPEED : %i",dev->read_s);
slInfo->Add(forfile);
}
if (dev->iscdRWrite && dev->write_s > 0)
{
sprintf(forfile,"MAX CDR WRITE SPEED: %i",dev->write_s);
slInfo->Add(forfile);
}
first_time=false;
}
dev = dev->next;
}
const char* sPOST_FileExt = ".hif";
const char* sPOST_Filter = "CD/DVD Info File (*.hif)|*.hif";
SaveDialog->DefaultExt = sPOST_FileExt;
SaveDialog->Filter = sPOST_Filter;
SaveDialog->Title = "Save the CD/DVD informations into a file";
SaveDialog->FileName="";
if (SaveDialog->Execute())
{
if (FileExists(SaveDialog->FileName))
{
if (!DeleteFile(SaveDialog->FileName))
{
Application->MessageBox("Unable to save to file. Maybe file is write protected?", "Error", MB_OK | MB_ICONSTOP);
Abort();
}
}
slInfo->SaveToFile(SaveDialog->FileName);
}
#ifdef DISCInfo_DEBUG
write_log("HIF file saved");
#endif
SaveDialog->FileName="";
/*
char firmax[60];
char sumahex[8];
int suma;
sprintf(firmax,"%s",SaveDialog->FileName);
FILE* fin = fopen(firmax,"rb");
do
{
suma += fgetc(fin); // sum all bytes
} while(!feof(fin));
fclose(fin);
sprintf(sumahex,"CRC:%04X",suma&0xFFFF); // LAST FEW BYTES
sumahex[8]=0;
Application->MessageBox (sumahex, "ASPI error", MB_OK | MB_ICONSTOP);
fin = fopen(firmax,"a+");
fwrite(sumahex, 8, 1, fin);
fclose(fin);
*/
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMain_Form::About1Click(TObject*)
{
#ifdef DISCInfo_DEBUG
write_log("Opening About box");
#endif
About_Box = new TAbout_Box(Application);
About_Box->ShowModal();
delete About_Box;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMain_Form::ComboBoxChange(TObject *Sender)
{
int i=0;
Device* dev = devices;
ExtraInfo1->Enabled=false;
Firmwareupdates1->Enabled=false;
int pos = deviceCount-Main_Form->ComboBox->ItemIndex-1;
for (i=0; i < pos; i++)
{
dev = dev->next;
}
GetDeviceData (dev);
#ifdef DISCInfo_DEBUG
char tmp[255];
sprintf(tmp,"Viewing details for the drive %s",AnsiString(dev->vendor_name).Trim());
write_log(tmp);
#endif
if (dev->type == DTYPE_WORM || dev->type == DTYPE_CROM)
{
if(dev->iscdDrive || dev->iscdRRead || dev->iscdRWrite || dev->isdvdDrive)
{
Main_Form->ExtraInfo1->Enabled=true;
Main_Form->Firmwareupdates1->Enabled=true;
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMain_Form::ComboBoxKeyPress(TObject *Sender, char &Key)
{
if (Key == 'x' || Key == 'X' || Key == VK_ESCAPE)
{
#ifdef DISCInfo_DEBUG
write_log("Program exit");
#endif
Close();
}
if (Key == 'c' || Key == 'C')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Displaying Capabilities info selected");
#endif
ExtraInfo1->Click();
}
if (Key == 'a' || Key == 'A')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Displaying About box selected");
#endif
About1->Click();
}
if (Key == 'd' || Key == 'D')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Displaying other devices than CD/DVD selected");
#endif
Displayotherdevices1->Click();
}
if (Key == 's' || Key == 'S')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Save data to HIF file selected");
#endif
SaveData1->Click();
}
if (Key == 'f' || Key == 'F')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Firmware updates selected");
#endif
Firmwareupdates1->Click();
}
if (Key == 'g' || Key == 'G')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Take screenshot of main window selected");
#endif
versionDblClick(NULL);
}
if (Key == 'i' || Key == 'I')
{
Key = 0;
#ifdef DISCInfo_DEBUG
write_log("Display summary page selected");
#endif
CopyToClipboard1->Click();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMain_Form::Displayotherdevices1Click(TObject *Sender)
{
if (Displayotherdevices1->Checked)
{
#ifdef DISCInfo_DEBUG
write_log("Disable showing of other deviced selected");
#endif
Displayotherdevices1->Checked=false;
ComboBox->Clear();
Device::makeDeviceList ();
ComboBoxChange(Main_Form);
} else
{
#ifdef DISCInfo_DEBUG
write_log("Enable showing of other deviced selected");
#endif
Displayotherdevices1->Checked=true;
ComboBox->Clear();
Device::makeDeviceList ();
ComboBoxChange(Main_Form);
}
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::ExtraInfo1Click(TObject *Sender)
{
#ifdef DISCInfo_DEBUG
write_log("Showing capabilities window");
#endif
Extra_Box = new TExtra_Box(Application);
Extra_Box->ShowModal();
delete Extra_Box;
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::Firmwareupdates1Click(TObject *Sender)
{
#ifdef DISCInfo_DEBUG
write_log("Showing firmware update window");
#endif
Search_Box = new TSearch_Box(Application);
Search_Box->ShowModal();
delete Search_Box;
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::CopyToClipboard1Click(TObject *Sender)
{
#ifdef DISCInfo_DEBUG
write_log("Showing summary page window");
#endif
SumInfo = new TSumInfo(Application);
SumInfo->ShowModal();
delete SumInfo;
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::SPTI1Click(TObject *Sender)
{
if (!SPTI1->Checked)
{
#ifdef DISCInfo_DEBUG
write_log("SPTI access enabled");
#endif
SPTI1->Checked=true;
ASPI1->Checked=false;
ComboBox->Clear();
Device::makeDeviceList ();
ComboBoxChange(Main_Form);
}
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::ASPI1Click(TObject *Sender)
{
if (!ASPI1->Checked)
{
#ifdef DISCInfo_DEBUG
write_log("ASPI access enabled");
#endif
SPTI1->Checked=false;
ASPI1->Checked=true;
ComboBox->Clear();
if (InitASPI() || Device::makeDeviceList () || !deviceCount)
{
Application->MessageBox ("ASPI driver not or improperly installed.\nTrying to switch back to SPTI mode.", "ASPI error", MB_OK | MB_ICONSTOP);
SPTI1->Checked=true;
ASPI1->Checked=false;
if (Device::makeDeviceList () || !deviceCount)
{
#ifdef DISCInfo_DEBUG
write_log("No devices found or I have problem with finding them");
#endif
Application->MessageBox ("Can't find any drives or problem with identifying them.", "Critical error", MB_OK | MB_ICONSTOP);
Close();
}
}
ComboBoxChange(Main_Form);
}
}
//---------------------------------------------------------------------------
void __fastcall TMain_Form::Resfresh1Click(TObject *Sender)
{
#ifdef DISCInfo_DEBUG
write_log("Refreshing the drive list");
#endif
ComboBox->Clear();
Device::makeDeviceList ();
ComboBoxChange(Main_Form);
}
//---------------------------------------------------------------------------
#ifdef DISCInfo_DEBUG
void start_log()
{
char LogFileDir[MAX_PATH];
sprintf(LogFileDir,"%s\\DISCInfo.log",GetCurrentDir());
debug_file = fopen( LogFileDir, "w" );
write_log("Loging started");
fclose( debug_file );
}
void write_log(char *debug_string)
{
char neki[255];
char LogFileDir[MAX_PATH];
sprintf(LogFileDir,"%s\\DISCInfo.log",GetCurrentDir());
sprintf(neki,"%s: %s\n",TimeToStr(Time()),debug_string);
debug_file = fopen(LogFileDir, "a" );
if ( debug_file )
{
fwrite( neki, 1, strlen(neki), debug_file );
fclose( debug_file );
}
}
#endif
// Get Data out of the drive
void GetDeviceData (Device *device)
{
char type_of[50];
char temp[2];
switch(device->type)
{
case DTYPE_DASD:
memcpy(type_of,"Hard Disk Device",50);
break;
case DTYPE_SEQD:
memcpy(type_of,"Tape Device",50);
break;
case DTYPE_PRNT:
memcpy(type_of,"Printer Device",50);
break;
case DTYPE_SCAN:
memcpy(type_of,"Scanner Device",50);
case DTYPE_PROC:
memcpy(type_of,"Process Unit",50);
break;
case DTYPE_WORM:
memcpy(type_of,"CD/DVD Burner Device",50);
break;
case DTYPE_CROM:
memcpy(type_of,"CD-ROM Device",50);
break;
case DTYPE_OPTI:
memcpy(type_of,"Optical Memory Device",50);
break;
case DTYPE_JUKE:
memcpy(type_of,"Juke Box Device",50);
break;
default:
memcpy(type_of,"Unknowned Device",50);
break;
}
if (device->isdvdDrive && !device->iscdRWrite && device->type == DTYPE_CROM || device->type == DTYPE_WORM)
memcpy(type_of,"DVD-ROM Device",50);
if (device->isdvdDrive && device->iscdRWrite && device->type == DTYPE_CROM || device->type == DTYPE_WORM)
memcpy(type_of,"COMBO (CDR/DVD) Device",50);
if (device->iscdRWrite && !device->isdvdDrive && device->type == DTYPE_CROM || device->type == DTYPE_WORM)
memcpy(type_of,"CDR Burner Device",50);
if (device->iscdRWrite && !device->isdvdDrive && device->cdRWWrite && device->type == DTYPE_CROM || device->type == DTYPE_WORM)
memcpy(type_of,"CDRW Burner Device",50);
if (device->iscdRWrite && device->dvdRWrite && device->type == DTYPE_CROM || device->type == DTYPE_WORM)
memcpy(type_of,"DVD Burner Device",50);
if (!device->if_toshiba)
{
Main_Form->fw_code->Caption="none";
Main_Form->specific_d->Caption=type_of;
} else
{
Main_Form->fw_code->Caption=Trim((AnsiString) device->fw_code);
if(AnsiString(device->tosh_model).Length() == 0)
{
Main_Form->specific_d->Caption=AnsiString(type_of).Trim();
} else
{
Main_Form->specific_d->Caption=device->tosh_model;
}
}
Main_Form->date->Caption=AnsiString(device->extra_info).Trim();
Main_Form->version->Caption=device->firmware_version;
if (device->type == DTYPE_CROM || device->type == DTYPE_WORM)
{
Main_Form->read_s->Caption="Read speed:";
Main_Form->write_s->Caption="Write speed:";
if (device->read_s > 0)
{
sprintf(temp,"%ix",device->read_s);
Main_Form->readval->Caption=temp;
} else
Main_Form->readval->Caption="n/a";
if (device->write_s > 0)
{
sprintf(temp,"%ix",device->write_s);
Main_Form->writeval->Caption=temp;
} else
Main_Form->writeval->Caption="n/a";
} else
{
Main_Form->read_s->Caption="";
Main_Form->write_s->Caption="";
Main_Form->readval->Caption="";
Main_Form->writeval->Caption="";
}
if (!device->drive_status || !device->isdvdDrive)
{
Main_Form->reg_status->Caption="";
Main_Form->permanent_status->Caption="";
Main_Form->changes_left->Caption="";
Main_Form->manuf_left->Caption="";
Main_Form->region_set->Caption="";
Main_Form->change_data->Caption="";
Main_Form->man_data->Caption="";
Main_Form->set_data->Caption="";
if (device->isdvdDrive)
{
Main_Form->region_status->Caption="Drive region status:";
Main_Form->status_rpc->Hint="RPC-1 :o)";
Main_Form->status_rpc->Caption="No Lock Detected";
} else
{
Main_Form->status_rpc->Caption="";
Main_Form->region_status->Caption="";
}
if (device->type == DTYPE_DASD || device->type == DTYPE_PROC) // Specical case for HD
{
Main_Form->status_rpc->Caption="";
Main_Form->region_status->Caption="";
}
} else
{
Main_Form->region_status->Caption="Drive region status:";
Main_Form->reg_status->Caption="Region setting status";
Main_Form->changes_left->Caption="User changes left:";
Main_Form->manuf_left->Caption="Manufactor resets left:";
Main_Form->region_set->Caption="Current region set:";
Main_Form->status_rpc->Hint="RPC-2 :-(";
Main_Form->status_rpc->Caption="Lock Detected";
Main_Form->permanent_status->Caption=device->region_status;
Main_Form->set_data->Caption=device->current_region;
if (Trim(Main_Form->set_data->Caption) == "n/a")
{
Main_Form->set_data->Caption="n/a";
Main_Form->change_data->Caption="n/a";
Main_Form->man_data->Caption="n/a";
} else
{
Main_Form->set_data->Caption=device->current_region;
Main_Form->change_data->Caption=device->user;
Main_Form->man_data->Caption=device->manufactor;
}
}
}
void __fastcall TMain_Form::versionDblClick(TObject *Sender)
{
const char* sPOST_FileExt = ".png";
const char* sPOST_Filter = "Portable Network Graphic (*.png)|*.png";
SaveDialog->DefaultExt = sPOST_FileExt;
SaveDialog->Filter = sPOST_Filter;