The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: dedndave on March 02, 2011, 02:03:08 PM

Title: GetSaveFileName file extension problem
Post by: dedndave on March 02, 2011, 02:03:08 PM
i have more-or-less working dialog code - lol
it works fine, but....

if the user puts in a filename extension, the default extension is also appended to it   :red

QuotelpstrDefExt

    The default extension. GetOpenFileName and GetSaveFileName append this extension to the
file name if the user fails to type an extension. This string can be any length, but only the first
three characters are appended. The string should not contain a period (.). If this member is NULL
and the user fails to type an extension, no extension is appended.

test code attached....
Title: Re: GetSaveFileName file extension problem
Post by: jj2007 on March 02, 2011, 03:07:10 PM
Not on my PC (Win XP SP2). Are your "known" extensions visible in Explorer?
Title: Re: GetSaveFileName file extension problem
Post by: dedndave on March 02, 2011, 05:01:05 PM
i typed in "abc.abc", and got this....

(http://img10.imageshack.us/img10/9981/extu.png)

and - i hate when the known extensions are hidden - lol
that's one of the first things i set when i rebuild
Title: Re: GetSaveFileName file extension problem
Post by: dedndave on March 02, 2011, 06:24:37 PM
anyone else have the same problem as me ?
or does it work on more than one machine ?
Title: Re: GetSaveFileName file extension problem
Post by: FORTRANS on March 02, 2011, 06:51:05 PM
Hi,

   Yep.  Exactly as described.  Both with your app (?) and with
WordPad every so often.  You can work around this "feature"
by using quotes.

Regards,

Steve N.
Title: Re: GetSaveFileName file extension problem
Post by: dedndave on March 02, 2011, 07:13:22 PM
thanks, both of you
i was worried there was something wrong with me, my machine, or my code - lol
probably all three   :bg
Title: Re: GetSaveFileName file extension problem
Post by: jj2007 on March 02, 2011, 07:15:21 PM
Actually, it is more complicated:

abc.abc yields abc.abc.txt
abc.doc yields abc.doc

Apparently, the OS checks if the extension is known. If not, the default extension will be added.
Title: Re: GetSaveFileName file extension problem
Post by: FORTRANS on March 02, 2011, 10:06:10 PM
Hi,

   Cute.  Went into WordPad and tried to save TEST.ASM and
got TEST.ASM.txt.  Went to the Control Panel and added ASM
as a file type and repeated the experiment and got TEST.ASM.
I would never have known that an ASM file has the file type
FT000001.  What you can learn in the land of Microsloth.

Cheers,

Steve N.
Title: Re: GetSaveFileName file extension problem
Post by: dedndave on March 02, 2011, 10:56:19 PM
 :P
it can be cleaned up with code, easy enough
Title: Re: GetSaveFileName file extension problem
Post by: Antariy on March 03, 2011, 01:46:40 AM
Edit: Oh, reading posts from bottom to the top, do not saw that there is answer already (http://www.masm32.com/board/index.php?topic=16199.msg133911#msg133911).