//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : GetMachineId.cpp Data : 13.09.14 Versione : 1.5i2 // Contenuto : Programma per lettura identificativo di macchina. // // // // Modifiche : 13.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include #include #include #include "resource.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/SELkMachineId.h" //------------------------------------------------------------------------------ #pragma comment( linker, \ "\"/manifestdependency:type='Win32' "\ "name='Microsoft.Windows.Common-Controls' "\ "version='6.0.0.0' "\ "processorArchitecture='x86' "\ "publicKeyToken='6595b64144ccf1df' "\ "language='*'\"") #pragma comment( lib, "ComCtl32.lib") #include "/EgtDev/Include/EgtLibVer.h" #pragma comment( lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib") //------------------------------------------------------------------------------ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch( uMsg) { case WM_COMMAND : switch ( LOWORD( wParam)) { case IDOK : SendMessage( hDlg, WM_CLOSE, 0, 0) ; return TRUE ; } break ; case WM_CLOSE : DestroyWindow( hDlg) ; return TRUE ; case WM_DESTROY : PostQuitMessage( 0) ; return TRUE ; } return FALSE ; } //------------------------------------------------------------------------------ int WINAPI wWinMain( HINSTANCE hInst, HINSTANCE h0, LPTSTR lpCmdLine, int nCmdShow) { // inizializzazioni InitCommonControls() ; HWND hDlg = CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_DIALOG1), NULL, DialogProc, 0) ; HWND hText = GetDlgItem( hDlg, IDC_MACHID) ; SetClassLong( hDlg, GCL_HICON, (LONG) LoadIcon( hInst, MAKEINTRESOURCE(IDI_ICON))) ; // se realese verifico debug non attivo #if defined( NDEBUG) BOOL IsDbgPresent = FALSE ; CheckRemoteDebuggerPresent( GetCurrentProcess(), &IsDbgPresent) ; if ( IsDbgPresent) return 0 ; #endif // calcolo MachineId e lo imposto nell'edit std::string sMachineId ; if ( ! CalcMachineId( false) || ! GetMachineId2( sMachineId)) sMachineId = "Error" ; SetWindowTextW( hText, stringtoW( sMachineId)) ; // visualizzzione dialogo ShowWindow( hDlg, nCmdShow) ; // loop dei messaggi MSG msg ; BOOL ret ; while ( ( ret = GetMessage( &msg, 0, 0, 0)) != 0) { if ( ret == -1) return -1 ; if ( ! IsDialogMessage( hDlg, &msg)) { TranslateMessage( &msg) ; DispatchMessage( &msg) ; } } return 0 ; }