mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-11-17 21:04:45 +00:00
9e5e21b8c9
This change does two things: 1. Updates the registry APIs to reduce the likelihood of uninitialized variables. The code wasn't always checking the return value of registry load operations. In some cases, this led to uninitialized memory being used, and crashes could result. For example, LoadConfiguration in Applewin.cpp was using an uninitialized value for the computer type if no registry variable for the "Apple 2 type" was set. New registry reading methods and macros have also been introduced, allowing default value fallbacks for the cases where a registry variable is not found. This makes registry access simpler and safer when a default value is known in advance. The registry code's style has also been updated to conform with the rest of the code base (tabs instead of spaces, naming conventions, etc.) 2. Introduces string safety improvements. A number of code paths have been modified to use safe-string functions instead of their unsafe counterparts (e.g., strcpy, sprintf). In the process, some strings were converted from "char" to "TCHAR". This was done mostly for consistency with the rest of the code-base.
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
//#define WIN32_LEAN_AND_MEAN
|
|
|
|
// Required for Win98/ME support:
|
|
// . See: http://support.embarcadero.com/article/35754
|
|
// . "GetOpenFileName() fails under Windows 95/98/NT/ME due to incorrect OPENFILENAME structure size"
|
|
#define _WIN32_WINNT 0x0400
|
|
#define WINVER 0x500
|
|
|
|
// Mouse Wheel is not supported on Win95.
|
|
// If we didn't care about supporting Win95 (compile/run-time errors)
|
|
// we would just define the minimum windows version to support.
|
|
// #define _WIN32_WINDOWS 0x0401
|
|
#ifndef WM_MOUSEWHEEL
|
|
#define WM_MOUSEWHEEL 0x020A
|
|
#endif
|
|
|
|
// Not needed in VC7.1, but needed in VC Express
|
|
#include <tchar.h>
|
|
|
|
#include <crtdbg.h>
|
|
#include <dsound.h>
|
|
#include <dshow.h>
|
|
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#if _MSC_VER >= 1600 // <stdint.h> supported from VS2010 (cl.exe v16.00)
|
|
#include <stdint.h> // cleanup WORD DWORD -> uint16_t uint32_t
|
|
#else
|
|
typedef UINT8 uint8_t;
|
|
typedef UINT16 uint16_t;
|
|
typedef UINT32 uint32_t;
|
|
typedef UINT64 uint64_t;
|
|
#endif
|
|
|
|
#include <windows.h>
|
|
#include <winuser.h> // WM_MOUSEWHEEL
|
|
#include <strsafe.h>
|
|
#include <commctrl.h>
|
|
#include <ddraw.h>
|
|
#include <htmlhelp.h>
|
|
#include <assert.h>
|
|
|
|
#include <algorithm>
|
|
#include <map>
|
|
#include <queue>
|
|
#include <stack>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
// SM_CXPADDEDBORDER is not supported on 2000 & XP:
|
|
// http://msdn.microsoft.com/en-nz/library/windows/desktop/ms724385(v=vs.85).aspx
|
|
#ifndef SM_CXPADDEDBORDER
|
|
#define SM_CXPADDEDBORDER 92
|
|
#endif
|
|
|
|
#define USE_SPEECH_API
|