News:

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

Main Menu

Problem with CreateDirectory

Started by Zen, April 28, 2015, 07:10:12 AM

Previous topic - Next topic

Zen

SORRY. I figured it out. I feel like such an idiot. I forgot to add the .code directive to the top of my include file !!!

This is such a simple problem. I've written a simple procedure to create a directory,...something I've done many times before in MASM programs. And, I'm getting a couple of errors, repeatedly, that I just don't understand. What amazes me is that my short procedure is very similar to code that I'm using elsewhere in the same program (and, which works without a problem).
...Anyway,...here's the procedure:   

CrtServerDirctry PROC   

    invoke GetCurrentDirectory, 256, ADDR PathCurDir    ;   Memory location for the Current Directory.   
    .IF eax==0
     RET
    .ENDIF   
;  If lstrcpy fails, the return value is NULL   
    invoke lstrcpy, ADDR ServerDirectry, ADDR PathCurDir       
    .IF eax==0
     RET
    .ENDIF   
    invoke lstrcat, ADDR ServerDirectry, ADDR szServerDirctry       
    .IF eax==0
     RET
    .ENDIF   
    mov eax, 0
    mov eax, OFFSET ServerDirectry   
    mov lpServrDir, eax   
;  If CreateDirectory fails, the return value is zero. If the directory already   
;  exists, CreateDirectory fails, but, calling GetLastError returns 183.       
    invoke CreateDirectory, lpServrDir, NULL
    .IF eax==0
     invoke GetLastError
     CMP eax, 183
     RET   
    .ENDIF 

     RET

CrtServerDirctry ENDP


The errors I'm getting (repeatedly) are:   
error A2108: use of register assumed to ERROR.   
error A2107: cannot have implicit far jump or call to near label.

jj2007

The errors indicate that for some reason you are in the .data or .data? section, not in .code

error 183 is "directory exists".

Zen

JOCHEN,
Yeah,...you're right,...I realized what it was just after I posted.
THANKS ANYWAY.