Re: Adding Resource To EXE
You open up your project that you want to add the Resource file to then press CTRL+D to add a VB file, find the *.res file and add it.
If you want to edit this res file then you have to Load VB6 Resource Editor from Add-Ins\Add-In Manager... and select VB6 Resource Editor and just put a tick in Loaded/Unloaded and Load on Startup checkboxes then you will see the green segmented cube on the menubar everytime VB starts up.
Re: Adding Resource To EXE
Oh sorry I think I need to rephrase my question.
Ok, I already created the resource file and added everything I want in it. I also already added the resource file to my VB6 application.
What I'm trying to figure out is the code that loads the resource file into my app.
As In what is the code that I need to put in Form_Load to load the resource file into my EXE.
Like this:
Dim FileNum As Integer
Dim DataArray() As Byte
DataArray = LoadResData(101, "CUSTOM")
FileNum = FreeFile
Open "WHAT DO I PUT HERE?" For Binary As #FileNum
Put #FileNum, 101, DataArray()
Close #FileNum
Erase DataArray
Re: Adding Resource To EXE
You can't add a resource to a running program.
Re: Adding Resource To EXE
I am trying to include my dll into my VB6 application so that I will not have to manually regsvr32 it myself.
How can I do that?
Re: Adding Resource To EXE
You ARE loading it.... that's what LoadResData(101, "CUSTOM") is doing... loading that resource into the byte array... so if it is a dll, you want to write it to a file, with the appropriate name... now after that... I don't know... since your app is already running, you can't add it as a reference so I'm not sure what you're trying to accomplish.
-tg
Re: Adding Resource To EXE
So If I put
LoadResData(101, "CUSTOM") into Form_Load
I won't have to download my dll and register it?
I have a dll file by the name of Chrome.DLL. I added this dll to a resource. I then added the resource to my VB6 application.
I want to use my application on other computers though and the problem with that is that I have to keep registering chrome.dll in order for my EXE to work because chrome.dll is added as a reference.
Im trying to make it so I just include/compile EVERYTHING into the one EXE file and then won't have to register the DLL anymore.
Re: Adding Resource To EXE
If it's referenced, then how can you use it if it's tucked into a resource file? Even if you extract the file and write it out to the system, you'd still need to rgsvr32 in order to use it...
Sounds like what you really need is an installer...
-tg
Re: Adding Resource To EXE
Yes, I referenced chrome.dll. Which means I have to manually register it for every computer I want to run my program on. Are you saying there is no other way to avoid this other than making an installer?
Re: Adding Resource To EXE
It has to be registered on the system somehow... if you don't want to do it manually, then an installer should be able to handle that for you.
-tg
Re: Adding Resource To EXE
I think the way it works is like this: During you app's load time the system loads all DLL's used by your app which all must have already been registered and puts them in their own processing space. This means that you cannot pull your DLL data out of the resource part of your app and then save it and then try to register it. Even if you could it wouldn't work as it was not loaded by the OS when your app first was launched. So, the only way is to include the DLL as part of your installer and have the installer register it for you then when your app is launched by the user the DLL is ready to go.
Re: Adding Resource To EXE
What you seem to be asking for is static linking. VB6 doesn't support that and in any case you link .LIB files, not .DLLs.
Of course in many cases you can use registration-free COM to avoid the need to register DLLs and OCXs. You still need to deploy them as private assemblies, but simply copying them is enough. This has been around since XP came out.