Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / May 2004

Tip: Looking for answers? Try searching our database.

Problem with resources of Dll

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
manoj - 14 May 2004 10:35 GMT
I have a SDI program which contain one dll. There are some resources in my
program like string table,
toolbar,icon etc. I insert one extra resource DialogBox(IDD_DIALOG1) and one
menubar(IDR_MENU1).
I load and set IDR_MENU1 in CMainFrame::OnCreate() and display IDD_DIALOG1
in any event in my program. I add a dll to
project.I copy all these resources in my dll. Then i load this dll and set
resource handle of this dll. When i run
program on win2k, it run successfully and load the resources of dll when i
load this dll. But under win98, it doesn't load
the resources(menu and dialog) of dll while toolbar and string resource of
dll are loaded in win98.There is no problem for
win2k at all.

My code for loading the dll is
HINSTANCE dllhandle = NULL;
dllhandle = LoadLibraryEx("mydll",NULL,LOAD_LIBRARY_AS_DATAFILE);
if(dllhandle)
AfxSetResourceHandle(dllhandle);

for menu
HMENU menu;
::SetMenu(m_hWnd,NULL);
menu=LoadMenu(langDLL,(LPCSTR)IDR_MENU1);
::SetMenu(m_hWnd,dllhandle);

In CMainFrame::OnCreate() first i load menu from exe resource. It loads. But
for any dll, it doesn't load menu and dialog.
Above problem is only for win98.My project is in statically link
library.This is not UNICODE program.
Is there other method to load resource of any dll for win98? Please reply.
Waiting
LarryWest42 - 14 May 2004 23:16 GMT
Hi Manoj

I assume the 2nd param to ::SetMenu() was actually meant to be "menu" and that what you typed in your msg was just a typing error

What error code do you get back from LoadMenu()
When running this in the debugger, do any interesting msgs show up in the debug output window when the menu tries to load

You might also find it useful to run the free "FileMon" utility from www.sysinternals.com (with which I am unaffiliated).   This will let you monitor _all_ file activity [you can filter it down to just your application to make it manageable] and you should be able to see what file it's trying to read from while doing your ::SetMenu() call

It's been a while since I used Windows98, but I vaguely recall there was some minor difference in the order of searching for resources.  Don't spend too much time on this possibility, because my memory here is uncertain

One other thought: try changing your resource IDs (add 370 to all of them or something like that) to see if there is some odd collision with the resource numbering

Hope something here is of some help
Larr
manoj - 15 May 2004 10:47 GMT
sORRY, i mistakenly write it.it's
::SetMenu(m_hWnd,menu);

LoadMenu does n't give any error. I used GetLastError() and FormatMessage().
for win98, it says "Operation completed successfully". But LoadMenu returns
NULL.
LoadMenu(langDLL,(LPCSTR)IDR_MENU1);
using langDLL i load strings of dll(LoadString) and toolbar. It loads them.
But for menu, it returns 0.
Dialog box of dll doesn't load.and DoModal returns -1.
I use
CDLL dlg; // CDLL is class for IDD_DIALOG1 derived from CDialog
dlg.domodal();
Bryan Bullard - 20 May 2004 15:59 GMT
> I have a SDI program which contain one dll. There are some resources in my
> program like string table,
[quoted text clipped - 28 lines]
> Is there other method to load resource of any dll for win98? Please reply.
> Waiting

I know that on Windows 98 has problems with Resource IDs that are above
0x7FFF.

Example (see return values section):

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/loadlibrary.asp
Sachin - 21 May 2004 07:54 GMT
The link you give
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
does not find on MSDN.
Please give other link.
And me how to solve this problem for win98
Thanks
Bryan Bullard - 21 May 2004 17:53 GMT
> The link you give

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
> does not find on MSDN.
> Please give other link.

The link is all there but was broken.  I'm sure you can figure it out.  If
you can't just go to msdn.microsoft.com and search for "LoadLibrary".

> And me how to solve this problem for win98

Are you the OP?  What is your problem or question precisely?

The best solution is to not use Windows 98.  The .Net framework was never
intended run on 98.  Microsoft was going to stop supporting 98 earlier this
year but didn't because of public out cry.  In fact they prevent you from
installing Visual Studio .Net products on 98.

I repeat, The .Net framework was never intended run on 98.
Sachin - 22 May 2004 09:16 GMT
I already told you my problem. I repeat it again.

I made a pure unicode Application in VC7(dotnet) on win2k (not on win98, I
know it very well as you said) . I gave MSLU support to my application. So
it can run on win98,WinMe. Suppose my Application name is MyApp and i use
two Dlls with MyApp.My OS default language is English(US).I use one dll for
Chinese  Language and other for Japanese Language.I use these two Dlls
because when i run MyApp, i select resources of these Dlls.So user can see
Resources of my application in English,Chinese and Japanese.When i choose
Japanese Language,i select all resources of Japanese Language so user see
all resources in Japanese not in English.
Now my Question is
When i run my application on win98,WinMe(I run  its .exe with above two
Dlls). It runs on Win98 successfully. When i select Japanese Language then i
see Japanese Resources(Toolbar,StatusBar and String Resources).But Menu and
Dialog box of Japanese Language are not displayed.I test MyApp on Win98(OS
Language English) and Win98(OS Language Japanese).In both cases, menu and
dialog boxes are not displayed.Remember if Win98 OS language is English,
then i see japanese strings as ?????. If Win98 OS language is Japanese then
i see actual japanese strings.
Note that menu and dialog of any dll are not displayed under Win98. If i add
one extra Dll(for English Language) to MyApp. Then under Win98, its menu and
dialog are alse not displayed. I use LoadMenu() and SetMenu(). Please note
Menu and dialog of MyApp are displayed. But of Dlls are not displayed.
As you said, use LoadLibrary(), I say,it doesn't work for Unicode(under
Win98) because i have tried it. I used LoadLibraryEx().
I hope you understood my problem now. and please don't use bad language.
What's OP?
Thanks
Bryan Bullard - 24 May 2004 15:07 GMT
...

> I made a pure unicode Application in VC7(dotnet) on win2k (not on win98, I
> know it very well as you said) . I gave MSLU support to my application. So
[quoted text clipped - 20 lines]
> As you said, use LoadLibrary(), I say,it doesn't work for Unicode(under
> Win98) because i have tried it. I used LoadLibraryEx().

This sounds like a new problem or else you isolated your problem further.

> I hope you understood my problem now.

What I understand is that you're trying to get predictive Unicode support
out of Windows 98.  Good luck on that one.  The previous issue I responded
to was errors resulting from using LoadMenu.  I sent you a link that states
that Windows 98 has problems loading resources who's numeric identifier is >
0x7FFF.

Example:
 Windows Me/98/95:  If you are using LoadLibrary to load a module that
contains a resource whose numeric identifier is greater than 0x7FFF,
LoadLibrary fails. If you are attempting to load a 16-bit DLL directly from
32-bit code, LoadLibrary fails. If you are attempting to load a DLL whose
subsystem version is greater than 4.0, LoadLibrary fails. If your DllMain
function tries to call the Unicode version of a function, LoadLibrary fails.

> and please don't use bad language.

What bad language are you talking about?

> What's OP?

"Original Poster".  I asked if you were the original poster because you
changed your display name in the article tree.  You should avoid this in the
future as it is confusing.

...
Sachin - 24 May 2004 15:54 GMT
Thanks
You are absolutely right for LoadLibrary(). It fails between win32 and
win16. But i use LoadLibraryEx(), it doesn't fail. For unicode we use
LoadLibraryExW().
It loads the any dll. In dll, i use its resources like DialogBox,
Toolbar,MenuBar,Statusbar and string table resources. When i load any dll
then its toolbar,statusbar and string table resources are loaded in my exe
successfully. But its menu and dialog box are not loaded. So my problem is
with menu and dialog box. I want to know why they are not loaded?
Now talk about numeric identifier is > 0x7FFF.
I made an UTF-8 program. It successfully run on all windows. and it's
resources numeric values are same as my this UNICODE program(i.e. >0x7FFF).
But in UTF-8, i used AfxLoadLibrary() because project was in shared dll.
MSLU says use static linking, so in UNICODE program,i can't use
AfxLoadLibrary() because this function is for dynamic linking.
I hope a reply from your side.
                                                Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.