سؤال

I have built a program in Microsoft Visual Studio 2005 and it works fine.

The problem I am having is the the machine it needs to be used on is running windows 98. As far as I can tell I need to install the re-distributable for vc++. Can I install the re-distributable on windows 98 or is there a way to make it work on windows 98?

هل كانت مفيدة؟

المحلول

Yes, apps compiled with VS 2005 work perfectly fine on Windows 98 and Me. I've run several of them myself, and keep VS 2005 around and installed for precisely this purpose. Version 2005 of the CRT redistributable is supported as far back as Windows 98.

The trick is that you must compile the application for the multi-byte character set (MBCS). It will not work when compiled as Unicode, which is the default project setting. Windows 9x platforms do not support Unicode without some extra help. You should be able to change the project settings and be fine, but if you've written your code to assume Unicode, then you'll have a problem.

This is why you need to use generic character types and functions defined in tchar.h, rather than their wide character equivalents that are preferred for Unicode builds. Always define strings using the TCHAR type (or LPTSTR or LPCTSTR types), which is conditionally defined to wchar_t or char, as appropriate. Use string manipulation functions that begin with _tcs..., rather than the ones specific for wide or narrow characters. Make sure that when you call functions, you always call the generic typedef'ed versions, rather than the ANSI- or wide-specific ones that end with an A or a W suffix.

It may be a lot of work to go back and fix this if you haven't done it from the start. If that's the case, you might look into the Microsoft Layer for Unicode on Windows 95/98/ME Systems, which provides an abstraction layer that allows you to call Unicode functions on the legacy Windows 9x operating systems where they are not natively supported.

Beyond Unicode/MBCS, the only thing to watch out for is that you're not calling any functions that didn't exist in the Win32 APIs way back in the Windows 98 days. You can't trust what the online MSDN documentation tells you for the "minimum supported client version" anymore, because Microsoft is no longer supporting Windows 98. All of the SDK docs say that the minimum supported version is Windows 2000 now, and you know that's not correct. The entire API was not introduced as late as W2K. In order to get accurate information, you'll need to obtain an old version of the SDK documentation; what came with your installation of VS 2005 should be fine. The information there goes back at least as far as Win 98, if not 95 (I don't remember exactly).

For instances where you want to call functions that didn't exist back in Windows 98 when you're running on newer systems where they are available, you'll need to take extra care to call them dynamically, rather than adding them to your application's DLL import table (what the linker generally does for you automatically). That means defining function pointers yourself, and using the LoadLibrary and GetProcAddress functions to call them. It's not fun, but it does work.

Alternatively, you can configure the linker to "delay load" the libraries (check your project's properties). This is much more convenient, but obviously you'll need to ensure that you only call the functions that are available on your target operating system, otherwise the application will crash.

Either way, the GetVersionEx function will tell you everything that you need to know about the current host operating system so that your code can take different paths (calling newer functions if available, or falling back to older ones if not) depending on the environment. This allows you to support new functionality on new systems, while still retaining whatever degree of support for legacy operating systems is appropriate. You'll find a lot of if statements in the code base when this is done right. :-)

نصائح أخرى

Yes, you can http://www.microsoft.com/download/en/details.aspx?id=3387 (Microsoft Visual C++ 2005 Redistributable Package (x86))

Supported Operating Systems: Windows 2000 Service Pack 3, Windows 98, Windows 98 Second Edition, Windows ME, Windows Server 2003, Windows XP Service Pack 2

Did you check the system requirements? According to this link, Windows 98 should be fine.

There is more than distributing CRT with your application. All functions you use in the program must be available in Windows98. For all the functions you find on MSDN you will find a "Minimum supported client". This is tricky ...
To get over CRT issue you can statically link the application (/MT linker option). Will result in a bigger binary but will work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top