LB Booster
IDE and Compiler >> Compiler >> embedded resource file
http://lbb.conforums.com/index.cgi?board=compiler&action=display&num=1404197429

embedded resource file
Post by ripvanwinkle on Jun 29th, 2014, 04:13am

I created a small program that uses a dll. When I create an exe of the program (with the dll embedded) and place it on the desktop and then run it, a copy of the embedded dll also appears on the desktop. Is there a way to prevent this behavior? Thanks!


Re: embedded resource file
Post by Richard Russell on Jun 29th, 2014, 10:00am

on Jun 29th, 2014, 04:13am, ripvanwinkle wrote:
Is there a way to prevent this behaviour?

I would first say that putting an executable on the desktop is never recommended, irrespective of the language in which it is created. Normally the EXE will be stored somewhere more appropriate (e.g. in C:\Program Files) and a shortcut to it placed on the desktop (and possibly also in the Start Menu). Creating such shortcuts is usually the responsibility of an installer.

So my preferred solution is to avoid the problem by not putting the EXE on the desktop in the first place! But if for some reason that is unacceptable your only alternative is to store your DLL not in the folder which contains the executable but instead in the temp folder. You can do that when you compile your program by using the Add Temp button instead of Add.

When your program runs you will need to specify the path to the temp folder when you OPEN the DLL (the GetTempPath API will return that string). You will also need to copy the DLL into the temp folder before you compile your program, in case it has been deleted from there.

Richard.
Re: embedded resource file
Post by ripvanwinkle on Jun 29th, 2014, 3:15pm

Understand! Thank you for your quick and complete answer!
Re: embedded resource file
Post by Richard Russell on Jun 8th, 2015, 5:43pm

A question has been asked at the LB Community Forum about embedded resource files (in the Global dim array question thread):

"I want the image to be compressed within the program. I am trying to put everything, including sounds, eventually inside a program efficiently."

Alyce has drawn attention to the Resource Hacker utility but of course LBB has a built-in mechanism for embedding resource files which automatically get extracted when the program is run. An advantage of the LBB approach is that the resources are available to the program as conventional files, but a possible disadvantage is that they are more easily examined by the end user.

Will somebody post a reply of the 'permitted' kind, i.e. that LBB provides an alternative solution, with a link to here?

Richard.
Re: embedded resource file
Post by Richard Russell on Jun 8th, 2015, 9:28pm

on Jun 8th, 2015, 5:43pm, Richard Russell wrote:
a possible disadvantage is that they are more easily examined by the end user.

If this is a concern, there are a couple of approaches to making a resource file less easily snooped on:
Richard.
Re: embedded resource file
Post by Richard Russell on Jan 1st, 2017, 1:58pm

I've received a query by email about the locations in which embedded resource files can be stored by LBB. Here are the options supported:
If a resource file is found already to exist, and is identical to the file embedded in the executable, LBB will not attempt to replace it. This allows a program to be stored in a 'protected' location (e.g. C:\Program Files (x86)\) with admin privileges required only the first time it is run.

Richard.