Page 1 of 3

UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Sat Jul 08, 2006 7:49 am
by ts-soft
This library create compiled userdefined resources without another
resource-compiler, without resource-script or temporary files.
The resourcetyp is "PBDATA". Only ID-numbers, no name for the resources.

The resources can automatically packed and unpacked with brieflz. (included
in this library)

This is a good alternate to IncludeBinary. Resources a not loaded
automatically in RAM with exe or dll, other then IncludeBinary.

Only Import the created *.res and use the resource with the functions from
this lib.

English-Help and Examples included.

Download

//edit
New downloadlink

Posted: Sat Jul 08, 2006 11:18 am
by srod
Thank you ts-soft, this is very interesting. :)

I don't know a great deal about resource files. However, I'm working on a large project in which I've created quite a large resource script containing a whole bunch of icons which I then load with LoadIcon_() and display with DrawIconEx_(). Can I still do this with UDRES? My fear is that if I use CatchImage(), this then regards the icon as a bitmap and I lose the ability to display the icon with a transparent background!

I guess I'm asking if there's a way of combining UDRES with my own resource scripts also?

Impressive work nevertheless.

Thanks again.

Posted: Sat Jul 08, 2006 2:35 pm
by ts-soft
@srod
Sorry, in the moment only userdefined resources. The only possible
ResourceType is "PBDATA" (same as RC_DATA, but another name)

I have no information to load it other than as this:

Code: Select all

ResName.s = "#" + Str(ResNumber)

hFind = FindResource_(hModule, ResName.s, @"PBDATA")
If hFind
  hLoad = LoadResource_(hModule, hFind)
  hSize = SizeofResource_(hModule, hFind)
  hLock = LockResource_(hLoad)

  Mem = AllocateMemory(hSize)

  If Mem
    CopyMemory(hLock, Mem, hSize)
    FreeResource_(hLock)
    ProcedureReturn Mem
  EndIf
EndIf 
The Resource Header is a dynamic Structure, it's not so easy and the
documentation isn't good, but i will enhance it in the future :wink:
So in the moment only Catch from Mem or Save to disk, but all binarys are
no problem (Catch RTF oder LoadLibraryM and so on)

I hope there comes more features in the next releases

Posted: Sat Jul 08, 2006 2:55 pm
by srod
I understand.

Thanks.

Posted: Sat Jul 08, 2006 3:44 pm
by ts-soft
I will add extra function for icons (only numbered) and stringtable. Would this
be sufficient?

Posted: Sat Jul 08, 2006 4:09 pm
by srod
That would be brilliant and cover about all of my needs as far as resources go.

This is going to be one handy little library. :D

Posted: Sat Jul 08, 2006 6:59 pm
by ts-soft
Big problem with icon and so on.
The first off header a long is the datasize, but this is different :cry:
DataSize The size of the data that follows the header. This value does not include any file padding bytes added after the actual data.
The format of the data is different for any of the possible resource types. Data size is expressed in BYTEs (8 bit unsigned integer).
The real DataSize doesn't work, i have no information to change this value
Compiled with Porc, this value isn't the FileSize, so i don't know, what is the
DataSize for icons :?:

Posted: Sun Jul 09, 2006 1:17 pm
by srod
Sorry I can't help at the mo, it's beyond my experience.

Posted: Sat Oct 07, 2006 12:43 am
by ts-soft
Update

New functions:
UDRes_GetFunction
UDRes_GetPackFunction
The same Functions as GetFunction in PB, but directly for a DLL in Resource
Is DLL not loaded, so loadet automatic in memory and unload at programend.
Example:

Code: Select all

#PB_DLL = 1

Import "PureBasic.res" : EndImport

CallFunctionFast(UDRes_GetPackFunction(#PB_DLL, "EasyRequester"), "Test")
Also added a threadsafe version as subsystem

Download in first post

regards
Thomas

Posted: Tue Oct 10, 2006 4:28 am
by ts-soft
Update

New Functions:
UDRes_CatchImage
UDRes_CatchPackImage
UDRes_CatchSound
UDRes_CatchPackSound
UDRes_CatchSprite
UDRes_CatchPackSprite
Nearly the same as the catchfunctions in PB, but for UserDefinded Resources
All Catched Sounds, Sprites or Images a only ones in Memory, other than
IncludeBinary!

Download in first post

regards
Thomas

SO how do i move from this DLL call to a res file

Posted: Tue Oct 31, 2006 3:51 am
by danraymond
How do I use UDRes to get rid of this:

Code: Select all

OpenLibrary(0,"mt19937ar.dll"); opens random generator library
CallFunction(0, "init_genrand", timeGetTime_()); seed the PRNG
*genrand31 = GetFunction(0, "genrand_int31"); get pointer to function in the dll
then later in the code I do:

Code: Select all

myrandom=mindemand+Int(CallFunctionFast(*genrand31)/#MAXLONG *(maxdemand-mindemand))
so I what changes to both codes and what do I do with UDREs to achieve it?

Thanks

Dan Raymond

[/code]

Posted: Tue Oct 31, 2006 8:31 am
by ts-soft
use this for example:

Code: Select all

init_genrand = UDRes_GetFunction(1, "init_genrand")
CallFunctionFast(init_genrand, timeGetTime_())
*genrand31 = UDRes_GetFunction(1, "genrand_int31")
(DLL has Resourcenumber 1 in the example)

Posted: Thu Nov 02, 2006 2:01 am
by srod
Excellent work ts-soft.

Thanks.

Posted: Thu Nov 02, 2006 2:05 am
by ts-soft
srod wrote:Excellent work ts-soft.

Thanks.
thanks :D

Posted: Tue Jan 09, 2007 7:39 pm
by ts-soft
Update:
Added 2 Functions

Code: Select all

UDRes_GetModuleHandle(ResNumber.l [, hModule.l]) 
UDRes_GetPackModuleHandle(ResNumber.l [, hModule.l])
The result is the ModuleHandle. With this, you can load all resources from included DLL