bug in windows getsavefilename api?



hi,

when i try to compile the following code and execute the program as follows,
it crashes. i tried the mingw compiler as well as ms vs .net 2003. but first
the code:



#define STRICT
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
szCmdLine, int iCmdShow)
{
OPENFILENAME FileDialogInfo;
char filterNames[] = "stuff (*.dat)\0*.dat\0";
char fileName[513];

for(int i=0; i<2; ++i)
{
ZeroMemory(&FileDialogInfo, sizeof(FileDialogInfo));
fileName[0] = '\0';
FileDialogInfo.lStructSize = sizeof(FileDialogInfo);
FileDialogInfo.hwndOwner = NULL;
FileDialogInfo.lpstrFilter = filterNames;
FileDialogInfo.nFilterIndex = 1;
FileDialogInfo.lpstrFile = fileName;
FileDialogInfo.nMaxFile = sizeof(fileName);
FileDialogInfo.Flags = OFN_PATHMUSTEXIST |
OFN_OVERWRITEPROMPT;

GetSaveFileName(&FileDialogInfo);
}

return 0;
}



and here is how i have to use it to make it crash:

1. create an arbitrary file (text or binary; content doesn't matter) and name
it 'name.dat'. two things are important here: give it the .dat extension and
save it on your desktop!

2. start the compiled program

3. now browse to your desktop when the first save file dialog appears

4. point your mousepointer over the created .dat file in the save file dialog,
so that it fades in an info box with information about type, last change and
size of that file.

5. now do what ever you want, to bring up the second dialog. at best click
cancel.

6. repeat step 3 and 4. when the info box is about to fade in again the
program crashes.



that's it. i know it sounds strange, but it crashes on my computer. i use
windows xp pro sp2. is there something wrong with my code? if it doesn't crash
on your computer, what os do you use?


thanks in advance
fred
.



Relevant Pages

  • Re: VBA and VSTO
    ... excel crashes if a file is not compiled. ... makes the compilation invalid (I can see it since the compile item ... VBA (the event-cycle must stay in VBA I guess, so I would like to call ...
    (microsoft.public.excel.programming)
  • Re: VBA and VSTO
    ... (but the opposite is not true: compiled on XP crashes on 2000). ... Have you got the add-in working now in all Excel versions? ... VBA (the event-cycle must stay in VBA I guess, ... compile is black, not greyed out, saying my project is not ...
    (microsoft.public.excel.programming)
  • Re: VBA and VSTO
    ... both .xla files were still enormously bloated. ... I would still investigate why exactly it crashes on 2000 when compiled in XP and if you send the .xla file ... Have you got the add-in working now in all Excel versions? ... I think the main thing is to be able to compile the project with Option Explicit in each and every module. ...
    (microsoft.public.excel.programming)
  • Re: VBA and VSTO
    ... variable-types vs. excel objects confusion). ... I stay with VBA. ... I would still investigate why exactly it crashes on 2000 when compiled ... compile is black, not greyed out, saying my project is not ...
    (microsoft.public.excel.programming)
  • Re: VBA and VSTO
    ... I reduced the .xla file from a bit over 5Mb to 2.5 Mb. ... then you definitely need better security than Excel can offer! ... I would still investigate why exactly it crashes on 2000 when compiled in XP and if you send the .xla file ... I think the main thing is to be able to compile the project with Option Explicit in each and every module. ...
    (microsoft.public.excel.programming)