News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

select file of the list

Started by 03.jose, July 30, 2012, 09:09:38 AM

Previous topic - Next topic

03.jose

hello I wanted to ask if anyone knows how to open a file you select from a list, the file has extention txt or asm. other than FileName db "\problemas\ ejemplo2.txt", 0 as it is very static, I want something more dynamic because I know the name of the file will be called

attached the file I am where I am working

jj2007

LB_GETTEXT and ShellExecute are your friends, José :t

03.jose

can you giveme an example please??

jj2007

No, but you can search the forum.

03.jose

hello I still have the same problem ... I think I not understand LB_GETTEXT use, the problem is that I could not pass (send) the file path to open (display contents), could help me please?

jj2007

Post your code, with comments telling us what you have tried so far, and we'll see :icon14:

TouEnMasm

To open a file you use this function:
Quote
      ;----------------------------
      ;  open a file for read
      ;----------------------------
invoke CreateFile,addr pathopenfile,GENERIC_READ,NULL,\
               NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
         .if eax==INVALID_HANDLE_VALUE
            mov retour,eax
            jmp somewhere
         .endif
         mov hFile,eax

If you are on a treeview,read the nod.This one can use a short path(only the name),you need the fool path (directory + name) to open it.
Search this name in a list of full path (you have to made this one) and pass the full path to the createfile function.






Fa is a musical note to play with CL

03.jose

yes, something like that is what I tried. this is how I've been until now the treeview

jj2007

Your filename is no good - this reserves one single byte:
FileName    DB          ?

This works (hola mundo) but it's a bit clumsy because I extract the true filename from mbp.lpszText:

        mov eax, mbp.lpszText
.Repeat
inc eax
.Until byte ptr [eax]=="="  ; get start of filename
.Repeat
inc eax
.Until byte ptr [eax]>" "  ; without whitespace
.data?
pFile dd ?
.code
mov pFile, eax  ; store begin of filename
.Repeat
inc eax
.Until byte ptr [eax]<=" "  ; find whitespace (won't work if your filename has spaces!!!)
mov byte ptr [eax], 0  ; delimit filename
        ;mov  FileName, mbp.lpszText

        invoke CreateFile,pFile,\
                GENERIC_READ or GENERIC_WRITE ,\
                FILE_SHARE_READ,\
                NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
                NULL

03.jose

hello, thanks for the help they give me.

Now what I'm trying to do is to work the code you gave me when you select a file to asm these are in the "soluciones (asm)", not because it does not.

the other thing I wanted to ask is because EjecutarExe calls to run an exe file, and to probe the function separately (ShellExecute) and worked, not because here it does not, what is it I am doing wrong so that do not call?

jj2007

Attached version opens ejemplo.txt in Notepad. Check for badcode in the *.asm source

You are pretty closen now :t

03.jose

excuse me, i have a problem with RichMasm

You cannot use the MasmBasic library with ml.exe version 6.14, sorry - try JWasm or ml 6.15

##########################
\masm32\MasmBasic\MasmBasic.inc(176) : error A2052: forced error
TestMasmVersion(7): Macro Called From
  \masm32\MasmBasic\MasmBasic.inc(176): Include File
*** Assembly Error ***

but i copy the JWasm in the \masm32\bin

the ml.exe version 6.15 i not found

jj2007

Just add this somewhere:

; OPT_Assembler   JWasm





03.jose

you were right, I forgot to add the line told me.

but still not open asm files or run exe files, why is if you have the instructions?

another question: why did not you show me icons similarly if the user already has?

jj2007

Hi,

I have no idea, but you can find out:
- in line 3, set useMB=1
- in line 581, insert this (see here for help):
    deb 1, "Line 580", eax, ebx, $tvi.pszText

You will see that tvi.pszText is always on ejemplo1.txt, so the error is before this line. Use the deb macro to find out where...