Solved

Unicode for win98

Posted on 2004-04-12
36
2,885 Views
Last Modified: 2013-11-20
I want to make an unicode application which run on win2000 and win98.
My application run on win2000 successfully but for win98 it gives error like "Debug Assertion Failed".
I define UNICODE  in project setting,wWinMainCRTstartup and undefine MBCS,and include all libraries. I'm using vc++7.0.
Anybody Please tell me what project settings we use either for vc6.0 or vc7.0.
or give me an MFC example.
Need A help
                       waiting
0
Comment
Question by:ManojKrChauhan
  • 18
  • 17
36 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 35 total points
ID: 10805275
Windows 98 doesn't have Unicode support built in, so a simple Unicode built program will not even be able to load up under Windows 98.  There is nothing you can do about this.

Fortunately, there is a solution.  You can use the Unicode libraries for windows 95.  I have tried to use them and failed more than once (it's easier to just use code-pages everywhere for what I've worked on) but you can read about it here: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q210/3/41.ASP&NoWebContent=1

Hope this helps.
0
 

Author Comment

by:ManojKrChauhan
ID: 10813958
The site doesn't give whole information about project setting.
I want information about project setting for vc7.0 or vc6.0.
My unicows.lib doesn't load MSLU loader.
Tell me how to link unicows.dll and unicows.lib
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10814186
There are details on setting up the compiler here: http://msdn.microsoft.com/msdnmag/issues/01/10/MSLU/default.aspx

Look under the heading "Integrating MSLU".  The most likely problem is that MFC is trying to link to the system calls first, and never getting to the unicows library.

Hope this helps.
0
 

Author Comment

by:ManojKrChauhan
ID: 10830537
So tell me how should link UNICOWS.DLL first?
I have all documents but my unicows.dll is not linked.
is there other way to link it?
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10833788
Well, it is pretty far down in teh article.  Here's the relevant section:

===============

In order to ensure that the application uses the correct function, you need to determine that everything is linked in the right order. The simple rule for the linker is that references are resolved from left to right (and if it cannot find the symbol, it starts back at the beginning, finally using the DEFAULTLIB location if it still cannot find the symbol).
To take advantage of this scheme, you can use the following three-step plan:

Include the following in the link list:

/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib
/nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib
/nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib
/nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib

Include unicows.lib.

Include all of the libraries that MSLU (and your application) might need:

kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib
version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib
secur32.lib oleacc.lib oledlg.lib sensapi.lib

=================

In other words, you have to alter your project's properties so that the kernel libraries are not linked by default (just add the first list to the "no default libraries" list).  You can probably get away with just setting the linker to ignore all default libraries.

Then go and add to the aditional dependancies in the project settings all of the ones in list items 2 and 3, *in that order* so that unicows will be linked first.
0
 

Author Comment

by:ManojKrChauhan
ID: 10848766
Everything i have applied which you told but still got same error(at run time when run on win98. error is  for debug version "Debug Assertion Failed line no. 41 in auxdata.cpp" and for release version  "application has requested to terminate it in an unsual way")
So please either give me a program which only dispaly a messagebox on winnt and win98
or solve my problem
                                   Thanks
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10859731
Odd, that assertion is for a bad wait cursor.  That means a missing dll, so you might want to doubel check that you added all the libraries on the list to your project.
0
 

Author Comment

by:ManojKrChauhan
ID: 10866205
Thanks It's running now for win98
 But still a problem
I'm making a multilanguage program.
I'm using VC7(dotnet). I'm using dll for other languages say chinese,spanish etc.
No problem for win2k. but when i run on win98. It use English(default) but when i load other resource say i load chinese dll then it again load english not chinese. I do it by LoadLibraryW()
I checked, For win98 it returns NULL. I have tried to change the path of chinese dll but it doesn't load other dlls except english(default)
So please tell me where i'm wrong
One more question is related with DotNet
I run my program in Release mode.
For debug mode it runs 2 or 3 times but after that it gives error. why?No problem at all for release mode.
             Thanks
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10868997
I'm not sure you should be calling LoadLibraryW directly since unicows overrides LoadLibrary.  However, you shouldn't be needing to do that.  MFC 7.0 and later automatically load the language DLLs based on the current language settings in Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcconLocalizedResourcesInMFCApplicationsSatelliteDLLs.asp

As for the problem with debug mode, is it possible you are not freeing a resource?  In release, all resources are freed when the program exits, but under debug mode Visual Studio keeps them open, so a resource leak will build up until the program stops working.
0
 

Author Comment

by:ManojKrChauhan
ID: 10906364
Thnaks for clearing Debug and Release mode.
I select different languages from menu bar in my program.
So i'm using LoadLibraryW()
when i run it on win2k, it loads other languages. but in case of win98, when i load other language,it doesn't load it and i see only English(default). because now LoadLibraryW() returns NULL.
for UTL-8, my project runs on all windows successfully. I use AfxLoadLibrary(), because i use project in dynamic mode not static.
since MSLU says use static project mode  and AfxLoadLibrary() is unaccessible for static project settings so i use LoadLibraryW().
I have done every settings for resource dlls same as UTF-8. but LoadLibraryW fails.why?
Please tell me.
             thanks

0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10918137
What I'm suggesting is that perhaps you should be using LoadLibrary under Win98, since you need to call the unicows version.  In general, it is usually not a good idea to specifically call an A or W version of a function without a very good reason.  In this case, calling LoadLibrary should call the appropriate function, whereas calling LoadLibraryW under Win98 may fail just because it doesn't exist.
0
 

Author Comment

by:ManojKrChauhan
ID: 10956798
Sir, if we are using MSLU then we can use LoadLibraryW() because for win98,MSLU converts it to LoadLibraryA().
Well, i have tried with LoadLibrary().But  Same problem. It runs on win2k but for win98,it again load english string when i select other language because LoadLibrary returns NULL.
I think this is the problem of DotNet(path problem).

If we are using dlls then in linker option we add to their output path   as  ../
I have done it for vc7 but unable to solve problem.

Sir, since i have done MSLU for VC7. when i apply same project settings on vc6 then it fails. i got almost 150 errors. Is there any way for providing MSLU support for vc6.

waiting for reply
                                  Thanks for your response

0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10959541
When LoadLibrary returns NULL, what does GetLastError return?

And since unicows was designed when VC6 was the standard, I assume it should work in VC6.  What errors are you getting?  And what do you mean by DotNet?  A normal C++ program cannot load DotNet DLLs since they are not real DLLs, but managed C++ programs can.  Howvere, VC6 does not support managed C++.
0
 

Author Comment

by:ManojKrChauhan
ID: 10960157
DotNet is i'm taking about VC7(dotnet).
I have done MSLU for VC7.
For VC6, after project settings when i build project then i get error like
can't open SensAPI.Lib,atlsd.libm,Secur32.Lib,uafxcw.lib,atls.lib one by one. Then i copy these files to current directory.I build program again, then it gives 92 errors like

MainFrm.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CFrameWnd::GetMessageString(unsigned int,class CString &)const " (?GetMessageString@CFrameWnd@@UBEXIAAVCString@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: int __thiscall CStatusBar::Create(class CWnd *,unsigned long,unsigned int)" (?Create@CStatusBar@@QAEHPAVCWnd@@KI@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: int __thiscall CToolBar::CreateEx(class CWnd *,unsigned long,unsigned long,class CRect,unsigned int)" (?CreateEx@CToolBar@@QAEHPAVCWnd@@KKVCRect@@I@Z)
testunicodeforvc6.obj : error LNK2001: unresolved external symbol "protected: int __thiscall CWinApp::Enable3dControlsStatic(void)" (?Enable3dControlsStatic@CWinApp@@IAEHXZ)
atls.lib(atlbase.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(dlgfile.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(viewedit.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(dlgdata.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(viewprnt.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(winctrl1.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(winctrl4.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(olevar.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(appinit.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(docmgr.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(filecore.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(filest.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(arccore.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(barcore.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(dlgtempl.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(appui3.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(filelist.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(strcore.obj) : error LNK2001: unresolved external symbol ___security_cookie
uafxcw.lib(objcore.obj) : error LNK2001: unresolved external symbol ___security_cookie
etc.................

I have no problem for UTF-8 for multilanguage in vc6.It run on all windows. I use same project settings which i done in VC7.But i got these errors.

So i have 2 problems now
1. MSLU with VC6
2. LoadLibrary with VC7

So Please solve my problem. Atleast for VC6. If it will solve for VC6 then there will not any problem.
             Thanks
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10960874
Okay, the errors you are seeing happen because the libraries are not properly linked.  Make sure the linker options do include the lib files that were supposed to be re-included after the unicows library.

Also, you should not need to copy the library files into the directory, especially since you have to copy the files for VC6, and if you accidentally copied the ones for VC7 you will get errors.  The VC6 library files you need are, by default, in Program Files\Microsoft SDK\Lib if you downloaded the platform SDK and Program Files\Microsoft Visual Studio\VC98\MFC\Lib for the rest.  Make sure that directory is in the compiler settings (not the project settings).

As for VC7, right after the call to LoadLibrary just add the line

TRACE("%d\n", ::GetLastError());

The number it prints corresponds to an error in this list: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp

That should help you locate the cause of the error.
0
 

Author Comment

by:ManojKrChauhan
ID: 10993232
::GetLastError() for VC7 returns error no. 66

For VC6, Please tell me MSLU support i.e. project settings because I'm getting all errors which i told you. First i get "can't open secur32.lib". I see it's not in vc++\lib directory. I copy it to lib directory(or current directory). same for sensapi.lib,uafxcwd.lib
For vc7,project settings you told i applied then my program run successfully. I include libraries in vc6 as

/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib unicows.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib oleacc.lib oledlg.lib

There is a space between each lib. Please tell all project settings
         Thanks
0
 

Author Comment

by:ManojKrChauhan
ID: 10993729
for vc7,I have tried with SetThreadLocale(MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),SORT_DEFAULT));
Successfully run on win2k. But for win98, when i sele japanese language it load resources in English.

For vc6,i got error now "can't open file uafxcw.lib" then "atls.lib" after that i got above 92 errors.
Sir,If possible then send me a single MSLU application in vc6(MFC) which dispaly a text "MSLU for Win98" in message box.
My email address is         gkv_manoj@yahoo.com
                                                                             Thanks
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10996091
Hmm, Error 66 is "The network resource type is incorrect" which is a very odd error to get when loading a dll.  That usually happens when you try to get a network connection, so I'm not sure why it would be happening here.  Is it possible this error is coming from another function?  Make sure the GetLastError call is right after the failed LoadLibrary (if the LoadLibrary succeeds, or another call happens in-between the error could be from somewhere else.

You should never be puting lib files in your program directory.  Not only is it a bad idea to move them from their original directory because that could break other programs, but also if you do not link to them in their original directories then your program will miss updates to the files.  For library files that are specific to a project, you should add the directory containing the library files to the project settinsg under Link|Additional Library Path.  These libraries should be used by every project, though, so they should be in Tools|Options|Directories|Library Files.

I'll see if I can throw something together, but I don't have a Win98 machine to test on.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ManojKrChauhan
ID: 10997326
Sir
    Thanks for your response
 Please send me a vc6 example for MSLU or tell me all project settings for vc6
0
 

Author Comment

by:ManojKrChauhan
ID: 11013775
For Vc7
For VC&
My dlls are loaded now. When i select Japanese Language, i see Japanese strings data on win98. No problem for string table RESOURCE. But My Menu and
Dialog boxes of any dll are not loaded(win98). I use another menu IDR_MENU1(NOT IDR_MAINFRAME).
I use function LoadMenuW(dll handle,menuname) and setmenu() to load a menu. I add a dialog box to project.
I have tried with LoadMenuW() API and LoadMenu() of CMenu class(i use it for UTF-8).
Please reply where i'm wrong? Is there any other settings for these resource.
No problem in win2k for UTF-8 AND UTF-16

For VC6, my unicode program successfully run on win98. When i add dlls to program, then under ReleaseMode,i got an error
Linking...
uafxcw.lib(olevar.obj) : warning LNK4044: unrecognized option "alternatename:??$HashKey@PB_W@@YGIPB_W@Z=?HashKey@@YGIPB_W@Z"; ignored
LINK : fatal error LNK1104: cannot open file "atls.lib"
Error executing link.exe.
and for Debug mode, first time program run successfully, but after that i got a message "debug assertion failed, error in file docsingl.cpp,line no. 215"

Please reply me. I'm waiting
           Thanks



0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11014816
Make sure Release is set to have the same MFC settings as Debug (I suspect they need ot both be "dynamic").  It's also possible you need service pack 5, since it is complaining about a linker option that it doesn't recognize.  Is it possible you opened the VC7 file using VC6?

And the code at dossingl.cpp line 215 is

            VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));

which means that the DLL the program is trying to use in LoadString does not have a string resource called AFX_IDS_UNTITLED.  Make sur ethe resource does exist, and then see if it is loading the file properly on the second run.


If you are loading the language DLL by hand, you will need to specify the resource handle for the DLL in your LoadMenu command, not the default one which the CMenu object uses, so LoadLibrary should be the function you need.  How did you get the LoadLibrary function working?  Could the same technique be used on LoadMenu?
0
 

Author Comment

by:ManojKrChauhan
ID: 11015758
Thanks
I have tried with LoadMenuW(module handle.name) and loadmenu of cmenu, but fail in both case
For library, i use,LoadLibraryExW() because LoadLibraryW() is not used in case of unicode and fail between win32 and win16
Thanks for clearing debug and release again
But please try to solve the problem of menu and dialog, i'm not understanding why they are fail for win98, i do their settings as i done for UTF-8
and no problem for win2k at all
    anyway thanks
       i'm waiting
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11015852
Did you try using GetLastError after LoadMenu fails?  Since I don't have access to a Win98 machine I really can't test anything like this.

Coud you post the actual call, and maybe some of the text around it.  I just don't have enough information to even guess at an answer.
0
 

Author Comment

by:ManojKrChauhan
ID: 11047336
(1)
For win98 no problem with resource strings and toolbar.
I have tried now GetLastError() after loadmenuw and dlg.DoModal(). LoadMenuW returns 0 and dlg.domodal returns -1. I use FormatMessage() for both,which says "operation completed successfully"
I think this is the problem between win16 and win32 or Loadmenuw doesn't support unicode between win2k and win98. Is there any project settings for dlls?I have tried with static and dynamic dll.
For dll, only setting is Link->general output filename=../debug/filename or ../release/filename. Is there any setting for resource tab of project.exe?
(2)
How to solve the problem of "dossingl.cpp line 215 is" VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
(3)
There is one silly question. In my unicode program, i display all directories of windows drive in LeftPane. For win98(English), program display all directories of windows drive BUT for Win98(Japanese), It doesn't display its directories.Both windows have Microsoft Visual Studio6.0 installed on them.

Please reply        
       I'm waiting

0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11049868
(1)  If LoadMenuW is returning a GetLastErorr of 0, then the LoadMenu is successful.  Is it possible the menu is empty, or not being displayed correctly?  I suppose a menu with a unicode character might be causing problems, but perhaps the menu is multibyte instead of unicode?  If you entered the data under Windows 98, that may be the case.

(2) The only solution I can think of is that the string with ID AFX_IDS_UNTITLED doesn't exist.  If it doesn't, teh solution is to add it.

(3) I don't know the answer to this question because there isn't enough information.  What control is displaying, and does it display nothing, or just the wrong thing?  And how is the data loaded into the control?
0
 

Author Comment

by:ManojKrChauhan
ID: 11050060
Thanks
leave 2nd problem. I haved it.
Now come to first problem.
I'm using IDR_MENU1. In OnCreate() of mainframe.cpp, i write

menu=LoadMenuW(langDLL,(LPCTSTR)IDR_MENU1);  where menu is of HMENU type, initially langdll is null(handle of exe)
::SetMenu(m_hWnd,menu);
when i exucute program, i see menus of IDR_MENU1.
Now, i have IDR_MENU1 in my all dlls. When i select any language, i load corresponding dll.Its strings,toolbar are loaded but menu(IDR_MENU1) and dialog not loaded.
For this, i write
::DestroyMenu(menu); // this doesn't matter whether used or not
menu=LoadMenuW(langDLL,(LPCTSTR)IDR_MENU1);  where menu is of HMENU type, initially langdll is null(handle of exe)
::SetMenu(m_hWnd,menu);
here  langdll contains handle of dll (i use langdll to display string)but i think here IDR_MENU1 is unaccessible. HERE IS THE PROBLEM
I hope now u understood my problem.

my third problem is same which i discussed. It display on english 98 but not on japanese 98.

well thanks for response
waiting for ur response
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11051433
So are you saying that the menu loads the first time, but not the second time?  Or do you mean that it doesn't load when any DLL is used?  Does it work if you put the same English menu in the language DLL?

Since I don't know what you are doing to try to display the information, I have no way of knowing what would be different from English and Japanese Windows 98.  Like I said, I would need to knwo what control is being used, and how the information is being put into teh control.  Are you using a CTreeCtrl, a CListViewCtrl, or some third party control?  How do you put text into the control, and does the text being put in display correctly if you display it somehwre else?  Try setting it into the main window's titlebar for testing, and see if it displays correctly there.
0
 

Author Comment

by:ManojKrChauhan
ID: 11056209
For second question
I'm using CTreeCtrl class(SDI application). I set main window title of win98(japanese). No problem. To insert text in treeview control, i use

CImageList img;
img.Create(IDB_BITMAP1,30,1,RGB(255,0,255));//create image list
      GetTreeCtrl().SetImageList(&img,TVSIL_NORMAL);
hitem=GetTreeCtrl().InsertItem(itmm,ILI_HARD_DISK,ILI_HARD_DISK,TVGN_ROOT,TVI_SORT);//insert root node in tree view
where hitem is HTREEITEM and LPCTSTR itmm=_T("DriveName"); and ILI_HARD_DISK has value 0(first part of image)
After that i insert directories of windows drive. But in case of win98(japanese not english),it display nothing.(even not drivename). While my UTF-8 program(non UNICODE), display DriveName in japanese windows98.
I have tried without using Imagelist. but no success.Remember no problem with win98 english. and for win2k, i select japanese language from Regional Setting, then i put some directories(of text japanese) in windows drive. Then my program display all directories of windows drive with all japanese directories.

Now come to first problem
No it doesn't put English Language menu. It only put menu from Main exe resource. Not from any dll whether it's english or japanese or any other.  Is this the problem of "Win9x has problems with resource ID values > 32K". I don't know,only guessing.
Well thanks for your response. Waiting for Reply
                                                                       Thanks
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11059517
For the first problem:
  If it does not display the menu in English ut probablty isn't a Unicode problem, so you might want to do things like double check teh resource ID.  It isn't enough that the menu have the same name, the numbers have to match too.  The value is defined in Resource.h

For the second problem:
  This may be a problem with the tree control under Windows98.  Try setting the text without the _T macro.  It's very surprising that the text is not even Japanese characters.  The only thing I can think of is that it is a conflict between Unicode characters and Multibyte characters, though you will need to use the debugger to see which one is whcih if that is it.

ごめんあさい。
0
 

Author Comment

by:ManojKrChauhan
ID: 11065581
All values are same in resource.h for all Dlls and main exe. If that was the problem then it should not not menu and dialog of japanese and english dll on win2k.As i already told, program successfully run on win2k.
I match this program with my UTF-8 program and resources of all Dlls have same value as in UTF-8. When i double click on any dialog(exe or dll) then control goes to its class constructor(in main exe)
Thanks waiting for reply
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11068325
I'm sorry, but in this case I cannot think of a single reason it would not work.  The menu resource is no different from string resources, so if string resources work but the menu resource doesn't I cannot guess what the problem is.  As long as the resource is compiled with the same numeric constants, there is no reason why this should not work.

Tame ni naranai jogen ni gomennasai.
0
 

Author Comment

by:ManojKrChauhan
ID: 11069253
Ok. Now i caught the problem. and problem is in LoadLibraryExW(). I made a non unicode application(statically linked) which contains one dll and i load this dll as i done in unicode application. It successfully run on win2k.But under win98,menu and dialog of this dll are not loaded. But if i use
AfxLoadLibrary()(not loadlibraryex()) then no problem at all. But to use AfxLoadLibrary(), define _AFXDLL in preprocessor definitions and /MD in runtime library. all resources of dll are load under win98 now.

Since MSLU says statically linked your project, and _AFXDLL in preprocessor definition  is not defined in static linking. and we want to use AfxLoadLibrary() then we have to define _AFXDLL in preprocessor definitions and /MD in runtime library.
Now in my unicode application i define _AFXDLL and /MD. It successfully run on win2k. But under win98, first it requires MFC71U.DLL AND MSVCR71.DLL. Then it doesn't load MSLU. Now this is new problem. I think _AFXDLL require kernel32.lib. so kernel32.lib loads before unicows.dll under win98.
In nonunicode application,no unicows.dll is require so it runs there.
I hope you understand my problem now.
So if possible, reply.
and again thanks for your response.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11071446
I'm not sure what you mean here.  AfxLoadLibrary uses the standard LoadLibrary call.  The only specific difference I can see between the static and dynamic versions is that the dynamic version uses LoadLibrary compiled for an ANSI system, but the static version will, I believe use LoadLibraryA or LoadLibraryW depending on the compiler settings.  I don't think you need /MD to use AfxLoadLibrary.

Since you are specifying the load order in the linker, it should always load unicows.dll before kernel32.dll.
0
 

Author Comment

by:ManojKrChauhan
ID: 11168860
LoadLibrary() fails between 16 bits and 32 bits. I give you reason written by Byran Bullard from Microsoft.
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.

If project is in static linking then we can't use AfxLoadLibrary(). You can try it. Don't mind. I use LoadLibraryEx(). It succeed for win98. But it doesn't display menu and dialog. Leave it. I have solved my problem through Dynamic MSLU i.e. Now i build project as shared dll(not static). If you can solve menu and dialog problems in static linking then please reply me. Because for Dynamic MSLU, we have to pass some extra dlls with our exe. If not then it's ok.
Will you tell me about WM_NOTIFY and WM_NOTIFYFORMAT. How we use these two message?
       Thanks



0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11171580
If you are compiling the DLL yourself under VS 6.0 it shouldn't be a 16-bit DLL.  If you have the same ID for the menu in the DLL as the App, and it was created by VS it should automatically be 0x7FFF or less. And for a resource DLL, the DllMain function shouldn't be calling anything.  I'm not clear why any of this would apply.

As for AfxLoadLibrary, the entire fundtion is

HINSTANCE AFXAPI AfxLoadLibrary(LPCTSTR lpszModuleName)
{
      ASSERT(lpszModuleName != NULL);
      AfxLockGlobals(CRIT_LOCKSHARED);
      HINSTANCE hInstLib = LoadLibrary(lpszModuleName);
      AfxUnlockGlobals(CRIT_LOCKSHARED);
      return hInstLib;
}

and AfxLockGlobals is a non-function unless the program is multithreaded, in which case it is a critical section.  So if calling LoadLibrary doesn't work, then calling AfxLoadLibrary will have no effect either.

I can't really add anything to WM_NOTIFYFORMAT that you can't find here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/common/messages/wm_notifyformat.asp
0
 

Expert Comment

by:hung2k
ID: 13417246
Hi ManojKrChauhan and KurtVon,

I got the same problem you described in the discussion: I included the linker's option with nodefault lib and include the unicows.lib as described but it still stop by assertion failed for LoadCursor
Would you please tell me what you have done to overcome the bug.

Thank you very much for the help.

Hung
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 150
dog bark java program 15 82
Line meaning 9 77
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 50
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now