Strange behavior of SHFileOperation between my debug and release version

This is a discussion on Strange behavior of SHFileOperation between my debug and release version within the C++ Programming forums, part of the General Programming Boards category; here's a snippet of my code what i intented to do was to delete the whole directory "C:\WINDOWS\Desktop\Game", and then ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    Strange behavior of SHFileOperation between my debug and release version

    here's a snippet of my code
    what i intented to do was to delete the whole directory "C:\\WINDOWS\\Desktop\\Game", and then restore the directory from "C:\\backup\\game" so that my desktop "game" directory isnt too messy.
    Code:
    SHFILEOPSTRUCT file_struct;
    ZeroMemory(&file_struct, sizeof(file_struct));
    game_dir = "C:\\WINDOWS\\Desktop\\Game";
    game_dir_org =  "C:\\backup\\game" ;
    
    file_struct.wFunc = FO_DELETE;
    file_struct.pFrom = game_dir ; // deletes the "game" dir on  desktop
    int iz = SHFileOperation(&file_struct);
    file_struct.wFunc = FO_COPY;
    file_struct.pFrom = game_dir_org;
    file_struct.pTo = game_dir;
    SHFileOperation(&file_struct);
    ShellExecute(0,"open",game_dir,0,0,SW_SHOWMAXIMIZED);
    what happens is that the debug version deletes "C:\\WINDOWS\\Desktop\\Game" as it should while the release version does not.
    also, sometimes the release version deletes "C:\\backup\\game" while no problems with debug version
    what's wrong??

    using
    - win98se
    - vc++ 6.0
    - API style

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    How are game_dir and game_dir_org declared?

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Make sure you are double NULL terminating game_dir_org and game_dir as stated in the descriptions for the pFrom and pTo members of SHFILEOPSTRUCT (and as implied by Swoopy).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. debug release conf problem
    By fighter92 in forum Game Programming
    Replies: 6
    Last Post: 03-20-2009, 04:39 PM
  2. dumpbin with debug and release version
    By George2 in forum C Programming
    Replies: 5
    Last Post: 11-12-2007, 02:10 AM
  3. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 04:00 PM
  4. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  5. Why does this crash in release version but not debug?
    By Dual-Catfish in forum C++ Programming
    Replies: 1
    Last Post: 04-03-2002, 05:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21