Unicode from resource dlls under Win9x

I want to do this :
http://support.microsoft.com/support/kb/articles/Q196/8/99.asp

But instead of loading it from the exe itself, I need the Unicode text
resource from a dll.


I tried :

HINSTANCE DllHandle = LoadLibrary ("resource.dll")  ;

hRC = FindResourceEx(DllHandle,
         RT_STRING,
         MAKEINTRESOURCE(block) ,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));

hRC always seems to be NULL but DllHandle is a valid handle to the resource
dll.

Any ideas ???
sneeuwAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
NetminderConnect With a Mentor Commented:
Points refunded and question closed.

Netminder
Community Support Moderator
Experts Exchange
0
 
robpittCommented:
FindResourceEx requires that the language specified match *exactly*.

You might want to use FindResource instead.



0
 
sneeuwAuthor Commented:
Same Problem !!!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
robpittCommented:
Thats odd, I have used the same trick myself and it works.

I can only suggest you double check everything...

-  Are you sure the string is actually in the DLL?
   (Check this by opening the DLL "As Type : Resource")
-  Does the DLL load correctly?
-  Is the dll module hinstance valid?
-  Is the resource Id computed correctly (i.e. stringId/16+1 )





0
 
robpittCommented:
RE : "(Check this by opening the DLL "As Type : Resource")"
I refer to a feature on the "File | Open..." menu of Visual Studio if you have it.
0
 
sneeuwAuthor Commented:
Here's the code :
(Tried several things already (commented out))

UINT block = (Identifier >> 4) + 1;   // Compute block number.
UINT num   =  Identifier & 0xf;       // Compute offset into block.

HMODULE DllHandle = LoadLibraryEx("D:\\Builder\\Projects\\IsoBuster\\Lang\\russian.dll", 0, LOAD_LIBRARY_AS_DATAFILE );
// HMODULE DllHandle = LoadLibrary ("D:\\Builder\\Projects\\IsoBuster\\Lang\\russian.dll") ;
// HMODULE DllHandle = NULL ;

HRSRC   hRC = FindResourceEx(DllHandle, RT_STRING, MAKEINTRESOURCE(block) , MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));

/*
hRC = FindResource(
    DllHandle,     // resource-module handle
    MAKEINTRESOURCE(block) ,     // pointer to resource name
    RT_STRING      // pointer to resource type
   );
*/

HGLOBAL hgl = LoadResource(DllHandle, hRC);
LPWSTR  str = (LPWSTR)LockResource(hgl);

int len = 0 ;      
if (str)
    {
    for (UINT i = 0; i < num; i++)
        {
        str += *str + 1 ;
        }
    xstring.assign(str + 1, *str) ;
    len = *str ;
    }
if (DllHandle) FreeLibrary(DllHandle) ;
return len ;
0
 
sneeuwAuthor Commented:
But it already fails while trying to get the handle :

hRC

Using FindResource or FindResourceEx

I think computing the variables is OK because :
- It's the same as done in the MS example
- It works great IF DllHandle is NULL !!!!!

That is, I have build a piece of the resource in the exe to test.  When this is done and DllHandle is NULL, the exact text is found in the exe itself !

I use Borland cpp Builder 5
I compile under Win98
0
 
robpittCommented:
I'm affraid I have little else to add.
It should work!


What ever is preventing it from working is probably subtle and will cause you to kick your self when you stumble accross it.

BTW : There a useful resource viewer (PE Explorer) at http://www.heaventools.com

0
 
sneeuwAuthor Commented:
How subtle can it be ?
There must something I don't know yet or something I'm missing ??

I mean ... if you copy the code in your project ... does it work ?

If so, why and not on my system ?

I work under Win98 but found no reference describing issues under Win98 ?

The resoure viewer looks nice indeed !
I don't know how this can help me though ?

Can it be that a dll needs to be build in a special for the function to succeed ??
LoadString() using these dlls works like a charm !
0
 
robpittCommented:
The only reason I pointed you at the resource viewer was to verify that the dll did indeed contain the strings resources in the appropriate language.

Anyway if you want... post the dll to robpitt@cyberdude.com and I'll have a go at loading a string using the sample code above.
0
 
robpittCommented:
Just took a quick look at the DLL you sent me... it would appear to contain strings marked as DUTCH [BELGIUM] ???

That hardly seems right - I think you should look closely at how this dll was made.

For a quick fix change the language in FindResourceEx to MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH_BELGIAN)

0
 
sneeuwAuthor Commented:
The dll was made in Belgium all right !!
I had no idea that is automatically added ?

Anyway, I tried it but the result stays the same !!
0
 
robpittCommented:
Well I just compiled a test program and it worked - I even got a bunch of Cyrillic looking text on the screen!

The only significant change was:

hRC = FindResourceEx(hDll, RT_STRING, MAKEINTRESOURCE(block) , MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH_BELGIAN));



I say again you should look at how you are compiling your dll because its resources are being flaged as the wrong language.
0
 
sneeuwAuthor Commented:
> I even got a bunch of Cyrillic looking text on the
screen!

Nice.  What OS and with what app did you build ?
Borland cpp Builder will still convert the Unicode to MBCS so that the CodePage has to match the language to get someting Cyrillic looking.

Frustrating it doesn't work here !?
I have no explanation why ?
0
 
sneeuwAuthor Commented:
> I even got a bunch of Cyrillic looking text on the
screen!

Nice.  What OS and with what app did you build ?
Borland cpp Builder will still convert the Unicode to MBCS so that the CodePage has to match the language to get someting Cyrillic looking.

Frustrating it doesn't work here !?
I have no explanation why ?
0
 
sneeuwAuthor Commented:
> will cause you to kick your self when  you stumble accross it.

Just fainted from kicking myself too hard !!!!
Damn ...

the block :
> MAKEINTRESOURCE(block)
was incorrect

Thanks
0
 
NetminderCommented:
sneeuw,

These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days. Please note that the recommended minimum for an "Easy" question is 50 points.
http://experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=20183446
http://experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=20158806
http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20192985
http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20151309
http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20137274
http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20136466
http://experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20088277
http://experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20183228

EXPERTS: Please leave your thoughts on this question here.

Thanks,

Netminder
Community Support Moderator
Experts Exchange
0
All Courses

From novice to tech pro — start learning today.