News:

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

FindExecutable

Started by Mr Earl, May 24, 2005, 02:26:29 PM

Previous topic - Next topic

Mr Earl

What's wrong with this example?

szWork  db 261 dup(0)

szFileNm  db "C:\masm32\AsmEditV5\Projects\Elib\Elib.asm",0

INVOKE FindExecutable,OFFSET szFileNm,0,OFFSET szWork


The return I always get is 31, "There is no association for the specified file type".
I know there IS a File Association for the file, and I tried several other files.

pbrennick

Since there is an association for that file, then the only thing that can be wrong is the path (though why it does not return a ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND is beyond me).  Can you post the code so I can test it on my machine?  There is something missing here.

Paul

Tedd

All seems to work fine for me..
I tried both ADDR and OFFSET - they both give the same result.
For a non-existent file, it returns error code 2.
There doesn't seem to be any problem with case sensitivity either.
:eek

.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include shell32.inc
includelib shell32.lib

.data
szfname db "C:\temp\test.asm",0
cod     db "Error - code %lu",0

.data?
szwork  db 261 dup (?)

.code
start:
    ;invoke FindExecutable, ADDR szfname,0,ADDR szwork
    invoke FindExecutable, OFFSET szfname,0,OFFSET szwork
    .IF (eax > 32)
        invoke MessageBox, NULL,ADDR szwork,ADDR szwork,MB_OK
    .ELSE
        invoke wsprintf, ADDR szwork,ADDR cod,eax
        invoke MessageBox, NULL,ADDR szwork,ADDR szwork,MB_OK or MB_ICONERROR
    .ENDIF
    invoke ExitProcess, NULL
end start

No snowflake in an avalanche feels responsible.

Mr Earl

Paul & Tedd,

As I was preparing to post my code I found MY mistake.

I inserted the code into an existing program just to test that function, but
the:  szFileNm db "C:\masm32\AsmEditV5\Projects\Elib\Elib.asm",0
was inserted under .data?

For some reason, it's only AFTER I post a question on the forum that I
find my mistakes.

Thanks for your time.

Steve

pbrennick

Hey Steve,
No problem at all.  It happens to us all.

Paul

pbrennick

Tedd,
Even though you wrote that test piece to determine the problem, it actually is a very useful tool to quickly show an association.  Well done and simple!   :thumbu :thumbu

Paul