Buchempfehlung
Visual Basic 6 Kochbuch
Visual Basic 6 Kochbuch
Viele praktische Tipps zum Programmieren mit Visual Basic 6, die sich oft auch auf FB übertragen lassen. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

Code-Beispiel

Code-Beispiele » Dateien und Laufwerke

VHD-Dateien einbinden oder abtrennen

Lizenz:Erster Autor:Letzte Bearbeitung:
k. A.Mitgliedhhr 13.05.2020
Dim As String vhdpath,partialstring,vdiskcommand,scriptpath

If Len(Command(1))>0 Then
   vhdpath=Command(1)
   Print Wstr(vhdpath)
Else
   Input "Paste VHD path: ",vhdpath
End If

If Instr(vhdpath,":")=0 Then End ' Full path required

Dim As Long attribute
If Len(Dir(vhdpath,&hFF,attribute))=0 Then End ' Path not found
If Bit(attribute,4) Then End ' If Directory Then End

partialstring=Lcase(Right(vhdpath,Len(vhdpath)-Instrrev(vhdpath,".")))
If Not((partialstring="vhd") Or (partialstring="vhdx")) Then End

Print
Print "[ attach virtual disk | detach virtual disk ]"
Print
Print "Input [ a | d ]: ";

Select Case Chr(Getkey)
   Case "a"
      vdiskcommand="attach vdisk"
   Case "d"
      vdiskcommand="detach vdisk"
   Case Else
      End
End Select

Print vdiskcommand
Print

scriptpath=Exepath & "\diskpartscript.txt"

Open scriptpath For Output As #1
   Print #1,"select vdisk file=" & Chr(34) & vhdpath & Chr(34)
   Print #1,vdiskcommand
   Print #1,"exit"
Close #1

Dim As Long result=Shell("diskpart /s " & Chr(34) & scriptpath & Chr(34))

If result=0 Then
   Print "Operation successful."
Else
   Print "Operation failed."
End If

Sleep

End ' mountvhd.bas
'

Eine Verknüpfung kann in das "Senden an"-Menü kopiert werden.
Der entsprechende Ordner lässt sich mit der FreeBASIC-Zeile

shell "explorer shell:sendto"

öffnen.


Zusätzliche Informationen und Funktionen
  • Das Code-Beispiel wurde am 16.04.2020 von Mitgliedhhr angelegt.
  • Die aktuellste Version wurde am 13.05.2020 von Mitgliedhhr gespeichert.
  Bearbeiten Bearbeiten  

  Versionen Versionen