bug in windows getsavefilename api? - Programmer

This is a discussion on bug in windows getsavefilename api? - Programmer ; 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 int WINAPI WinMain(HINSTANCE hInstance, ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: bug in windows getsavefilename api?

  1. 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

    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

  2. Re: bug in windows getsavefilename api?

    In article , Lucian Wischik wrote:
    >RemoveThis_fredgillioz@web.de (Frederic Gillioz) wrote:
    >>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:

    >
    >Just to report, I too get a crash with vs.net 2005.
    >"Unhandled exception at 0x7ca514ae in fnb.exe: 0xC0000005: Access
    >violation reading location 0x00f24590."
    >
    >I think .dat files are registered with Windows Media Player. I wonder
    >if, when you hover the cursor over, the shell asks the registered DLL
    >to provide information that will go in the tooltip? so it might be a
    >bug in wmp rather than the shell?
    >


    i tried the same thing for .raw or whatever you want and it's always the same.
    but thanks for trying.

    fred

  3. Re: bug in windows getsavefilename api?

    hello,

    > Lucian Wischik schrieb:
    > ...
    > I think .dat files are registered with Windows Media Player. I wonder
    > if, when you hover the cursor over, the shell asks the registered DLL
    > to provide information that will go in the tooltip? so it might be a
    > bug in wmp rather than the shell?
    > ...


    by now i thought it would only happen with PDFs, but
    it seems mining the desktop 'works' with several filetypes
    and a lot of applications, just try notepads file-dialog
    or whatever you find...


    fred, try to call either CoInitialize() or OleInitialize()
    and their opponent-functions at start and end of your program
    to avoid theAT desktop-tooltip-issue.

    see 'Problems with GetOpenFileName and GetSaveFileName'
    http://groups.google.de/group/micros...d5638c2125150b



    hope it helps,

    carsten neubauer
    http://www.c14sw.de/
    http://www.edcomponents.com/


  4. Re: bug in windows getsavefilename api?

    In article <1130919409.908194.33820@g44g2000cwa.googlegroups.c om>, "Carsten Neubauer" wrote:
    >hello,
    >
    >> Lucian Wischik schrieb:
    >> ...
    >> I think .dat files are registered with Windows Media Player. I wonder
    >> if, when you hover the cursor over, the shell asks the registered DLL
    >> to provide information that will go in the tooltip? so it might be a
    >> bug in wmp rather than the shell?
    >> ...

    >
    >by now i thought it would only happen with PDFs, but
    >it seems mining the desktop 'works' with several filetypes
    >and a lot of applications, just try notepads file-dialog
    >or whatever you find...
    >


    yes, i tried it with notepad and it crashes too.

    >
    >fred, try to call either CoInitialize() or OleInitialize()
    >and their opponent-functions at start and end of your program
    >to avoid theAT desktop-tooltip-issue.
    >


    thanks, that did it.

    >see 'Problems with GetOpenFileName and GetSaveFileName'
    >http://groups.google.de/group/micros...i/browse_frm/t
    >hread/5fd5638c2125150b
    >
    >


    maybe i try googling next time first
    they mention there that it happens on systems with adobe reader 7. on both
    systems i tried, i had this version installed...

    >
    >hope it helps,
    >


    it did.

    >carsten neubauer
    >http://www.c14sw.de/
    >http://www.edcomponents.com/
    >



    fred

+ Reply to Thread