Loading strings from system DLLs

Share your advanced PureBasic knowledge/code with the community.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Loading strings from system DLLs

Post by Hroudtwolf »

Hi,

I made following little example for a member of the purebasic-lounge.com chat.
It shows, how to load strings from stringtable in a DLL file on windows.
To load strings from system DLLs is very advantageous.
'Cause so you can abstain from language files in many cases and the texts in shell32 and user32 DLLs are by default in the language of the current windows installation. (IMHO&AFAIK)

You can examine the IDs of stringtable strings very easy by using the legendary ressourcehacker tool.

Downloadable here: http://angusj.com/resourcehacker/

Code: Select all

; Http://www.purebasic-lounge.com
; Hroudtwolf
; PureBasic 4.x
; Windows


Define.l hLib        = LoadLibrary_( "shell32.dll" ) ; Loading library
Define.s sptrBuffer  = Space ( 255 )                 ; Buffer for receiving strings
Define.l lI

If Not hLib ; DLL not found ?
   End
EndIf

; Examining strings from lib
For lI = 60 To 63 ; IDs 60-62
   LoadString_( hLib ,lI , @ sptrBuffer , 255 )
   Debug sptrBuffer
Next lI

For lI = 4161 To 4175 ; IDs 4161-4175
   LoadString_( hLib ,lI , @ sptrBuffer , 255 )
   Debug sptrBuffer
Next lI

FreeLibrary_( hLib )
Regards

Wolf
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

You can load and free the DLL via PB, so no need for API variants. Also you shouldn't use ResourceHacker since it's buggy and outdated.
Use XN ResourceEdior instead:

http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

You can load and free the DLL via PB, so no need for API variants.
I don't think so. ;-)
PB functions are overhead in this case.
'Cause this example runs only on windows whatever I use instead of LoadLibrary/FreeLibrary.

Thanks for your commend of XN-Resource Editor.

Regards

Wolf
Post Reply