itto wrote:Danilo wrote:
Tested:
Win7 64bit english: "New Folder", "New Folder (2)", ...
WinXP Pro 32bit German: "Neuer Ordner", "Neuer Ordner (2)", ...
So this must be the same way Windows get the name of the new folder, this is awesome! the name changes according to the language of the OS!

Yep. But the "magic numbers" changed in Vista.
Here is the code to get the "magic numbers" for the first code (requires UNICODE compilation!):
Code: Select all
;
; http://blogs.msdn.com/b/oldnewthing/archive/2004/01/30/65013.aspx
;
Macro MAKELANGID(p,s)
( ( (s)<< 10) | (p) )
EndMacro
Procedure.s FindStringResourceEx(hinst,uId.l, langId.l)
;// Convert the string ID into a bundle number
;*pwsz = 0
hrsrc = FindResourceEx_(hinst, #RT_STRING,(uId / 16 + 1)&$FFFF,langId)
If (hrsrc)
hglob = LoadResource_(hinst, hrsrc);
If (hglob)
*pwsz.Unicode = LockResource_(hglob)
If (*pwsz)
*oldResPointer = *pwsz
i = 0
While i < (uId & 15)
*pwsz = *pwsz + 2 + (*pwsz\u * 2)
i+1
Wend
If *pwsz\u > 0
ret$ = PeekS(*pwsz + 2,*pwsz\u)
EndIf
;UnlockResource_(*oldResPointer)
EndIf
FreeResource_(hglob)
EndIf
EndIf
CompilerIf #PB_Compiler_Debugger
;If ret$
; Debug ret$
;EndIf
CompilerEndIf
ProcedureReturn ret$
EndProcedure
Procedure.s FindStringResource(hinst, uId.l)
;(LANG_NEUTRAL, SUBLANG_NEUTRAL) = Language Neutral
;(LANG_NEUTRAL, SUBLANG_DEFAULT) = User's Default Language
ProcedureReturn FindStringResourceEx(hinst, uId, MAKELANGID(#LANG_NEUTRAL, #SUBLANG_NEUTRAL))
EndProcedure
Procedure FindResourceStringId(resource_handle, string.s, langId)
resource_id = -1
For i = 0 To 65536 ;Step 16
resource_string.s = FindStringResourceEx(resource_handle, i, langId)
If resource_string
If resource_string = string
resource_id=i
Debug resource_id
Debug resource_string
;Break
EndIf
EndIf
Next
ProcedureReturn resource_id
EndProcedure
shell_handle = LoadLibrary_("shell32.dll")
new_folder_id = FindResourceStringId(shell_handle, "New Folder", $409); // look for US English "New Folder" resource id.
Debug "-----"
If new_folder_id
newfolder.s = FindStringResource(shell_handle, new_folder_id)
;MessageRequester("New Folder", newfolder )
Debug newfolder
Debug FindStringResourceEx(shell_handle, new_folder_id, MAKELANGID(#LANG_GERMAN ,#SUBLANG_GERMAN) )
Debug FindStringResourceEx(shell_handle, new_folder_id, MAKELANGID(#LANG_THAI ,#SUBLANG_DEFAULT) )
Debug FindStringResourceEx(shell_handle, new_folder_id, MAKELANGID(#LANG_ENGLISH ,#SUBLANG_DEFAULT) )
Debug FindStringResourceEx(shell_handle, new_folder_id, MAKELANGID(#LANG_FRENCH ,#SUBLANG_DEFAULT) )
EndIf
This code is not useful in end-user programs! You can get the "magic numbers" with it
and use them with the LoadString_() method.
It requires some testing (f.e. in a virtual machine) if you get more than 1 magic number.
For example test:
- Win7/Vista English and WinXP Englisch
plus:
- Win7/Vista German/Other and WinXP German/Other
The line:
Code: Select all
new_folder_id = FindResourceStringId(shell_handle, "New Folder", $409); // look for US English "New Folder" resource id.
does not work if english MUI is not installed. It works only with currently installed languages (I tested with German/English/Thai).