The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on December 01, 2008, 06:39:20 PM

Title: Need help with GetSaveFileName
Post by: ragdog on December 01, 2008, 06:39:20 PM
Hi

I have a question to GetSaveFileName this crash under xp-sp2
If i remove this
          mov  @stOF.lpstrDefExt, "txt"
          mov  @stOF.lpstrCustomFilter,NULL
          mov  @stOF.nMaxCustFilter,0

works this.



_GetSaveFileName proc uses edi, hWnd:HWND
LOCAL @stOF:OPENFILENAME

       invoke  RtlZeroMemory,addr @File,sizeof @File
       invoke  RtlZeroMemory,addr @stOF,sizeof @stOF
         mov  @stOF.lStructSize,sizeof @stOF
push  hWnd
  pop  @stOF.hwndOwner

          mov  @stOF.lpstrFilter,offset szSaveFilter
          mov  @stOF.lpstrFile,offset @File
          mov  @stOF.nMaxFile,512
          mov  @stOF.lpstrTitle, offset szBrowseTitle
          mov  @stOF.lpstrDefExt, "txt"
          mov  @stOF.lpstrCustomFilter,NULL
          mov  @stOF.nMaxCustFilter,0
          mov  @stOF.Flags,OFN_OVERWRITEPROMPT OR OFN_HIDEREADONLY
         
          .if !@File
              invoke lstrcpyn,addr @File,CTEXT ("File.txt"),256
          .endif
       
          invoke GetSaveFileName,addr @stOF
             .if  eax
      mov eax,@stOF.lpstrFile
     .endif
         ret
_GetSaveFileName endp


greets
Title: Re: Need help with GetSaveFileName
Post by: jj2007 on December 01, 2008, 08:30:28 PM
lpstrCustomFilter
    Pointer to a static buffer that contains a pair of null-terminated filter strings

One NULL is not enough. This might be one reason for your crash.
EDIT: But mov  @stOF.lpstrDefExt, "txt" is another hot candidate. Try
mov  @stOF.lpstrDefExt, chr$("txt")
Title: Re: Need help with GetSaveFileName
Post by: ragdog on December 01, 2008, 08:50:02 PM
Thanks for your help i try it