Is there any way to place recources not into the executable but e.g. into a DLL?
Recources
The subroutine use_resource_library@ allows you to use resources in a DLL.
For example the file mydll.f95 say:
SUBROUTINE test()
use clrwin
call use_resource_library@('mydll.dll')
iw = winio@('%ca[Bitmap]&')
iw = winio@('%bm[mybitmap]')
END SUBROUTINE
Resources are placed in a resource script res.rc say:
mybitmap BITMAP chimp.bmp
The main program is say main.f95:
PROGRAM main
call test()
END
Compile mydll.f95 and main.f95 using FTN95. Compile res.rc using SRC. Link mydll.obj and res.obj (for 32 bits) into a DLL. Link main.obj into the exe.
Paul,
I had
APP_ICON ICON ic_adplo.ico
DOTS3 BITMAP bt_3dots.bmp
BT_Draw BITMAP bt_Draw.bmp
bt_OK BITMAP bt_OK.bmp
bt_PngFileL BITMAP bt_PngFileL.bmp
bt_Exit BITMAP bt_ExitS.bmp
and
!$ AdploMain
!------------------------------------------------------------------
WINAPP !!! '..\icons\rc_Adplo.rc'
PROGRAM AdploMain ! Start program for ADPLO functions
! REV. 2019-AUG-01 Copyright: Dr. Erwin Kruck, Aalen, Germany, 1987 - 2019
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
USE GlobalData
USE AdploData
USE GrafFiles
IMPLICIT NONE
INCLUDE <clearwin.ins>
INCLUDE <win32api.ins>
INTEGER iRet
CHARACTER cString*8
INTEGER, EXTERNAL :: cb_SavePara, cb_ReadPara, AdploGUI, AdploDraw, cb_ReadCameraData
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - -
CALL rc$adplo ()
TaskName = 'ADPLO'
cGaphicFileName = 'Adplo_Graph_00'
iWindowHandle = 0
and created
SUBROUTINE rc$adplo ()
USE CLRWIN
IMPLICIT NONE
INTEGER MA
CALL USE_RECOURCE_LIBRARY@ ('BgoRes.DLL')
MA= WINIO@ ('%ca[ICON]&')
MA= WINIO@ ('%bm[APP_ICON]&')
MA= WINIO@ ('%ca[BITMAP]&')
MA= WINIO@ ('%bm[DOTS3]&')
MA= WINIO@ ('%bm[BT_Draw]&')
MA= WINIO@ ('%bm[bt_OK]&')
MA= WINIO@ ('%bm[bt_PngFileL]&')
MA= WINIO@ ('%bm[bt_Exit]')
RETURN
END SUBROUTINE rc$adplo
and
DLL
LOAD rc$adplo.obj
EXPORTALL
FILE D:\Bingo\bin\BgoResources.dll
But the program do not start with message, that app_icon is not available
You should compile the resource script using SRC. If the script is resource.rc then for 32 bits the output is resource.obj.
Then LOAD resource.obj with the other obj file when running SLINK.
All my software is 64 bit !?
OK. The only difference is that you must use /r when compiling with SRC. The result is a .res file resource.res say. Then you load resource.res with the DLL obj64 file when linking and createing the DLL with SLINK64.
File MakeResourceDLL.bat:
FTN95 rc$adplo.f90 /no_banner /64 /opt /MOD_PATH ..\Moduls
src /r rc_adplo.rc
SLINK64 @BgoRecources.lk
File BgoRecources.lk:
DLL
LOAD rc$adplo.obj
LOAD RC_ADPLO.RES
EXPORTALL
FILE D:\Bingo\bin\BgoResources.dll
Result:
D:\Bgo_7.2\IconsDLL>MakeResourceDLL
D:\Bgo_7.2\IconsDLL>FTN95 rc$adplo.f90 /no_banner /64 /opt /MOD_PATH ..\Moduls
D:\Bgo_7.2\IconsDLL>src /r rc_adplo.rc
[Silverfrost SRC/WIN32 Ver 4.20 Copyright (c) Silverfrost Ltd 2018]
D:\Bgo_7.2\IconsDLL>SLINK64 @BGORecources.lk
[SLINK64 v2.04, Copyright (c) Silverfrost Ltd. 2015-2018]
Loading D:\Bgo_7.2\IconsDLL\rc$adplo.obj
Loading D:\Bgo_7.2\IconsDLL\RC_ADPLO.RES
Creating dynamic link library D:\Bingo\bin\BgoResources.dll
The following symbols were not defined:
USE_RECOURCE_LIBRARY@
D:\Bgo_7.2\IconsDLL>
Where to find USE_RECOURCE_LIBRARY@ ?
USE_RESOURCE_LIBRARY@ (note the spelling) should be available via USE clrwin or INCLUDE <clearwin.ins>.
Yes it is. Sorry, a typing error.
I have sent you an email
I am very sorry for this error but it now appears that use_resource_library@ is not working as it should for 64 bit DLLs.
At the moment I am assuming that it is a SLINK64 issue and I have referred it to the author.
Unfortunately I am not able to provide a work around.
Is there a Windows API behind which I could use instead?
Background: To protect my software against illegal copies I use a CodeMeter dongle from WIBU. Every executable will be put into an envelope and can be encrypted only using the dongle. It seems, that the WIBU software has a bug which has had not any effect since years. But since Windows 10 Version 1909 the resources inside my executables are not found anymore - my software does not work! My idea was to put all resources into a file (DLL) which will not be protected with a WIBU envelope to get my software working again.
I don't have anything to offer at the moment except the hope that we can get a fix soon from the author of SLINK64, then I will be able to send you a new SLINK64.
Good news. I made a mistake when creating my sample demo and this works as expected.
Please download the demo via the following link...
https://www.dropbox.com/s/phq43gatxmcxos5/ResourceStuff.zip?dl=0
The call to use_resource_library@ has been made redundant for the next release of ClearWin+.
ClearWin+ will automatically look for resources in the executable and in any attached DLLs that were created using FTN95 or SCC.
The above download and sample will in future not need the call to use_resource_library@.
Paul,
Is that the right approach? Presumably, if one has to call use_resource_library@, then it might be possible to put all the icons etc relating to a particular, customisable, appearance in its own library, and then other appearances in other libraries. Then, load the appropriate library at startup.
I'm not sure how you would switch 'themes' on the fly with this.
Eddie
Eddie
If a DLL is not loaded then the ClearWin+ library will not be able to find resources in it. Perhaps I am missing something but the new approach seems sound to me.
Absolutely no adverse criticism intended. It was a question, really. If it was possible to selectively load dlls, and someone had used that to set optional themes, then loading all dlls would lead to multiple definitions - maybe? That's all.
Eddie
I didn't take it as a criticism.
By way of further explanation, the new mechanism will only kick in when the existing one fails to find the resource, a kind of 'long stop'. So the existing mechanism will continue to work as now.