This commit is contained in:
297
Global.cpp
Normal file
297
Global.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
// Spy.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Global.h"
|
||||
#include "Resource.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
HKEY ghkeySpy = NULL;
|
||||
CHAR gszSpyAppKey[] = "Software\\Yourisoft\\FutureChecker";
|
||||
CHAR gszKeyPosition[] = "Position";
|
||||
|
||||
//LPSTR StripExtension(LPSTR pszFileName);
|
||||
|
||||
|
||||
|
||||
APPENV g_AppEnv = {
|
||||
1000, // 순물체결량 제한시간.
|
||||
5, // 순물체결량 라인 수.
|
||||
0, // 순물체결량 차이계산(0), 단독합산(1).
|
||||
500, // 순물체결량 상승 인식.
|
||||
500, // 순물체결량 하락 인식.
|
||||
1, // 순물체결량 적용여부.
|
||||
|
||||
"10143", // 선물종목코드.
|
||||
1000, // 순물호가 제한시간.
|
||||
2, // 순물호가 호가변화 단계.
|
||||
1, // 순물호가 적용여부.
|
||||
|
||||
0, // 적용구분 교집합(0), 합집합(1).
|
||||
1000, // 적용구분 합집합시 제한시간.
|
||||
1, // 핫키 실행후 풀림상태 계속유지.
|
||||
{0,0}, // 잠금/풀림 핫키.
|
||||
{0,0}, // 상승 적용 핫키.
|
||||
{0,0}, // 하락 적용 핫키.
|
||||
};
|
||||
|
||||
WINDOWPLACEMENT gwndpl;
|
||||
HMODULE g_hUserDll = NULL;
|
||||
//CCondition g_Condition; // 조건 처리.
|
||||
CConfigINI g_ConfigINI; // config.ini
|
||||
CString g_strBankAccount; // 계좌번호.
|
||||
CString g_strBankAccountPermitted; // 인증허가된 계좌번호 리스트.
|
||||
//CStockData * g_pStockData; // 주식종목 데이터.
|
||||
//CFile * g_pLogFile;
|
||||
|
||||
|
||||
ICpTdUtilPtr g_objTdUtil;
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// 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 );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************\
|
||||
* ReadRegistry
|
||||
*
|
||||
* Opens (creates if necessary) the registry key for spy preferences and then
|
||||
* reads the last saved values.
|
||||
*
|
||||
* Arguments:
|
||||
* none
|
||||
*
|
||||
* Returns:
|
||||
* VOID
|
||||
\*****************************************************************************/
|
||||
|
||||
VOID
|
||||
ReadRegistry(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
DWORD dwType;
|
||||
DWORD cbData;
|
||||
|
||||
RegCreateKey(HKEY_CURRENT_USER, gszSpyAppKey, &ghkeySpy);
|
||||
|
||||
cbData = gwndpl.length = sizeof(gwndpl);
|
||||
if (!ghkeySpy || RegQueryValueEx(ghkeySpy, gszKeyPosition, NULL, &dwType,
|
||||
(LPBYTE)&gwndpl, &cbData) != ERROR_SUCCESS)
|
||||
{
|
||||
gwndpl.length = 0;
|
||||
}
|
||||
|
||||
if (gwndpl.length != sizeof(gwndpl))
|
||||
{
|
||||
/* gwndpl.length = sizeof(gwndpl);
|
||||
gwndpl.flags = 0;
|
||||
gwndpl.showCmd = SW_SHOWNORMAL;
|
||||
gwndpl.ptMinPosition.x = 0;
|
||||
gwndpl.ptMinPosition.y = 0;
|
||||
gwndpl.ptMaxPosition.x = 0;
|
||||
gwndpl.ptMaxPosition.y = 0;
|
||||
gwndpl.rcNormalPosition.left = 10;
|
||||
gwndpl.rcNormalPosition.top = 10;
|
||||
gwndpl.rcNormalPosition.right =
|
||||
10 + (GetSystemMetrics(SM_CXSCREEN) / 3);
|
||||
gwndpl.rcNormalPosition.bottom =
|
||||
10 + (GetSystemMetrics(SM_CYSCREEN) / 3);
|
||||
*/ }
|
||||
/*
|
||||
for( int i=0; i< MAX_FIND; i++ )
|
||||
{
|
||||
cbData = sizeof(HWND);
|
||||
TCHAR szKeyName[100] = {0,};
|
||||
wsprintf( szKeyName, "HWND_%d", i );
|
||||
if (!ghkeySpy || RegQueryValueEx(ghkeySpy, szKeyName, NULL, &dwType,
|
||||
(LPBYTE)&g_hFindWindow[i], &cbData) != ERROR_SUCCESS)
|
||||
{
|
||||
g_hFindWindow[i] = NULL;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************\
|
||||
* WriteRegistry
|
||||
*
|
||||
* Writes out preference data to the registry when the app exits, then
|
||||
* closes the registry key.
|
||||
*
|
||||
* Arguments:
|
||||
* none
|
||||
*
|
||||
* Returns:
|
||||
* VOID
|
||||
\*****************************************************************************/
|
||||
|
||||
VOID
|
||||
WriteRegistry(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (ghkeySpy)
|
||||
{
|
||||
WINDOWPLACEMENT wndpl;
|
||||
wndpl.length = sizeof(WINDOWPLACEMENT);
|
||||
::GetWindowPlacement( AfxGetApp()->GetMainWnd()->m_hWnd, &wndpl);
|
||||
RegSetValueEx(ghkeySpy, gszKeyPosition, 0, REG_BINARY,
|
||||
(LPBYTE)&wndpl, sizeof(wndpl));
|
||||
/*
|
||||
for( int i=0; i< MAX_FIND; i++ )
|
||||
{
|
||||
TCHAR szKeyName[100] = {0,};
|
||||
wsprintf( szKeyName, "HWND_%d", i );
|
||||
RegSetValueEx(ghkeySpy, szKeyName, 0, REG_DWORD,
|
||||
(LPBYTE)&g_hFindWindow[i], sizeof(DWORD));
|
||||
}
|
||||
*/
|
||||
|
||||
// RegSetValueEx(ghkeySpy, gszKeyHWND1, 0, REG_BINARY,
|
||||
// (LPBYTE)g_hFindWindow[0], sizeof(HWND));
|
||||
// RegSetValueEx(ghkeySpy, gszKeyFileName, 0, REG_SZ,
|
||||
// (LPBYTE)gszFile, (lstrlen(gszFile) + 1) * sizeof(TCHAR));
|
||||
|
||||
RegCloseKey(ghkeySpy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************\
|
||||
* StripExtension
|
||||
*
|
||||
* Strips the extension off of a filename.
|
||||
*
|
||||
* Arguments:
|
||||
* LPSTR pszFileName - File name to process.
|
||||
*
|
||||
* Returns:
|
||||
* Returns a pointer to the beginning of the filename. The extension
|
||||
* will have been stripped off.
|
||||
*
|
||||
\*****************************************************************************/
|
||||
/*
|
||||
PRIVATE LPSTR
|
||||
StripExtension(
|
||||
LPSTR pszFileName
|
||||
)
|
||||
{
|
||||
LPSTR p = pszFileName;
|
||||
|
||||
while (*p)
|
||||
p++;
|
||||
|
||||
while (p > pszFileName && *p != '\\' && *p != ':') {
|
||||
p = CharPrev(pszFileName, p);
|
||||
if (*p == '.') {
|
||||
*p = 0;
|
||||
}
|
||||
}
|
||||
if (*p == '\\' || *p == ':') {
|
||||
p++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user