DWORD _tmain(DWORD argc, _TCHAR* argv[])
{
	GetInfoComputer();
	KnowTimeToSwitchWindowsThread();
	printf("------------------------------------------------");
	_gettchar();
	return 1;
}
Beispiel #2
0
int clearsyskey(int argc, TCHAR** argv)
{
	if (0 != argc && 1 != argc) {
		return usage();
	}

	BOOL fConfirm = TRUE;
	if (1 == argc) {
		if (0 == ::lstrcmpi(_T("/q"), argv[0]) ||
			0 == ::lstrcmpi(_T("-q"), argv[0]))
		{
			fConfirm = FALSE;
		} else {
			return usage();
		}
	}

	if (fConfirm) {

		_tprintf(_T("Are you sure to delete the system key? (Y/N) "));

#if 0 
		//
		// MSVCRT.DLL (6.1 in Windows 2000) does not have _getwch().
		// But MSVCRT.DLL (7.1 in Windows XP) does.
		// Use _gettchar() instead.
		//

		TCHAR ch = _gettch();
		_tprintf(_T("%c\n"), ch);

		if (_T('Y') != ch && _T('y') != ch) {
			return 1;
		}
#else
		TCHAR ch = _gettchar();

		if (_T('Y') != ch && _T('y') != ch) 
		{
			return 1;
		}
#endif
	}

	UINT lResult = ::NdasEncRemoveSysKey();

	if (ERROR_SUCCESS != lResult) {
		DWORD dwStatus = ::GetLastError();
		_tprintf(_T("Removing the system key failed with error %08X (Code: %08X).\n"), lResult, dwStatus);
		return lResult;
	}

	_tprintf(_T("NDAS System Key is deleted successfully.\n"));

	return 0;
}
Beispiel #3
0
/* ----------------------- Start implementation -----------------------------*/
int
_tmain( int argc, _TCHAR * argv[] )
{
    int             iExitCode;
    TCHAR           cCh;
    BOOL            bDoExit;
	for (int Num = REG_INPUT_NREGS; Num >= 0; Num--)
	{
		usRegInputBuf[Num] = Num;
	}

	for (int Num = INPUT_STATUS_NREGS; Num >= 0; Num--)
	{
		ucInputStatusBuf[Num] = 1;
	}
	ucInputStatusBuf[0] = 255;

	for (int Num = 0; Num < REG_HOLDING_NREGS; Num++)
	{
		usRegHoldingBuf[Num] = Num;
	}

	for (int Num = 0; Num < INPUT_COIL_NREGS; Num++)
	{
		ucInputCoilBuf[Num] = 0;
	}
	ucInputCoilBuf[0] = 255;

    if( eMBTCPInit( MB_TCP_PORT_USE_DEFAULT ) != MB_ENOERR )
    {
        _ftprintf( stderr, _T( "%s: can't initialize modbus stack!\r\n" ), PROG );
        iExitCode = EXIT_FAILURE;
    }
    else
    {
        /* Create synchronization primitives and set the current state
         * of the thread to STOPPED.
         */
        InitializeCriticalSection( &hPollLock );
        eSetPollingThreadState( STOPPED );

        /* CLI interface. */
        _tprintf( _T( "Type 'q' for quit or 'h' for help!\r\n" ) );
        bDoExit = FALSE;
        do
        {
            _tprintf( _T( "> " ) );
            cCh = _gettchar(  );
            switch ( cCh )
            {
            case _TCHAR( 'q' ):
                bDoExit = TRUE;
                break;
            case _TCHAR( 'd' ):
                eSetPollingThreadState( SHUTDOWN );
                break;
            case _TCHAR( 'e' ):
                if( bCreatePollingThread(  ) != TRUE )
                {
                    _tprintf( _T( "Can't start protocol stack! Already running?\r\n" ) );
                }
                break;
            case _TCHAR( 's' ):
                switch ( eGetPollingThreadState(  ) )
                {
                case RUNNING:
                    _tprintf( _T( "Protocol stack is running.\r\n" ) );
                    break;
                case STOPPED:
                    _tprintf( _T( "Protocol stack is stopped.\r\n" ) );
                    break;
                case SHUTDOWN:
                    _tprintf( _T( "Protocol stack is shuting down.\r\n" ) );
                    break;
                }
                break;
            case _TCHAR( 'h' ):
                _tprintf( _T( "FreeModbus demo application help:\r\n" ) );
                _tprintf( _T( "  'd' ... disable protocol stack.\r\n" ) );
                _tprintf( _T( "  'e' ... enabled the protocol stack\r\n" ) );
                _tprintf( _T( "  's' ... show current status\r\n" ) );
                _tprintf( _T( "  'q' ... quit applicationr\r\n" ) );
                _tprintf( _T( "  'h' ... this information\r\n" ) );
                _tprintf( _T( "\r\n" ) );
                _tprintf( _T( "Copyright 2006 Christian Walter <*****@*****.**>\r\n" ) );
                break;
            default:
                if( cCh != _TCHAR('\n') )
                {
                    _tprintf( _T( "illegal command '%c'!\r\n" ), cCh );
                }
                break;
            }

            /* eat up everything untill return character. */
            while( cCh != '\n' )
            {
                cCh = _gettchar(  );
            }
        }
        while( !bDoExit );

        /* Release hardware resources. */
        ( void )eMBClose(  );
        iExitCode = EXIT_SUCCESS;
    }
    return iExitCode;
}
Beispiel #4
0
_TINT (_RTLENTRY _EXPFUNC _gettchar)( void )
  {
  return( _gettchar() );
  }