www.pudn.com > MirServer.rar > MirServerTest.cpp
// MirServerTest.cpp : 定义应用程序的入口点。 // #include "stdafx.h" #include#include "MirServerTest.h" #include "mirserver.h" #define MAX_LOADSTRING 100 // 全局变量: HINSTANCE hInst; // 当前实例 CMirServer g_MirServer; LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // TODO: 在此放置代码。 hInst = hInstance; AllocConsole(); freopen("CONOUT$", "w+", stdout); DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, GetDesktopWindow(), (DLGPROC)About); FreeConsole(); return 0; } INT GetValue( char chex ) { if( chex >= '0' && chex <= '9' ) return (int)(chex -'0'); if( (chex >= 'a' && chex <= 'f')) return (int)((chex - 'a')+10); if(chex >= 'A' && chex <= 'F' ) return (int)((chex -'A')+10); return 0; } UINT Hex2Int( char * pszHex ) { UINT ret=0; int i = 0; int icount = strlen( pszHex ); for( i = 0;i < strlen( pszHex ); i ++ ) { ret += GetValue( pszHex[i] ) << ( 4 * (icount - i - 1 )); } return ret; } // “关于”框的消息处理程序。 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_DESTROY: { g_MirServer.End(); } break; case WM_COMMAND: { UINT id = LOWORD(wParam); switch( id ) { case IDOK: case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); break; case ID_TEST: { DWORD dwView; CHAR szNumber[200]; GetDlgItemText( hDlg, IDT_VIEW, szNumber, 200 ); dwView = Hex2Int( szNumber ); g_MirServer.Test( dwView ); } break; case ID_START: g_MirServer.Run(); break; } } break; } return FALSE; }