使用程序集保存对话框

时间:2011-06-21 19:42:00

标签: assembly editor

我用程序集编写了一个程序,它就像一个编辑器(记事本,Word等)。现在,当我按下 F10 等快捷键时,我想显示一个保存对话框,用于保存便笺容器的内容。
我怎么能这样做? 感谢

2 个答案:

答案 0 :(得分:1)

假设您正在使用masm32和win32 sdk,当然在Windows下,this正是您正在寻找的,并且快速搜索谷歌给了我this关于热键检测。< / p>

答案 1 :(得分:1)

这就是我要做的事情:

WinProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  LOCAL ofn:OPENFILENAME
  LOCAL filePath[MAX_PATH]:BYTE
  LOCAL hFile:HANDLE

  .IF uMsg == WM_CREATE
    xor             eax, eax
  .ELSEIF uMsg == WM_KEYDOWN
    mov             eax, wParam
    .IF eax == VK_F10
      ; Prepare the OPENFILENAME structure
      invoke        RtlZeroMemory, ADDR ofn, SIZEOF OPENFILENAME
      invoke        RtlZeroMemory, ADDR filePath, MAX_PATH
      mov           ofn.lStructSize, SIZEOF OPENFILENAME
      m2m           ofn.hwndOwner, hWnd
      mov           ofn.lpstrFilter, CTEXT("All Files (*.*)",0,"*.*",0,0)
      mov           ofn.nFilterIndex, 1
      lea           eax, [filePath]
      mov           ofn.lpstrFile, eax
      mov           ofn.nMaxFile, MAX_PATH
      mov           ofn.Flags, OFN_PATHMUSTEXIST+OFN_FILEMUSTEXIST+OFN_EXPLORER

      .IF $invoke( GetOpenFileName, ADDR ofn ) != 0
        ; File selected...
        lea         esi, [ofn]
        invoke      CreateFile, (OPENFILENAME PTR [esi]).lpstrFile, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, 0, NULL
        .IF eax != INVALID_HANDLE_VALUE
          ; File opened...
          mov       hFile, eax
          inovke    CloseHandle, hFile
        .ENDIF
      .ENDIF
    .ELSEIF eax == VK_ESCAPE
      invoke        DestroyWindow, hWnd
    .ENDIF
  .ELSEIF uMsg == WM_DESTROY
    invoke          PostQuitMessage, NULL
  .ELSE
    invoke          DefWindowProc, hWnd, uMsg, wParam, lParam
  .ENDIF
  ret
WinProc endp

如果您没有alredy,我使用的宏是:

    m2m MACRO dest:REQ, src:REQ
      push  src
      pop   dest
    ENDM            

    CTEXT MACRO y:VARARG
      LOCAL sym, dummy
      dummy EQU $   ;; MASM error fix
      CONST SEGMENT
        IFIDNI <y>,<>
          sym db 0
        ELSE
          sym db y,0
        ENDIF
      CONST ends
      EXITM <OFFSET sym>
    ENDM

    $invoke MACRO Function:REQ, Args:VARARG
      IFB <Args>
        invoke  Function
      ELSE
        invoke  Function, Args
      ENDIF
      EXITM <eax>
    ENDM