Author Topic: Creating apps with a resource dll  (Read 2297 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Guest
Creating apps with a resource dll
« on: April 01, 2014, 11:06:04 PM »
Hello,

the following statements are meant for newbies in Oxygenbasic like me.

When I started to learn about Oxygenbasic and tried to use the WinApi I learned about the idea of using a dll containing the menus, dialogs, controls, images etc as resources.

The resources are kept in a .rc file and are compiled e.g. with GoRc.exe, which is already included with Oxygenbasic. The created res file can then be linked with LinkRes2Exe.exe to the final dll file.

The source for the Resource.dll is rather trivial:

Code: [Select]

$dll
$filename "<dll_filename>.dll"
 
includepath "$/inc/"
 
#include "RTL32.inc"
'#include "RTL64.inc" 
                                                 
// do nothing


Compiling the Resource.o2bas file with gxo2.exe and linking the dll with the Resource.res file via LinkRes2Exe will give the final Resource.dll.

There are some nice Resource editors like ResEdit or ResEd or others which could be used to create or change resource files. As the resource.rc script is a plain text file it can also be created and edited by hand. The documentation for this I found at Jeremy Gordon's Go Tools web site or in the help files for the ResEd program.

In my opinion using a resource dll can help with developing an application. After creating the Resource.dll in the development stage, gxo2.exe can be used like an interpreter. Therfore I am not obliged to compile and link everything from scratch if something does not work. And if everything goes well I can also build an independant application.exe without too much effort.

As an example I would like to use the WinResources demo of Charles which I found in this forum (Compiling with Resources). If you unzip the attached file you will find two batch files in the created directory. Maybe the path for Oxygenbasic must be changed in these files. For the examples I used the O2h build of March 23 2014.

WinResources1.o2bas contains the code for use with a dll resource. Build_with_dll.bat should create the dll file and start WinResources1.o2bas. If you uncomment the statement '#include "RTL32.inc" in WinResources1, there should be build an executable which also needs the resource dll.

WinResources2.o2bas shows the code for creating an independant executable which must be linked directly with the created .res file. This is done with build_only_exe.bat. By comparing the two source files you will find the seven or eight places which need a change.

I only could try this example with win32 on a 32-bit Windows system. But I think it should be possible to use a similar approach with a 64-bit Windows system.


Roland



.
« Last Edit: April 01, 2014, 11:38:01 PM by Arnold »

Aurel

  • Guest
Re: Creating apps with a resource dll
« Reply #1 on: April 02, 2014, 03:28:18 AM »
Quote
In my opinion using a resource dll can help with developing an application
Yes can help but what is the point of using standard windows controls from external
dll when you can create controls directly with source code using include file and on that
way create compact PE file.
Resources are mostly used as bmp,manifest,strings..etc

Arnold

  • Guest
Re: Creating apps with a resource dll
« Reply #2 on: April 02, 2014, 08:05:04 AM »
Yes, there could be used a library to do a lot of things. But I came to the conclusion that this is not a trivial job. Nevertheless I would use a library if it makes life easier.

Roland