testing on writing to floppy

This is a discussion on testing on writing to floppy within the Windows Programming forums, part of the Platform Specific Boards category; The idea is as follows: I have a ConfirmDisk button on a dialog (in Visual C++). When you click the ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    10

    testing on writing to floppy

    The idea is as follows: I have a ConfirmDisk button on a dialog (in Visual C++). When you click the button, the handler calls a ConfirmDisk() function which is supposed to write some files within a directory structure to floppy. If the user has its floppy into the drive all its fine. If it doesn't the function is trying to write in vain so I want to display a MessageBox prompting the user for the floppy.
    Now, look at what I tried to do:

    static LPCTSTR getErrMessage(DWORD win_err)
    {
    static TCHAR errMessage[500] = {0};
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, win_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMessage, sizeof(errMessage) / sizeof(TCHAR), 0);
    return errMessage;
    }

    void ErrMsg(CException* pe)
    {
    MessageBox(NULL, getErrMessage(GetLastError()), _T("Error") , MB_OK | MB_ICONINFORMATION);
    }

    // these are global function

    Now, when I'm calling my ConfirmDisk() function within a class:

    try
    {
    ConfirmDisk();
    }
    catch (CException* pe)
    {
    ::ErrMsg(pe);
    pe->Delete();
    return;
    }

    The idea was as follow: get any possible error message from the system with 'FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM...'
    then display it with Win32 API MessageBox from within ErrMsg, then attemp to execute my ConfirmDisk() from within a try/catch block. However, it doesn't work because the execution blocks on ConfirmDisk() function. When you use the debugger, you can see that the yellow arrow stops at this function. No message box is displayed.

    Thank you for any suggestions,
    Mullah, Romania

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Use code tags: code tags notice
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Does the program actually exit, and does it give any error messages?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    10
    No, the program simply blocks and you have to stop it from the task manager.

    Mullah

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Can you post the code for the ConfirmDisk() function?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    10
    Sorry, can't access the hotmail server right now so that I can send it to you by e-mail. It's more than one function call.


    Mullah

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  2. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM
  3. testing on writing to floppy
    By Mulah in forum C Programming
    Replies: 1
    Last Post: 07-06-2003, 01:46 PM
  4. Writing directly to floppy.
    By someonenearHim in forum C Programming
    Replies: 2
    Last Post: 12-12-2001, 06:51 PM
  5. Writing directly to sectors on a floppy.
    By someonenearHim in forum C Programming
    Replies: 0
    Last Post: 12-12-2001, 01:44 AM

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