Files
HLStock/HookMsg/Spy.cpp
2013-07-20 23:23:05 +00:00

162 lines
5.0 KiB
C++

// Spy.cpp
#include "stdafx.h"
#include "Spy.h"
HLSTOCKWINDOWDATA g_HLStockWindowData = {0,};
COPYDATASTRUCT g_HLStockWindowData_CDS = { 0, sizeof(HLSTOCKWINDOWDATA), &g_HLStockWindowData };
APPENV g_AppEnv = {
10000, // 현재가 항시체크 주기.
1, // 표준시간 맞추기.
"0311", // 자동전환 화면번호. (0311:매도)
1, // 매수잔량 전량취소.
0,
1, // Using sound effect.
500, // 7121 Click Delay.
1, // 7121 자동 클릭기능.
1, // 7121 클릭 후 자동잠김기능.
2000, // 7121 클릭(잠김후 동작제한시간).
300, // 현재가 요청후 응답제한시간. (제한시간초과시 매수않함.)
{0,0}, // Lock Unlock Hot key
{0,0}, // 잠금상태 NewsPlus 종목코드 핫키.
1, // 공시 매수레벨(일반).
2, // 공시 매수레벨(특별).
3, // 뉴스플러스 매수레벨(일반).
4, // 뉴스플러스 매수레벨(특별).
100, // 공시 거래금액(일반).
200, // 공시 거래금액(특별).
300, // 뉴스플러스 거래금액(일반).
400, // 뉴스플러스 거래금액(특별).
1, // 하한가일때 정보창 보이기.
1, // 종목코드 입력후 자동잠금(중복/수종종목시).
0, // 종목코드 입력후 자동잠금(매수후).
1, // 거래량 체크.
1, // 거래금액 체크.
10000, // 거래량.
20000, // 거래금액.
0, // 매수 매크로사용 1.
{0,0}, // 매수 핫키1.
0, // 매수 매크로사용 2.
{0,0}, // 매수 핫키2.
0, // 매수 매크로사용 3.
{0,0}, // 매수 핫키3.
0, // 매수 매크로사용 4.
{0,0}, // 매수 핫키4.
};
APPENV_DEBUG g_AppEnv_Debug = {
0, // Trace 전용.(표출시간 측정을 위해)
};
WINDOWPLACEMENT gwndpl;
HMODULE g_hUserDll = NULL;
CCondition g_Condition; // 조건 처리.
CConfigINI g_ConfigINI; // config.ini
CStockData * g_pStockData=NULL; // 주식종목 데이터.
CFile * g_pLogFile=NULL;
////////////////////////////////////////////////////////////////
// semitransparent Window2000 and WindowsXP only...
void CloseSmoothly(HWND hWnd)
{
// Increase transparency one percent each time...
for(int nPercent=100; nPercent >= 0 ;nPercent--)
SetTransparent(hWnd, 0, 255 * nPercent/100, LWA_ALPHA);
}
////////////////////////////////////////////////////////////////
// This function sets the transparency layered window by calling SetLayeredWindowAttributes API function.
BOOL SetTransparent(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
{
BOOL bRet = TRUE;
typedef BOOL (WINAPI* lpfnSetTransparent)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
// Check that "USER32.dll" library has been loaded successfully...
if ( g_hUserDll )
{
lpfnSetTransparent pFnSetTransparent = NULL;
pFnSetTransparent = (lpfnSetTransparent)GetProcAddress(g_hUserDll, "SetLayeredWindowAttributes");
if (pFnSetTransparent )
bRet = pFnSetTransparent(hWnd, crKey, bAlpha, dwFlags);
else
bRet = FALSE;
} //if( g_hUserDll )
return bRet;
} // End of SetTransparent function
////////////////////////////////////////////////////////////////
// NT : VER_PLATFORM_WIN32_NT, 95 : VER_PLATFORM_WIN32_WINDOWS
DWORD GetOsVersion()
{
OSVERSIONINFO osversioninfo;
osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo);
// Get the current OS version
if (!GetVersionEx(&osversioninfo))
return 0;
return osversioninfo.dwPlatformId;
}
////////////////////////////////////////////////////////////////
//사운드 리소스 파일을 플레이 시킨다 ( Plays a WAVE resource )
BOOL PlayResource(WORD wResourceID)
{
// Get the handle to the current instance of the application
HINSTANCE hInstance = AfxGetInstanceHandle();
ASSERT (hInstance != NULL);
// Find the WAVE resource
HRSRC hResInfo =
FindResource(hInstance, MAKEINTRESOURCE(wResourceID), _T("WAVE"));
if(hResInfo == NULL)
return FALSE;
// Load the WAVE resource
HANDLE hRes = LoadResource(hInstance, hResInfo);
if (hRes == NULL)
return FALSE;
// Lock the WAVE resource and play it
LPSTR lpRes = (LPSTR) LockResource(hRes);
if(lpRes==NULL)
return FALSE;
if (sndPlaySound(lpRes, SND_MEMORY | SND_ASYNC) == NULL)
return FALSE;
// Free the WAVE resource and return success or failure.
FreeResource(hRes);
return TRUE;
}
////////////////////////////////////////////////////////////////
// FormatMessage
void Message_Box( PSTR pTitle, DWORD dwError )
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
TCHAR szMsg[512] = {0,};
wsprintf( szMsg, "%s\nError code : %d", lpMsgBuf, dwError );
::MessageBox( NULL, szMsg, pTitle, MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}