windraw2.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:169k
- /* ***** BEGIN LICENSE BLOCK *****
- * Source last modified: $Id: windraw2.cpp,v 1.19.10.1 2004/07/09 01:59:19 hubbe Exp $
- *
- * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
- *
- * The contents of this file, and the files included with this file,
- * are subject to the current version of the RealNetworks Public
- * Source License (the "RPSL") available at
- * http://www.helixcommunity.org/content/rpsl unless you have licensed
- * the file under the current version of the RealNetworks Community
- * Source License (the "RCSL") available at
- * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
- * will apply. You may also obtain the license terms directly from
- * RealNetworks. You may not use this file except in compliance with
- * the RPSL or, if you have a valid RCSL with RealNetworks applicable
- * to this file, the RCSL. Please see the applicable RPSL or RCSL for
- * the rights, obligations and limitations governing use of the
- * contents of the file.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License Version 2 or later (the
- * "GPL") in which case the provisions of the GPL are applicable
- * instead of those above. If you wish to allow use of your version of
- * this file only under the terms of the GPL, and not to allow others
- * to use your version of this file under the terms of either the RPSL
- * or RCSL, indicate your decision by deleting the provisions above
- * and replace them with the notice and other provisions required by
- * the GPL. If you do not delete the provisions above, a recipient may
- * use your version of this file under the terms of any one of the
- * RPSL, the RCSL or the GPL.
- *
- * This file is part of the Helix DNA Technology. RealNetworks is the
- * developer of the Original Code and owns the copyrights in the
- * portions it created.
- *
- * This file, and the files included with this file, is distributed
- * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
- * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
- * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
- * ENJOYMENT OR NON-INFRINGEMENT.
- *
- * Technology Compatibility Kit Test Suite(s) Location:
- * http://www.helixcommunity.org/content/tck
- *
- * Contributor(s):
- *
- * ***** END LICENSE BLOCK ***** */
- /* for MS VC++ 6.0, pntypes needs to be included before windows include files */
- #include "hxtypes.h"
- #include "hxcom.h"
- #include "hxwintyp.h"
- #include "hxvsurf.h"
- #include "hxassert.h"
- #include "hxthread.h"
- #include "hxtick.h"
- #include "dllpath.h"
- #include "hxerror.h"
- #include "hxstrutl.h"
- /* Windows include files: */
- #include <windows.h>
- #include "ddraw.h"
- #define COMPILE_MULTIMON_STUBS
- #include <multimon.h>
- /* standard libraries: */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <assert.h>
- #include <math.h>
- #include "hxcom.h"
- #include "hxheap.h"
- #ifdef _DEBUG
- #undef HX_THIS_FILE
- static const char HX_THIS_FILE[] = __FILE__;
- #endif
- /* our stuff:*/
- #include "hxcolor.h"
- #include "colormap.h"
- #include "windraw2.h"
- #include "ddpdb.h" /* DirectDraw profiles database */
- /* DirectDraw profile: */
- static LPDDDEVICEPROFILE lpddprofDirectDrawProfile = NULL;
- //#define _CHECK_PERFORMANCE
- //#define _REMOVE_WINDRAW_CLIPPER
- // Exception handler mutex
- static CRITICAL_SECTION g_ehandlerMutex;
- static INT32 g_ehandlerMutexCnt = 0;
- static INT32 g_ehandlerSilent = 1;
- static INT32 g_ehandlerCount = 0;
- #include "hxmap.h"
- typedef void (HXEXPORT_PTR INITCOLORCONVERTERFN)();
- typedef int (HXEXPORT_PTR SETRGB8PALETTEFN) (int,UINT32*,int*);
- INITCOLORCONVERTERFN pfInitColorConverter = 0;
- SETRGB8PALETTEFN pfSetRGB8Palette = 0;
- HMODULE z_hHxColor = 0;
- struct CEnumDisplaySetting
- {
-
- CEnumDisplaySetting();
- ~CEnumDisplaySetting();
-
- CHXMapStringToOb m_Settings;
-
- void GetSettings(CHXSimpleList* pList);
- };
- CEnumDisplaySetting::CEnumDisplaySetting()
- {
- DEVMODE modeDesc;
- DWORD index = 0;
- char buffer[64]; /* Flawfinder: ignore */
- while(EnumDisplaySettings(0, index, &modeDesc))
- {
- sprintf(buffer, "%dx%dx%d", modeDesc.dmPelsWidth, modeDesc.dmPelsHeight, modeDesc.dmBitsPerPel); /* Flawfinder: ignore */
-
- void* ptemp;
-
- if (!m_Settings.Lookup(buffer, ptemp))
- {
- CModesDesc* pDesc = new CModesDesc;
- pDesc->m_nWidth = modeDesc.dmPelsWidth;
- pDesc->m_nHeight = modeDesc.dmPelsHeight;
- pDesc->m_nBitCount = modeDesc.dmBitsPerPel;
- m_Settings.SetAt(buffer, pDesc);
- }
- index++;
- }
- }
- CEnumDisplaySetting::~CEnumDisplaySetting()
- {
- CHXMapStringToOb::Iterator ndx = m_Settings.Begin();
- for(; ndx != m_Settings.End(); ++ndx)
- {
- CModesDesc* pDesc = (CModesDesc*) (*ndx);
- delete pDesc;
- }
-
- m_Settings.RemoveAll();
- }
- void CEnumDisplaySetting::GetSettings(CHXSimpleList* pList)
- {
- CHXMapStringToOb::Iterator i;
- i = m_Settings.Begin();
- for(; i!= m_Settings.End(); ++i)
- {
- CModesDesc* pOldDesc = (CModesDesc*) *i;
-
- CModesDesc* pNewDesc = new CModesDesc;
- pNewDesc->m_nWidth = pOldDesc->m_nWidth;
- pNewDesc->m_nHeight = pOldDesc->m_nHeight;
- pNewDesc->m_nBitCount = pOldDesc->m_nBitCount;
- pList->AddTail(pNewDesc);
- }
- }
- CEnumDisplaySetting zm_DisplaySettings;
- /***************************************
- *
- * Routines for using DirectDraw on a multimonitor system
- *
- */
- /* DDRAW.H might not include these: */
- #ifndef DDENUM_ATTACHEDSECONDARYDEVICES
- #define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L
- #endif
- #if DIRECTDRAW_VERSION <= 0x0500
- typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA) (GUID FAR *, LPSTR, LPSTR, LPVOID, HANDLE);
- typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA) ( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags);
- #define HMONITOR HANDLE
- #endif
- typedef HRESULT (*PDRAWCREATE) (IID *,LPDIRECTDRAW *,LPUNKNOWN);
- typedef HRESULT (*PDRAWENUM) (LPDDENUMCALLBACKA, LPVOID);
- /*
- * FindDeviceCallback functions:
- */
- typedef struct
- {
- LPSTR lpszDevice;
- GUID* lpGUID;
- GUID GUID;
- BOOL fFound;
-
- } FINDDEVICEDATA;
- static BOOL CALLBACK FindDeviceCallback (GUID* lpGUID, LPSTR lpszName,
- LPSTR lpszDevice, LPVOID lParam)
- {
- FINDDEVICEDATA *p = (FINDDEVICEDATA*) lParam;
-
- if (lstrcmpiA (p->lpszDevice, lpszDevice) == 0) {
-
- if (lpGUID) {
- p->GUID = *lpGUID;
- p->lpGUID = &p->GUID;
- } else
- p->lpGUID = NULL;
-
- p->fFound = TRUE;
- return FALSE;
- }
- return TRUE;
- }
- static BOOL CALLBACK FindDeviceCallbackEx (GUID* lpGUID, LPSTR lpszName,
- LPSTR lpszDevice, LPVOID lParam, HMONITOR hMonitor)
- {
- FINDDEVICEDATA *p = (FINDDEVICEDATA*) lParam;
-
- if (lstrcmpiA (p->lpszDevice, lpszDevice) == 0) {
-
- if (lpGUID) {
- p->GUID = *lpGUID;
- p->lpGUID = &p->GUID;
- } else
- p->lpGUID = NULL;
-
- p->fFound = TRUE;
- return FALSE;
- }
- return TRUE;
- }
- HRESULT WINAPI EnumSurfacesCallback(LPDIRECTDRAWSURFACE lpDDSurface,
- LPDDSURFACEDESC lpDDSurfaceDesc,
- LPVOID pSurface)
- {
- LPDIRECTDRAWSURFACE *lpSurf = (LPDIRECTDRAWSURFACE*)pSurface;
- if (lpDDSurface)
- {
- *lpSurf = lpDDSurface;
- lpDDSurface->Release();
- }
- return DDENUMRET_OK;
- }
- /*
- * DirectDrawCreateFromDevice
- *
- * create a DirectDraw object for a particular device
- */
- static IDirectDraw * DirectDrawCreateFromDevice (LPSTR lpszDevice,
- PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
- {
- IDirectDraw *pdd = NULL;
-
- /* check if device name is specified: */
- if (lpszDevice != NULL) {
-
- /* try to find device with a given name: */
- FINDDEVICEDATA find;
- find.lpszDevice = lpszDevice;
- find.fFound = FALSE;
- DirectDrawEnumerateP (FindDeviceCallback, (LPVOID)&find);
-
- /* check if found: */
- if (find.fFound) {
-
- /* In 4bpp mode the following DDraw call causes a
- * message box to be popped up by DDraw (!?!).
- * It's DDraw's fault, but we don't like it.
- * So we make sure it doesn't happen. */
- UINT ErrorMode = SetErrorMode (SEM_FAILCRITICALERRORS);
- DirectDrawCreateP (find.lpGUID, &pdd, NULL);
- SetErrorMode (ErrorMode);
- }
- } else
- DirectDrawCreateP (NULL, &pdd, NULL);
-
- /* return whatever we have found: */
- return pdd;
- }
- /*
- * DirectDrawCreateFromDeviceEx
- *
- * create a DirectDraw object for a particular device
- */
- static IDirectDraw * DirectDrawCreateFromDeviceEx (LPSTR lpszDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
- {
- IDirectDraw *pdd = NULL;
-
- /* check if device name is specified: */
- if (lpszDevice != NULL) {
-
- /* try to find device with a given name: */
- FINDDEVICEDATA find;
- find.lpszDevice = lpszDevice;
- find.fFound = FALSE;
- DirectDrawEnumerateExP (FindDeviceCallbackEx, (LPVOID)&find, DDENUM_ATTACHEDSECONDARYDEVICES);
-
- /* check if found: */
- if (find.fFound) {
-
- /* In 4bpp mode the following DDraw call causes a
- * message box to be popped up by DDraw (!?!).
- * It's DDraw's fault, but we don't like it.
- * So we make sure it doesn't happen. */
- UINT ErrorMode = SetErrorMode (SEM_FAILCRITICALERRORS);
- DirectDrawCreateP (find.lpGUID, &pdd, NULL);
- SetErrorMode (ErrorMode);
- }
- } else
- DirectDrawCreateP (NULL, &pdd, NULL);
-
- /* return whatever we have found: */
- return pdd;
- }
- /***************************************
- *
- * Routines for dynamic loading and unloading of the DirectDraw library.
- *
- */
- typedef DWORD (WINAPI *PGETFILEVERSIONINFOSIZE) (LPTSTR,LPDWORD);
- typedef BOOL (WINAPI *PGETFILEVERSIONINFO) (LPTSTR,DWORD,DWORD,LPVOID);
- typedef BOOL (WINAPI *PVERQUERYVALUE) (LPVOID,LPTSTR,LPVOID,PUINT);
- /* forward prototypes: */
- HRESULT LockSurface(LPWINDRAW lpwd, LPDIRECTDRAWSURFACE lpSurface, DDSURFACEDESC *pddsd, BOOL bBlock=TRUE);
- HRESULT IsFlipDone(LPWINDRAW lpwd, LPWINDRAWSURFACE lpwds, ENUMSURFACE* lpSurfEnum, BOOL bBlock=TRUE);
- HRESULT IsFrontBuffer(LPWINDRAW lpwd, LPWINDRAWSURFACE lpwds, ENUMSURFACE* lpSurfEnum, BOOL bBlock=TRUE);
- HRESULT RestoreSurfaces(LPWINDRAW lpwd, LPWINDRAWSURFACE lpSurface);
- HRESULT LoadDirectDraw (LPSTR lpszDevice, LPDIRECTDRAW *ppDirectDraw, HINSTANCE *phDirectDraw);
- void ReleaseDirectDraw (LPDIRECTDRAW *ppDirectDraw, LPDIRECTDRAW2 *ppDirectDraw2, HINSTANCE *phDirectDraw);
- void DumpDDInfo(LPWINDRAW lpwd, LPDIRECTDRAWSURFACE lpSurface, char *pFunction);
- /*
- * We can't be sure that DirectDraw is always available
- * so we can't statically link to the library.
- * Therefore we load the library, get the function entry
- * point addresses and call them to create the driver objects.
- * We return S_OK if we manage to load DirectDraw correctly
- * otherwise we return E_NOINTERFACE
- * We initialise a DirectDraw instance by explicitely loading
- * the library and calling GetProcAddress on the DirectDrawCreate
- * entry point that it exports
- *
- * On a multi monitor system, we can get the DirectDraw object
- * for any monitor (device) with the optional lpszDevice parameter
- */
- static HRESULT LoadDirectDraw (LPSTR lpszDevice,
- LPDIRECTDRAW *ppDirectDraw, HINSTANCE *phDirectDraw)
- {
- UINT ErrorMode;
- PDRAWCREATE pDrawCreate;
- PDRAWENUM pDrawEnum;
- LPDIRECTDRAWENUMERATEEXA pDrawEnumEx;
- HRESULT hr = NOERROR;
-
- /*
- * Check the display mode if it is less than 8 bits do not call into direct draw.
- */
-
- HDC hdc = GetDC(0);
- int bpp = GetDeviceCaps(hdc, BITSPIXEL);
- ReleaseDC(0, hdc);
-
- if (bpp < 8)
- {
- *ppDirectDraw = 0;
- return E_NOINTERFACE; /* whatever */
- }
-
- /* is DirectDraw already loaded? */
- if (*ppDirectDraw) {
- /* ... */
- return NOERROR;
- }
-
- /* make sure the library is available: */
- ErrorMode = SetErrorMode (SEM_NOOPENFILEERRORBOX);
- *phDirectDraw = LoadLibrary (TEXT ("DDRAW.DLL"));
- SetErrorMode (ErrorMode);
- if (*phDirectDraw == NULL) {
- /* ... */
- return E_NOINTERFACE;
- }
-
- /* get the DLL address for the creator function: */
- pDrawCreate = (PDRAWCREATE) GetProcAddress (*phDirectDraw, "DirectDrawCreate");
- /* force ANSI, we assume it: */
- pDrawEnum = (PDRAWENUM) GetProcAddress (*phDirectDraw, "DirectDrawEnumerateA");
- pDrawEnumEx = (LPDIRECTDRAWENUMERATEEXA)GetProcAddress (*phDirectDraw, "DirectDrawEnumerateExA");
-
- /* we don't need DirectDrawEnumerateEx, that's just for multimon stuff: */
- if (pDrawCreate == NULL || pDrawEnum == NULL) {
- /* ... */
- ReleaseDirectDraw (ppDirectDraw, NULL, phDirectDraw);
- return E_NOINTERFACE;
- }
-
- /* create a DirectDraw display provider for this device,
- * using the fancy multimon-aware version, if it exists: */
- if (pDrawEnumEx)
- *ppDirectDraw = DirectDrawCreateFromDeviceEx (lpszDevice, pDrawCreate, pDrawEnumEx);
- else
- *ppDirectDraw = DirectDrawCreateFromDevice (lpszDevice, pDrawCreate, pDrawEnum);
- if (*ppDirectDraw == NULL)
- {
- ReleaseDirectDraw (ppDirectDraw, NULL, phDirectDraw);
- return E_NOINTERFACE;
- }
-
- return NOERROR;
- }
- /*
- * Called to release any DirectDraw provider we previously loaded.
- * We may be called at any time especially when something goes
- * horribly wrong and when we need to clean up before returning
- * so we can't guarantee that all state variables are consistent
- * so free only those really allocated. This should only be called
- * once all the reference counts have been released.
- */
- void ReleaseDirectDraw (LPDIRECTDRAW *ppDirectDraw, LPDIRECTDRAW2 *ppDirectDraw2, HINSTANCE *phDirectDraw)
- {
- /* release any DirectDraw provider interface: */
- if (ppDirectDraw && *ppDirectDraw) {
-
- IDirectDraw_Release (*ppDirectDraw);
- *ppDirectDraw = NULL;
- }
-
- if (ppDirectDraw2 && *ppDirectDraw2)
- {
- (*ppDirectDraw2)->Release();
- *ppDirectDraw2 = NULL;
- }
-
- /* decrement module load count: */
- if (*phDirectDraw) {
- FreeLibrary (*phDirectDraw);
- *phDirectDraw = NULL;
- }
- }
- #if 0
- /*
- * Are we running on Direct Draw version 1? We need to find out as
- * we rely on specific bug fixes in DirectDraw 2 for fullscreen playback. To
- * find out, we simply see if it supports IDirectDraw2. Only version 2 and
- * higher support this.
- */
- BOOL IsDirectDrawVersion1 (LPDIRECTDRAW pDirectDraw)
- {
- IDirectDraw2 *p;
- HRESULT hr;
-
- /* check if DirectDraw is available: */
- if (pDirectDraw == NULL)
- return FALSE;
-
- /* query and release interface: */
- p = NULL;
- hr = IDirectDraw_QueryInterface(pDirectDraw, IID_IDirectDraw2, (void *)&p);
- if (p)
- IDirectDraw2_Release (p);
-
- /* returns TRUE, if !IDrectDraw2; FALSE otherwise */
- return hr != NOERROR;
- }
- #endif
- /***************************************
- *
- * Routines for using GDI on a multimonitor system
- *
- */
- /*
- * Get display DC.
- * Use:
- * HDC GetDisplayDC (LPSTR lpszDevice)
- * Input:
- * lpszDevice - device name to use (in a multimonitor system)
- * Returns:
- * NULL, if error; !NULL - display device DC.
- */
- static HDC GetDisplayDC (LPSTR lpszDevice)
- {
- HDC hdcDisplay;
-
- /* get a DC on the right monitor - it's ugly, but this is the way
- * you have to do it */
- if (lpszDevice == NULL || lstrcmpiA (lpszDevice, "DISPLAY") == 0)
- hdcDisplay = CreateDCA ("DISPLAY", NULL, NULL, NULL);
- else
- hdcDisplay = CreateDCA (NULL, lpszDevice, NULL, NULL);
-
- return hdcDisplay;
- }
- /*
- * Get pixel format for a given device context.
- * Use:
- * HRESULT GetDeviceFormat (HDC hDC, LPBMI lpbmi);
- * Input:
- * hDC - device context to query
- * lpbmi - pointer to a bitmapinfo structure to initialize
- * Returns:
- * NOERROR, if success, E_FAIL otherwise.
- */
- static HRESULT GetDeviceFormat (HDC hDC, LPBMI lpbmi)
- {
- HBITMAP hBM;
-
- /* initialize the bitmapinfo structure: */
- memset (lpbmi, 0, sizeof (BMI));
- lpbmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- lpbmi->bmiHeader.biBitCount = 0;
-
- /* retrieve display format parameters: */
- hBM = CreateCompatibleBitmap (hDC,1,1);
- GetDIBits (hDC,hBM,0,1,NULL, (BITMAPINFO *)& (lpbmi->bmiHeader),DIB_RGB_COLORS);
- /* this call will get the color table or the proper bitfields */
- GetDIBits (hDC,hBM,0,1,NULL, (BITMAPINFO *)& (lpbmi->bmiHeader),DIB_RGB_COLORS);
- DeleteObject (hBM);
-
- /* check the validity of the format & exit: */
- return CheckBitmap ((BITMAPINFO *)& (lpbmi->bmiHeader))? NOERROR: E_FAIL;
- }
- /*
- * Retrieves display pixel format. This is normally called
- * when we receive WM_DEVMODECHANGED device change messages.
- *
- * The optional szDevice parameter tells us which monitor we are interested
- * in for a multi monitor system.
- *
- * The calling program mush use global syncronization objects to prevent
- * re-entering this code.
- */
- static HRESULT GetDisplayFormat (LPBMI lpbmi, LPSTR lpszDevice)
- {
- HDC hdcDisplay;
- HRESULT hr;
-
- /* get a DC of a given monitor: */
- if ((hdcDisplay = GetDisplayDC (lpszDevice)) == NULL)
- return E_FAIL;
-
- /* retrieve display format parameters: */
- hr = GetDeviceFormat (hdcDisplay, lpbmi);
-
- /* delete hdcDisplay & exit: */
- DeleteDC (hdcDisplay);
- return hr;
- }
- /*
- * Generates the "standard" WinDraw palette.
- * Since we will have to deal with multiple datatypes, each having
- * its own combination of colors, what we really need is some "uniform"
- * palette, we could use to render all these objects with minimum loss
- * of quality.
- * This function generates so-called 6x6x6-color palette that contains
- * all possible combinations of 6 uniformly-displaced values for each
- * color component (R, G, and B). To avoid interference with Windows
- * system palette (first and last 10 entries in the palette), we will
- * insert our colors in 10..225 range, and mark them as non-collapsable
- * in hope to boost the performance (ideally, this should prevent GDI
- * from compressing the palette, and eliminate extra mapping).
- */
- static HRESULT CreateDefaultPalette (LPPALETTEENTRY lppe,
- int *pnLoColor, int *pnHiColor, LPSTR lpszDevice)
- {
- HDC hdc;
- HRESULT hr = E_FAIL;
- unsigned int i, r, g, b;
-
- /* get a DC of a given monitor: */
- if ((hdc = GetDisplayDC (lpszDevice)) != NULL) {
-
- /* apparently some displays have odd numbers of system colors: */
- if (GetDeviceCaps (hdc, NUMRESERVED) == 20) {
-
- /* retrieve system colors: */
- memset (lppe, 0, 256 * sizeof (RGBQUAD));
- GetSystemPaletteEntries (hdc, 0, 10, lppe);
- GetSystemPaletteEntries (hdc, 246, 10, lppe + 246);
-
- /* generate 6x6x6 (~2.58 bits/channel) palette: */
- i = 10;
- for (b = 0; b <= 0xFF; b += 0x33)
- for (g = 0; g <= 0xFF; g += 0x33)
- for (r = 0; r <= 0xFF; r += 0x33) {
- /* create a palette entry: */
- lppe [i].peGreen = g;
- lppe [i].peBlue = b;
- lppe [i].peRed = r;
- lppe [i].peFlags = PC_NOCOLLAPSE; /* !!! */
- i ++;
- }
-
- /* store the range of our colors: */
- *pnLoColor = 10;
- *pnHiColor = i;
-
- hr = NOERROR;
- }
- DeleteDC (hdc);
- }
- return hr;
- }
- char*
- CollectDDInfo(LPWINDRAW lpwd, LPDIRECTDRAWSURFACE lpSurface, char *pFunction, char* pSeparator)
- {
- char* pszDDInfo = NULL;
- CHXString pDDInfo;
- char szTemp[MAX_DISPLAY_NAME]; /* Flawfinder: ignore */
- char szTmp[MAX_DISPLAY_NAME]; /* Flawfinder: ignore */
- // write date and time of log
- SYSTEMTIME time;
- memset(&time, 0, sizeof(time));
- GetSystemTime(&time);
- GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, "ddd',' MMM dd yyyy, ", szTmp, sizeof(szTmp));
- SafeSprintf(szTemp, MAX_DISPLAY_NAME, "nLog Entry: %s", szTmp);
- pDDInfo = szTemp;
-
- GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &time, "hh:mm:ss tt", szTmp, sizeof(szTmp));
- SafeSprintf(szTemp, MAX_DISPLAY_NAME, "%s%s", szTmp, pSeparator);
- pDDInfo += szTemp;
-
- // write systime members
- SafeSprintf(szTemp, MAX_DISPLAY_NAME, "Systime: %d %d %d %d %d %d %d %d%s",
- time.wYear, time.wMonth, time.wDayOfWeek, time.wDay,
- time.wHour, time.wMinute, time.wSecond, time.wMilliseconds, pSeparator);
- pDDInfo += szTemp;
-
- // write function that caused fault
- SafeSprintf(szTemp, MAX_DISPLAY_NAME, "Function: %s%s", pFunction, pSeparator);
- pDDInfo += szTemp;
- // write OS version
- OSVERSIONINFO ver;
- memset(&ver, 0, sizeof(ver));
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
- SafeSprintf(szTemp, MAX_DISPLAY_NAME,
- "OS MajorVersion: %ld MinorVersion: %ld BuildNum: %ld PlatformId: %ld Build: %s%s",
- ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber, ver.dwPlatformId, ver.szCSDVersion, pSeparator);
- pDDInfo += szTemp;
- // write processor info
- SYSTEM_INFO sysinfo;
- memset(&sysinfo, 0, sizeof(sysinfo));
- GetSystemInfo(&sysinfo);
- SafeSprintf(szTemp, MAX_DISPLAY_NAME, "Processor Type: %ld Level: %ld Revision: %ld Count: %ld%s",
- sysinfo.dwProcessorType,
- sysinfo.wProcessorLevel,
- sysinfo.wProcessorRevision,
- sysinfo.dwNumberOfProcessors,
- pSeparator);
- pDDInfo += szTemp;
- // write DD version
- TCHAR szVersion[256] = __TEXT("