The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Force on May 04, 2012, 12:05:52 PM

Title: Calling a text file
Post by: Force on May 04, 2012, 12:05:52 PM
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
Title: Re: Calling a text file
Post by: qWord on May 04, 2012, 01:37:52 PM
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
Title: Re: Calling a text file
Post by: Force on May 04, 2012, 02:24:10 PM
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);
Title: Re: Calling a text file
Post by: Force on May 04, 2012, 02:42:51 PM
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
Title: Re: Calling a text file
Post by: hutch-- on May 04, 2012, 04:55:07 PM
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".
Title: Re: Calling a text file
Post by: Force on May 04, 2012, 06:05:19 PM
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