If I read your question correctly, you just want to store a little data in the application EXE....
You can do that but modifying the data at a later date is a little tricky under Windows. I started doing this when I required an app that needed unquestionable security for its configuration settings (I didn't want the user to locate and delete or modify a separate data file).
Basically, this requires two copies of the EXE to be present on the system. Prior to packaging your app you must create a small utility to save the initial data to the EXE. This might consist of a few lines of code similar to:[tt]
MyText$ = "Placeholder for my data."
TxtLength& = Len(MyText$)
ff = FreeFile
Open "MyApp.exe" For Binary as #ff
FileLength& = Lof(ff)
Put #ff, FileLength& + 1, MyText$
Put #ff, FileLength& + 1 + TxtLength&, TxtLength&
Close #ff
[/tt]
This just appends MyText$ here to the end of the EXE and then appends a long variable noting the length of MyText$. (You would probably use a user defined Type scructure instead of a string. I just show a string for the sake of simplicity.)
When "MyApp.exe" is executed it checks for the existence of its clone. If, for instance, "MyApp2.exe" does not exist, it performs a [tt]
FileCopy "MyApp.exe" "MyApp2.exe"[/tt] (you would probably use
[tt]App.Path & "\" & App.ExeName[/tt] to simplify matters).
The next step would be to retrieve the data from "MyApp2.exe":[tt]
ff = FreeFile
Open "MyApp2.exe" For Binary as #ff[/tt]
Get #ff, Lof(ff)-3, TxtLength&
MyText$ = String$(TxtLength&, 0)
Get #ff, Lof(ff) - TxtLength& -1, MyText$
Close #ff[/tt][/b]
'Show the text in the Text box
[tt]
Text1.Text = MyText$
[/tt]
If you are only interested in storing fixed data in the executable, there is no need to use a clone of the EXE. Windows doesn't object to
reading from the EXE of a running application. It objects strongly when one trys to
modify an EXE while it is running. Hence, the clone.
This is where the scheme gets a bit complex. Whenever the data is changed (written to the clone) the main app must shell to the clone, unload and terminate. The clone must wait for the main app to terminate (or force a termination with SendMessage) and then overwrite it with the updated EXE.
All of the above fall under the heading of "Extreme Measures" and don't apply to most situations. The simple way to do this is to write the data to the registry or save it in an INI or data file. I only posted this solution to show a way to save data when normal methods are inadequate. And, although somewaht complex, it actually works. I have a VB app that stores three separate applications appended to the VB EXE (two DOS based EXE's and a COM executable). The VB app extracts and runs them, as needed, and then removes them from the system to maintain security.
Alt255@Vorpalcom.Intranets.com