|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Registered User
Iscritto dal: Mar 2011
Messaggi: 72
|
[RISOLTO][VB.NET] Masterizzazione disco avviabile.
Salve a tutti!
Dovrei aggiungere ad un mio applicativo una funzionalità che permetta di masterizzare un dvd avviabile. Riesco a masterizzare il disco ma non so come impostare l'immagine di boot. Premetto che il codice non è scritto da me, ma è un progetto trovato su Codeproject che ho adattato alle mie esigenze. So che è possibile fare ciò che chiedo in quanto in "IMAPI2.Interop" ho trovato il codice di un'interfaccia "IBootOptions" che, a quanto ho capito,fa esattamente ciò che chiedo. Questo è il codice: Codice:
/// <summary> /// Boot Options /// </summary> [Guid("2C941FD4-975B-59BE-A960-9A2A262853A5")] [TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FDispatchable | TypeLibTypeFlags.FNonExtensible)] public interface IBootOptions { // Get boot image data stream [DispId(1)] IStream BootImage { get; } // Get boot manufacturer [DispId(2)] string Manufacturer { get; set; } // Get boot platform identifier [DispId(3)] PlatformId PlatformId { get; set; } // Get boot emulation type [DispId(4)] EmulationType Emulation { get; set; } // Get boot image size [DispId(5)] uint ImageSize { get; } // Set the boot image data stream, emulation type, and image size [DispId(20)] void AssignBootImage(IStream newVal); } Codice:
Dim bootFile bootFile="C:\etfsboot.com" Dim bootOptions As IBootOptions bootOptions.Manufacturer = "Microsoft" 'Imposta produttore bootOptions.PlatformId = PlatformId.PlatformX86 ' Imposta architettura bootOptions.Emulation = EmulationType.EmulationNone ' Imposta nessuna emulazione Dim bootStream As System.Runtime.InteropServices.ComTypes.IStream = bootFile bootOptions.AssignBootImage(bootStream) Su MSDN ho trovato qualche informazione, ma non mi è stata di grande aiuto: https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx Qualcuno può darmi una mano? Grazie ![]() Ultima modifica di Popo95 : 23-03-2015 alle 10:54. |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Iscritto dal: Sep 2006
Messaggi: 1539
|
Quote:
Se guardi il link da te postato nel tuo codice manca questa riga. SET bootOptions = WScript.CreateObject("IMAPI2FS.BootOptions") |
|
![]() |
![]() |
![]() |
#3 |
Registered User
Iscritto dal: Mar 2011
Messaggi: 72
|
Si ma quel codice non può essere utilizzato in VB.NET. Non so se abbia senso, ma ho provato a fare così:
Codice:
Dim bootOptions As IBootOptions = New BootOptions Codice:
Dim bootStream As System.Runtime.InteropServices.ComTypes.IStream = bootFile |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Sep 2006
Messaggi: 1539
|
Allora :
Il codice si aspetta un oggetto che implementi interfaccia ComTypes.IStream Che ovviamente la stringa non implementa. Implementarlo richiede comunque un po di lavoro, fortunatamente esistono già librerie che lo fanno Guardando il tuo esempio postato nel link Set bootStream = CreateObject("ADODB.Stream") WScript.Echo "Creating IStream for file " + bootFile bootStream.Open bootStream.Type = adFileTypeBinary bootStream.LoadFromFile bootFile bootOptions.AssignBootImage(bootStream) Vedi che esempio usa un ADODB.Stream che certamente non centra una fava con la masterizzazione cd, ma evidentemente va bene lo stesso. Quindi aggiungi un reference ad ADODB. e fai Dim bootStream As System.Runtime.InteropServices.ComTypes.IStream = new ADODB.Stream e prosegui come esempio. |
![]() |
![]() |
![]() |
#5 |
Registered User
Iscritto dal: Mar 2011
Messaggi: 72
|
Ok,risolto. Anche se adesso all'avvio mi da l'errore "COULDN'T FIND BOOTMGR", forse ho sbagliato qualcosa ma almeno adesso so a regola come proseguire.
Grazie mille! |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:57.