Hi Daniel,
so mal
Der Original C-Code:
#include "sddim_dll.h"
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
// Global Variables
SCSI_Info mySCSI_Info[100]; // Information about 100 (who owns them?) SCSI _
drives
int amount_of_disk_devices; // amount of SCSI Disk Devices connected to PC
// shows all present SCSI Disk Drives
void show_devices()
{
int i,j;
char mytext[]="0:0:0 ";
// show disk devices
for (i=0;i<amount_of_disk_devices;i++)
{
mytext[0]=mySCSI_Info.HaId+0x30;
mytext[2]=mySCSI_Info.Target+0x30;
for (j=0;j<40;j++) mytext[7+j]=mySCSI_Info.Name[j];
printf("%i) %s
",i,mytext);
}
}
// main()
int main()
{
BOOL loop;
printf("Drive Image Maker V1.0 - Console Version
(c)2000-2002 ");
// init WNASPI32.DLL
if (Init_WNASPI32()==FALSE)
printf("WNASPI32.DLL not present or no SCSI Host Adapters found!
");
// WNASPI32.DLL was successfully load now go on...
else
{
int i;
// scan SCSI Bus for Disk drives and store Disk Drive(s) information and _
amount
// of Disk Drives ;
// also prevent medium removal for all found disk devices
amount_of_disk_devices=Scan_SCSI_Bus(mySCSI_Info, TRUE);
// If no Disk Devices were found exit.......
if (amount_of_disk_devices==0)
printf("No SCSI Disk Drives found!
");
else
while (loop)
{
char key;
printf("please choose:
m) make image
s) store image
x) exit
");
key=_getch();
switch(key)
{
case 'x': loop=FALSE; break;
case 'm':
{
printf("MAKE IMAGE - please choose source drive:
");
show_devices();
key=0;
do key=_getch();
while (key<'0' && key>('0'+amount_of_disk_devices));
printf("please wait... making image 'c:\test.sdi'
");
// hier wird die funktion "makeImage" aufgerufen!!!
Make_Image(mySCSI_Info,key-'0', "c:\test.sdi");
break;
}
case 's':
{
printf("STORE IMAGE - please choose destination drive:
");
show_devices();
key=0;
do key=_getch();
while (key<'0' && key>('0'+amount_of_disk_devices));
printf("please wait... storing image 'c:\test.sdi'
");
// hier wird die funktion "makeImage" aufgerufen!!!
Store_Image(mySCSI_Info,key-'0', "c:\test.sdi");
break;
break;
}
}
}
// re-allow medium removal for all devices ....
for (i=0; i<amount_of_disk_devices; i++)
SCSI_Prevent_Medium_Removal(mySCSI_Info, FALSE);
}
// exit application....
return 0;
}Und hier die VB-Umsetzung:
' #include "sddim_dll.h"
'
Private Type SCSI_Info
Hald As Long 'Host Adapter ID
Target As Long 'SCSI Target
lPtrName As String 'Ptr auf String mit 64 Bytes
BlockSize As Long 'Size of one logical Block
Amount_of_Blocks As Long 'Anzahl of logical Blocks
End Type
Private Declare Function InitializeDLL Lib "wnaspi32.dll" Alias _
"Init_WNASPI32" () As Long
Private Declare Function ScanSCSI Lib "wnaspi32.dll" Alias _
"Scan_SCSI_Bus" _
(ByRef lptrSCSIInfo As Long, _
ByVal nTrueFalse As Long) As Long
Private Declare Sub SCSIPrevent Lib "wnaspi32.dll" Alias _
"SCSI_Prevent_Medium_Removeal" _
(ByRef lptrSCSIInfo As Long, _
ByVal nTrueFalse As Long)
Private Declare Function StoreImage Lib "wnaspi32.dll" Alias _
"Store_Image" _
(ByRef lptrSCSIInfo As Long, _
ByVal Drive As Long, _
ByRef sPtrFileName) As Long
Private Declare Function MakeImage Lib "wnaspi32.dll" Alias _
"Make_Image" _
(ByRef lptrSCSIInfo As Long, _
ByVal Drive As Long, _
ByRef sPtrFileName) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" _
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)
' // Global Variables ... SCSI_Info mySCSI_Info[100];
' // Information about 100 (who owns them?) SCSI drives
Private mySCSI_Info(100) As SCSI_Info
Private amount_of_Disk_Devices As Long ' // amount of SCSI Disk Devices
' connected to PC
Sub Main()
Dim rVal As Long
Dim jn As Integer
Dim nDrive As Integer
' WNASPI32.DLL initialisieren
rVal = InitializeDLL()
If rVal = 0 Then
MsgBox "WNASPI32.DLL not present or no SCSI Host Adapters found!", _
vbCritical, "Abbruch"
Exit Sub
End If
' // scan SCSI Bus for Disk drives and store Disk Drive(s) information and
' amoun of Disk Drives
' // also prevent medium removal for all found disk devices
amount_of_Disk_Devices = ScanSCSI(mySCSI_Info, True)
' // If no Disk Devices were found exit.......
If amount_of_Disk_Devices = 0 Then
MsgBox "No SCSI Disk Drives found!", vbExclamation, "Abbruch"
Exit Sub
End If
show_devices
' Im nachfolgenden wird gefragt, ob man eine Image erstellen
' will oder eine Image speichern will.
jn = MsgBox("Wollen Sie eine Image erstellen oder eine Image speichern. " & _
String(2, vbCrLf) & _
"Drücken Sie <JA> wenn Sie eine Image erstellen wollen." & _
vbCrLf & _
"Drücken Sie <Nein> wenn Sie eine Image speichern wollen." & _
vbCrLf & _
"Drücken Sie <Abbrechen> wenn Sie die Aktion abbrechen wollen", _
vbQuestion + vbYesNoCancel, "Frage:")
If jn = vbCancel Then Exit Sub
If jn = vbYes Then 'Image erstellen
nDrive = InputBox("Bitte geben Sie die Nummer des Laufwerks ein:", _
"Laufwerkauswahl")
If nDrive < 0 Or nDrive > amount_of_Disk_Devices Then Exit Sub
' Im nachfolgenden ist ein Pfad "hardgecodet"
MakeImage mySCSI_Info, nDrive, "C: est.sdi"
End If
If jn = vbNo Then 'Image in Drive speichern
nDrive = InputBox("Bitte die Nummer des Laufwerks an.", "Dateiangabe" & _
"erwartet")
If nDrive < 0 Or nDrive > amount_of_Disk_Devices Then Exit Sub
StoreImage mySCSI_Info, nDrive, "C: est.sdi"
End If
End Sub
' // shows all present SCSI Disk Drives
Private Sub show_devices()
Dim i As Long, j As Long
Dim myText As String
Dim a As String
For i = 0 To amount_of_Disk_Devices - 1
myText = mySCSI_Info(i).Hald + " "
myText = myText + mySCSI_Info(i).Target + " "
a = Space(64)
' Zeiger auf String in Var A umsetzen
CopyMemory ByVal a, mySCSI_Info(i).lPtrName, 64
myText = myText + Trim(a)
' Stringausgabe - wohin? mhm eine Listbox auf die Form!
List1.AddItem myText
Next
End Subcu
Lordchen |