-
Funktion auflösen
Hallo Leute brauche dringend einen guten Rat.
Kann man diese beiden abschnitte zusammenfassen, sodass man die Funktion nicht mehr aufrufen brauch ?
Code :
Private Function LoadFile(sPath As String) As String
Dim lFileSize As Long
Dim sData As String
Open sPath For Binary Access Read As #1
lFileSize = LOF(1)
sData = Input$(lFileSize, 1)
Close #1
LoadFile = sData
End Function
Private Sub Build_Click(Index As Integer)
Dim sBuff As String
Dim sSize As String * 8
Open App.Path & "\Test.exe" For Binary Access Write As #2
sBuff = LoadFile(App.Path & "\stub.exe")
Put #2, , sBuff
sBuff = LoadFile(Text1)
Put #2, , sBuff
sSize = Len(sBuff)
Put #2, , sSize
Put #2, , 27
Close #2
End Sub
Also Function LoadFile weg...
-
[Das erinnert mich grad irgendwie an EPL mit den ganzen substitutions *sigh*]
One way of doing it:
Code:
Private Sub Build_Click(Index As Integer)
Dim sBuff As String
Dim sSize As String * 8
Open App.Path & "\Test.exe" For Binary Access Write As #2
' Declare once use as many times you want
Dim sPath As String
Dim sData As String
' Substitution
sPath = App.Path & "\stub.exe"
Open sPath For Binary Access Read As #1
lFileSize = LOF(1)
sData = Input$(lFileSize, 1)
Close #1
' Subsitution End
sBuff = sData
Put #2, , sBuff
' Next one
sPath = Text1
Open sPath For Binary Access Read As #1
lFileSize = LOF(1)
sData = Input$(lFileSize, 1)
Close #1
' Done
sBuff = sData
Put #2, , sBuff
sSize = Len(sBuff)
Put #2, , sSize
Put #2, , 27
Close #2
End Sub
So das war jetzt fast eine braindead substitution geht natuerlich noch viel schoener aber das ueberlasse ich dir :D
Und was das bringen soll frag ich erst gar nicht weil normal wennst was mehrere male used verwendet man ja ne function (und die hast du ja grade "aufgeloest"
N.B noch nie VB.net gecoded aber denke das passt so
MFG
-
Vielen Dank erstmal !!!:) Ich glaube es geht.
Ich check das mal...
-
Veruchs auch ma so
Code:
Private Sub Build_Click(Index As Integer)
Dim sBuff As String
Dim sSize As String * 8
Dim lFileSize As Long
Dim sData As String
Open App.Path & "\Test.exe" For Binary Access Write As #2
Open (App.Path & "\stub.exe") For Binary Access Read As #1
lFileSize = LOF(1)
sBuff = Input$(lFileSize, 1)
Put #2, , sBuff
Close #1
Open text1 For Binary Access Write As #1
lFileSize = LOF(1)
sBuff = Input$(lFileSize, 1)
Put #2, , sBuff
sSize = Len(sBuff)
Put #2, , sSize
Put #2, , 27
Close #1
Close #2
End Sub
btw. das sieht aus wie der Binder Source vom HamHam ( ^^)
-
@big earl: irgendwas stimmt mit deinem code nicht, er funzt leider nicht.
ist übrigens die source von cryptosy-crypter
Meiner hat mittlerweile diese Form angenommen :
Private Sub Build_Click(Index As Integer)
Dim sBuff As String
Dim sSize As String * 8
Dim sPath As String
Dim sData As String
Dim lFileSize As Long
Open App.Path & "\Test.exe" For Binary Access Write As #2
Open App.Path & "\stub.exe" For Binary Access Read As #1
lFileSize = LOF(1)
sData = Input$(lFileSize, 1)
Close #1
sBuff = sData
Put #2, , sBuff
Open Text1 For Binary Access Read As #1
lFileSize = LOF(1)
sData = Input$(lFileSize, 1)
Close #1
sBuff = sData
Put #2, , sBuff
sSize = Len(sBuff)
Put #2, , sSize
Put #2, , 27
Close #2
End Sub
Was mich sehr interessiren würde ist:
Kann man den code nicht in dieser form funktionsfähig machen, ohne die stub verändern zu müssen :
Open App.Path & "\stub.exe" For Binary Access Read As #1
...
Open Text1 For Binary Access Read As #1
...
Open App.Path & "\Test.exe" For Binary Access Write As #2
...