zoukankan      html  css  js  c++  java
  • Read From Console Program

    To read characters entered by the user, call GetStdHandle to get the console’s standard input handle and call ReadConsole, using the same input handle. The following ReadConsole program demonstrates the technique. Notice that Win32 API calls are compatible with the Irvine32 library, so we are able to call DumpRegs at the same time we call Win32 functions:

    TITLE Read From the Console (ReadConsole.asm)
    INCLUDE Irvine32.inc
    BufSize = 80
    .data
    buffer BYTE BufSize DUP(?),0,0
    stdInHandle HANDLE ?
    bytesRead DWORD ?
    .code
    main PROC
    ; Get handle to standard input
    INVOKE GetStdHandle, STD_INPUT_HANDLE
    mov stdInHandle,eax
    ; Wait for user input
    INVOKE ReadConsole, stdInHandle, ADDR buffer,
    BufSize, ADDR bytesRead, 0
    ; Display the buffer
    mov esi,OFFSET buffer
    mov ecx,bytesRead
    mov ebx,TYPE buffer
    call DumpMem
    exit
    main ENDP
    END main

    If the user enters “abcdefg”, the program generates the following output. Nine bytes are inserted in the buffer: “abcdefg” plus 0Dh and 0Ah, the end-of-line characters(First a Carriage-Return(ASCII CODE:0D), then a new line(ASCII CODE:0A)) inserted when the user pressed the Enter key. bytesRead equals 9:

    Dump of offset 00404000

    -------------------------------

    61 62 63 64 65 66 67 0D 0A

  • 相关阅读:
    iOS 倒计时及获取本时区时间
    文字上的删除线
    ios 预览文件-QLPreviewController用法
    iOS delegate、notification、KVO的区别
    mvc 详解
    app切图暂时没有iOS8的,后续继续添加
    背影图
    字体渐变
    ios for 循环 创建 九宫格
    Spherical Harmonics Lighting
  • 原文地址:https://www.cnblogs.com/dreamafar/p/5978765.html
Copyright © 2011-2022 走看看