#include "stdafx.h"

const PCHAR gameCaption = "SwdHC";
HWND gameh;
HANDLE processH;
DWORD processId;
BOOL startGame()
{
	//获取窗口句柄
	gameh = ::FindWindow(NULL,gameCaption);
	if(gameh == NULL)
	{
		AfxMessageBox("请先运行游戏！");
		return false;
	}
	//获取进程ID
	::GetWindowThreadProcessId(gameh,&processId);
	//打开进程
	processH = ::OpenProcess(PROCESS_ALL_ACCESS,false,processId);
	return true;
}
// Big5 to GBK_繁体
LPSTR Big52GBKTraditional(char * szText)
{
	int nLength;
	wchar_t *pBuffer;
	LPSTR pResult;
	int nResultLength;

	nLength = MultiByteToWideChar(950,0,szText,strlen(szText),NULL,0);
	pBuffer = new wchar_t(nLength+1);
	MultiByteToWideChar(950,0,(LPCSTR)szText,strlen(szText),(LPWSTR)pBuffer,nLength);
	pBuffer[nLength] = 0;

	nResultLength = WideCharToMultiByte(936,0,pBuffer,nLength,NULL,0,NULL,false);
	pResult = new char(nResultLength+1);
	WideCharToMultiByte(936,0,(LPWSTR)pBuffer,nLength,(LPSTR)pResult,nResultLength," ",false);
	pResult[nResultLength] = 0;

	return pResult;
}
