gracias korpex, pero no me sirvio mcuho, lo ke encontre si ke me sirvio
'--------------------------------------------------------
' Copyright 2002, Anoop Sankar
'You may freely use, modify and distribute this source
'code, provided that you do not remove this message.
'But, you are NOT allowed to distribute the compiled
'version (.EXE,.DLL,.OCX etc etc.) of this program
'or any program which uses the below code without my
'consent.
'
'If you modified something, put your name below..
'
'Orginal Code : Anoop Sankar (anoops@gmx.net)
'Modified by : No one so far
'
'Last Update : Oct 25,2002
'Visit www.smilehouse.cjb.net for more source code
'-------------------------------------------------------
'
'Purpose of the project is to create a stand alone exe
'file from VB code. It doesn't do this directly, but uses
'a simple work around. I think this is quite a useful
'way to do this. If you think otherwise or if you have
'other methods, I would love to hear from you.
'
'The method is .. write to the end of a pre-created exe
'file, in binary mode.
'
'Check 'readme.html' for more details.
'
'-------------------------------------------------------
Private Sub cmdCompile_Click()
'This is were all the action takes place
On Local Error GoTo errTrap
Dim BeginPos As Long 'variable to store the start of data
Dim PropBag As New PropertyBag 'property bag to store the data
Dim varTemp As Variant 'for file writing
'Below section loads data into the property bag.
With PropBag
.WriteProperty "Caption", txtCaption.Text
.WriteProperty "Text", txtText.Text
.WriteProperty "Picture", imgPic.Picture
.WriteProperty "Protected", chkPass.Value
.WriteProperty "Password", txtPass.Text
'You may add your own propery using the syntax
'PropBag.WriteProperty "<property name>",<property value>
'As you might have noticed, property value can be anything
'string, picture, or numerical.
End With
'rdfce.ext is the template we use to create our exe.
'RDFCE = Renamed Dummy For Creating Executable ;-)
'(source of that file is included too)
'first copy that file to the user provided file name.
FileCopy App.Path & "\rdfce.ext", App.Path & "\" & txtExeFile.Text
'now open the file in binary mode
Open App.Path & "\" & txtExeFile.Text For Binary As #1
BeginPos = LOF(1) 'the point were we add extra data
varTemp = PropBag.Contents
Seek #1, LOF(1)
Put #1, , varTemp 'write data
Put #1, , BeginPos 'write starting point of extra data
Close #1
MsgBox "Exe File created without a problem", vbInformation, "Compilation Done"
Exit Sub
'Thats it! The exe is compiled.
'Read the prjExeDummy (prjRdfce.vbp) to find how the
'compiled exe works.
errTrap:
'to err is electronic
Msg = "There was an error during compilation" & vbCrLf
Msg = Msg & vbCrLf & Err.Description
MsgBox Msg, vbCritical, "Error"
End Sub
Private Sub Form_Load()
End Sub
Private Sub imgPic_Click()
End Sub
Private Sub Label2_Click(Index As Integer)
End Sub
Private Sub lblAddPic_Click()
On Local Error GoTo errTrap
ComDLG.CancelError = True
ComDLG.ShowOpen
imgPic.Picture = LoadPicture(ComDLG.FileName)
errTrap:
End Sub
Private Sub chkPass_Click()
On Local Error Resume Next
If chkPass.Value > 0 Then
txtPass.Enabled = True
txtPass.SetFocus
Else
txtPass.Enabled = False
End If
End Sub
y en el otro proyecto fuera de este
'--------------------------------------------------------
' Copyright 2002, Anoop Sankar
'You may freely use, modify and distribute this source
'code, provided that you do not remove this message.
'But, you are NOT allowed to distribute the compiled
'version (.EXE,.DLL,.OCX etc etc.) of this program
'or any program which uses the below code without my
'consent.
'
'If you modified something, put your name below..
'
'Orginal Code : Anoop Sankar (anoops@gmx.net)
'Modified by : No one so far
'
'Last Update : Oct 25,2002
'Visit www.smilehouse.cjb.net for more source code
'------------------------------------------------------
'
'This is the source for the rdfce.ext file,
'which is used as the template for creating the exe.
'
'This project will not run properly in the IDE.
'Check readme.html for more information
'
'------------------------------------------------------
Dim PropBag As New PropertyBag 'the property bag
Private Sub Form_Load()
'On Local Error Resume Next
Dim BeginPos As Long
Dim varTemp As Variant
Dim byteArr() As Byte
Open App.Path & "\" & App.EXEName & ".exe" For Binary As #1
Get #1, LOF(1) - 3, BeginPos 'get the start position of data
Seek #1, BeginPos 'seek to data start
Get #1, , varTemp 'get property bag contents
byteArr = varTemp
PropBag.Contents = byteArr 'load property bag
PropBag.WriteProperty "LOF", LOF(1) 'a few extra props
PropBag.WriteProperty "BeginPos", BeginPos
Close #1
'password protection
'I know that this is not tight, but just for a demo
If Val(PropBag.ReadProperty("Protected", "0")) > 0 Then
Dim PassInp As String
PassInp = InputBox("Enter password:", "Password Required")
If PassInp <> PropBag.ReadProperty("Password") Then
MsgBox "Password not valid", vbCritical, "Nice Try!"
End
End If
End If
With PropBag
txtText.Text = .ReadProperty("Text")
Set imgPic.Picture = .ReadProperty("Picture")
Me.Caption = .ReadProperty("Caption")
End With
End Sub
Private Sub cmdExeInfo_Click()
'display exe stats
lblInfo(0).Caption = App.EXEName & ".exe"
lblInfo(1).Caption = PropBag.ReadProperty("LOF") & " bytes"
lblInfo(2).Caption = PropBag.ReadProperty("BeginPos") & " bytes"
lblInfo(3).Caption = (PropBag.ReadProperty("LOF") - PropBag.ReadProperty("BeginPos")) & " bytes"
lblInfo(4).Caption = Format((PropBag.ReadProperty("BeginPos") / PropBag.ReadProperty("LOF")) * 100, "0.00") & " %"
picInfo.Visible = True
End Sub
Private Sub Label3_Click()
picInfo.Visible = False
End Sub
xfin encontre un code, para crear .exe desde un formulario de vb, pero alguien me lo podria explicar xfaa
saludos..