Sign in to follow this  
Followers 0
thesnow

how to load text resource from dll or exe?

6 posts in this topic

how to load text resource from dll or exe?

autoit crashed

#AutoIt3Wrapper_useansi=y
$Filehwnd=_API_LoadLibraryEx("shell32.dll",2)
MsgBox(32,"",$Filehwnd)
$te         =   _LoadString($Filehwnd,4184)
MsgBox(32,"",$te)

Func _API_LoadLibraryEx($sFileName, $iFlags=0)
  Local $aResult
  $aResult = DllCall("Kernel32.dll", "hwnd", "LoadLibraryExA", "str", $sFileName, "hwnd", 0, "int", $iFlags)
  Return $aResult[0]
EndFunc


Func _LoadString($File,$id)
    Local $aResult
    $aResult    =   DllCall("user32.dll","string","LoadStringA","hwnd",$File,"uint",$id,"int",100,"int",255)
    Return $aResult
EndFunc

Yes,it's me.thesnoW :idiot: .welcome to my au3 websiteit's a Chinese forum.http://www.AutoitX.com----------------------

Share this post


Link to post
Share on other sites

use the right parameters

#cs

int LoadString( HINSTANCE hInstance,

UINT uID,

LPTSTR lpBuffer,

int nBufferMax

);

#ce

:)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

this will be very useful to get system-lang-strings for buttons, etc.

@jpm

where do you got this code and how is it to understand and to transform to autoit?

i think, this should be add into autoit, as for icons and bitmaps is already done.

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Share this post


Link to post
Share on other sites

$Filehwnd=_API_LoadLibraryEx("shell32.dll",2)
;MsgBox(32,"",$Filehwnd)
$te            =    _LoadString($Filehwnd,4184)
MsgBox(32,"",$te)

Func _API_LoadLibraryEx($sFileName, $iFlags=0)
  Local $aResult
  $aResult = DllCall("Kernel32.dll", "hwnd", "LoadLibraryExA", "str", $sFileName, "hwnd", 0, "int", $iFlags)
  Return $aResult[0]
EndFunc


Func _LoadString($File,$StringId)
    Local $aResult,$StringResult
    $aStrLen    =     DllCall("user32.dll","int","LoadString","ptr",$File,"int",$StringId,"str",$StringResult,"int",255)
    If $aStrLen > 0 Then
    Return $StringResult
    EndIf
EndFunc

this does not crash autoit, but it returns 0 only ??? <_<

who helps a beginner?


AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

no, i don't want to load strings from resources but from system-dlls to get the local language of the current system and to save translation by hand.

EDIT:

i got it work! :P

#AutoIt3Wrapper_useansi=y
Func _LoadString($File,$StringId)
    Local $String,$StringResult
    $Dll = DllCall("Kernel32.dll","hwnd","LoadLibraryExA","str",$File,"hwnd",0,"int",2)
    $String = DllCall("user32.dll","int","LoadStringA","ptr",$Dll[0],"int",$StringId,"str",$StringResult,"int",255)
    If $String[0] > 0 Then Return $String[3]
EndFunc
Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0