dllentry.cpp
上传用户:looem2003
上传日期:2014-07-20
资源大小:13733k
文件大小:2k
- // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
- // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
- // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- // PARTICULAR PURPOSE.
- //
- // Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved.
- //
- // FILE: dllentry.cpp
- //
- //
- // PURPOSE: Source module for DLL entry function(s).
- //
- //
- // Functions:
- // DllMain
- //
- //
- //
- // PLATFORMS: Windows XP, Windows Server 2003, Windows codenamed Longhorn
- //
- //
- // History:
- // 06/24/03 xxx created.
- //
- //
- #include "precomp.h"
- #include "bitmap.h"
- #include "debug.h"
- #include "log_file.h"
- // StrSafe.h needs to be included last
- // to disallow bad string functions.
- #include <STRSAFE.H>
- BOOL gen_file_name( LPTSTR fileName, DWORD fileSize );
- TCHAR pageFileName[4*MAX_PATH] = _T("");
- // Need to export these functions as c declarations.
- extern "C" {
- ///////////////////////////////////////////////////////////
- //
- // DLL entry point
- //
- // DllMain isn't called/used for kernel mode version.
- BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved)
- {
- OEMDBG(DBG_VERBOSE, L"DllMain entry.");
- UNREFERENCED_PARAMETER(hInst);
- UNREFERENCED_PARAMETER(lpReserved);
- switch(wReason)
- {
- case DLL_PROCESS_ATTACH:
- init_log( _T("popfaxbd"), &hInst, 1 );
- gen_file_name( pageFileName, ARRAYSIZE(pageFileName));
- write_log( 3, _T("DllMain"), _T("%s"), pageFileName );
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- }
- return TRUE;
- }
- } // extern "C" closing bracket
- BOOL gen_file_name( LPTSTR fileName, DWORD fileSize )
- {
- BOOL ret = FALSE;
- SYSTEMTIME sysTime = {0};
- FILETIME fileTime = {0};
- if( (NULL != fileName) && ( 0 != GetTempPath( fileSize, fileName ) ) )
- {
- if( fileName[_tcslen(fileName)-1] != _T('\') )
- _tcscat_s( fileName, fileSize-_tcslen(fileName), _T("\") );
- GetLocalTime( &sysTime );
- ret = SystemTimeToFileTime( &sysTime, &fileTime );
- _stprintf_s( fileName+_tcslen(fileName), fileSize-_tcslen(fileName), _T("%X_%X"), fileTime.dwHighDateTime, fileTime.dwLowDateTime );
- }
- return ret;
- }