News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Calling a text file

Started by Force, May 04, 2012, 12:05:52 PM

Previous topic - Next topic

Force

Hello

How can I call a txt file by opening Notepad ?

I wanna use a txt file as help file in the program ... (After clicking help button)

is there any example about it?

thanks

Force
Never Stop Until You Are Better Than The Best

qWord

ShowFile proc pszFullFilePath: ptr TCHAR
LOCAL sei:SHELLEXECUTEINFO

fn RtlZeroMemory,&sei,SIZEOF sei
mov sei.cbSize,SIZEOF sei
mov sei.nShow,SW_NORMAL
mov sei.lpDirectory,WinDir$()
mov sei.lpFile,chr$("notepad.exe")
m2m sei.lpParameters,pszFullFilePath

fn ShellExecuteEx,&sei
ret

ShowFile endp
FPU in a trice: SmplMath
It's that simple!

Force

I mean like that C code  Somebody can translate it?

HINSTANCE hInst = ShellExecute(0,                           
                                   "open",                      // Operation to perform
                                   "c:\\windows\\notepad.exe",  // Application name
                                   "c:\\example.txt",           // Additional parameters
                                   0,                           // Default directory
                                   SW_SHOW);
Never Stop Until You Are Better Than The Best

Force

Ok ok i translated it my self  :toothy

.386
.model flat, stdcall
option casemap :none   

; ###############################
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\shell32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\shell32.lib
     
; ################################

    .data
           buffer db "test.txt",0
           opn db "open",0                   

    .data?


    .code

start:

  invoke ShellExecute,0,addr opn,addr buffer,NULL,NULL,SW_SHOWNORMAL
  invoke ExitProcess,NULL

end start
Never Stop Until You Are Better Than The Best

hutch--

Try this if you have included the masm32 macro file.


fn ShellExecute,0,"open","test.txt",NULL,NULL,SW_SHOWNORMAL


You can also use "fnx".
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Force

Thanks Hutch

using masm32rt.inc is simple way

in fact i dont use masm32rt.inc  often not to be lazy in masm32  :toothy
.386
include \masm32\include\masm32rt.inc
.code

start:
fn ShellExecute,0,"open","test.txt",NULL,NULL,SW_SHOWNORMAL
invoke ExitProcess,NULL
end start

Never Stop Until You Are Better Than The Best