He aquí otra forma de embeber archivos dentro de un ejecutable:
Para Meterlo:
Para Sacarlo:Código:Option Explicit Private Sub Command1_Click() Dim num As Integer num = FreeFile Open "C:\Mis documentos\Proyectos VB\Mios\Embebetor\EXE Pruebas\Copia (2) de Pruebas.exe" For Binary Access Write As #num Embeber_Archivo num, "C:\Mis documentos\Proyectos VB\Mios\Embebetor\EXE Pruebas\admutil.dll" Close End Sub Private Sub Embeber_Archivo(num As Integer, file As String) Dim file_cont As String Const footer_Ident As String = "#/*#/*#/*Archivo Embebido*\#*\#*\#" Dim footer_pos As Long Dim total_len As Integer Dim total As String Dim fnum As Integer fnum = FreeFile Open file For Binary Access Read As #fnum file_cont = Space(LOF(fnum)) Get #fnum, 1, file_cont Close #fnum total = footer_Ident & "," & Obtener_Nombre(file) & "," & file_cont total_len = Len(total) total = footer_Ident & total_len & "," & Obtener_Nombre(file) & "," & file_cont Put #num, LOF(num) + 1, total End Sub Private Function Obtener_Nombre(ruta As String) Obtener_Nombre = Right$(ruta, Len(ruta) - InStrRev(ruta, "\")) End Function
Importante: Hay que cambiarle los path, ya que cuando lo estaba probando le puse esos, podes reemplazarlos por otra ruta o por un text y de esa manera se hace dinámico...Código:Option Explicit Private Sub Sacar_Archivos(exe As String) Dim file_cont As String Dim file_name As String Const footer_Ident As String = "#/*#/*#/*Archivo Embebido*\#*\#*\#" Dim footer_pos As Long Dim total_len As Integer Dim exe_cont As String Dim fnum As Integer fnum = FreeFile Open exe For Binary Access Read As #fnum exe_cont = Space(LOF(fnum)) Get #fnum, , exe_cont Close Dim i As Integer i = 1 Dim tmp() As String Dim j As Integer Do While InStr(i, exe_cont, footer_Ident) footer_pos = InStr(i, exe_cont, footer_Ident) i = footer_pos + Len(footer_Ident) total_len = Val(Mid(exe_cont, i, Len(exe_cont) - InStr(i, exe_cont, ","))) tmp = Split(Mid(exe_cont, i, total_len + Len(total_len)), ",") file_name = tmp(1) For j = 2 To UBound(tmp) file_cont = file_cont & tmp(j) Next j fnum = FreeFile Open App.Path & "\" & file_name For Binary Access Write As #fnum Put #fnum, , file_cont Close Loop End Sub Private Sub Command1_Click() Sacar_Archivos ("C:\Mis documentos\Proyectos VB\Mios\Embebetor\EXE Pruebas\Copia (2) de Pruebas.exe") End Sub
Ya estoy trabajando para hacer un programa para embeber y sacar archivos de los exe más un módulo para incluír en otras aplicaciones y usar el mismo sistema...
Saludos...