News:

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

Main Menu

GetOpenFileName and select more than one file

Started by Avizma, October 14, 2013, 11:34:49 PM

Previous topic - Next topic

jj2007

Quote from: TWell on October 18, 2013, 03:15:30 AM
For selecting folder name with GetOpenFileName() in C

Compiles fine, but returns always FALSE in WinXP SP3...

Avizma

In summary, I finded way to use the GetOpenFileName for select folder (not files).
I repeat a posts of this forum, may be. But I think, this topic, will be more complete.


OpenFileDialogg proc hwnd:DWORD
   
    PUSH SIZEOF OPFILESTR
    PUSH OFFSET OPFILESTR
CALL RtlZeroMemory@8

PUSH SIZEOF szFile
        PUSH OFFSET szFile
CALL RtlZeroMemory@8

LEA EAX, [szFile]
MOV BYTE PTR [EAX], '*'
   
    MOV OPFILESTR.lStructSize,SIZEOF OPFILESTR
    MOV EAX, hwnd
    MOV OPFILESTR.hwndOwner, EAX
    MOV EAX, OFFSET szFile
    MOV OPFILESTR.lpstrFile, EAX
    MOV OPFILESTR.nMaxFile, SIZEOF szFile
    MOV EAX, OFFSET strFilter
    MOV OPFILESTR.lpstrFilter, EAX
    MOV OPFILESTR.nFilterIndex,1
    MOV OPFILESTR.lpstrFileTitle,0
    MOV OPFILESTR.nMaxFileTitle,0
    MOV OPFILESTR.lpstrInitialDir,0
    MOV OPFILESTR.Flags, OFN_NOVALIDATE
   
    PUSH OFFSET OPFILESTR
        CALL GetOpenFileNameA@4
       
   
    ret 4
OpenFileDialogg endp

dedndave

no need to zero the entire szFile buffer
    mov word ptr szFile,'*'
sets it to '*',0

also, if you have cleared out the OPENFILENAME structure, no need for...
    MOV OPFILESTR.lpstrFileTitle,0
    MOV OPFILESTR.nMaxFileTitle,0
    MOV OPFILESTR.lpstrInitialDir,0


anyways - it looks interesting - i'll have to try it out   :t

Avizma

Thanks, Dave!
You are absolutely right, about
MOV OPFILESTR.lpstrFileTitle,0.