.data?
fpMem          dd  ?
hpMem          dd  ?
BytesR         dd  ?

;===================================================
; Read file  PROCEDURE
;===================================================
ReadF PROC
LOCAL    hFile:DWORD

      .if hpMem
         INVOKE     GlobalUnlock, fpMem
         INVOKE     GlobalFree, hpMem
            and     hpMem, 0
      .endif

;---------- [CreateFile Read] ----------
      INVOKE     CreateFile, addr PathName,
                 GENERIC_READ or GENERIC_WRITE ,
                 FILE_SHARE_READ or FILE_SHARE_WRITE,
                 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, NULL
      .if eax == INVALID_HANDLE_VALUE
            xor     eax, eax
            jmp     NoFile
      .endif
         mov     hFile, eax
      INVOKE     GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT, 1000000
         mov     hpMem, eax
      INVOKE     GlobalLock, hpMem
         mov     fpMem, eax
      INVOKE     ReadFile, hFile, fpMem, 1000000, addr BytesR, NULL
        push     eax
      INVOKE     CloseHandle, hFile
         pop     eax

NoFile:
         ret

ReadF ENDP

;---------- [You could use the following instruction to display the text
;      INVOKE     SendMessage, hREdit, WM_SETTEXT, NULL, fpMem
