Thread: ShellExecute Problem

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    47

    ShellExecute Problem

    Hi guys, I'm wondering if anyone can help me with a ShellExecute() problem.... I've alredy looked in a bunch of other Threads and still didn't got what I'm looking for....
    Basicly, my program asks for a input and a output file, copys a bunch of stuff from the input file to the output file and opens the output file in Notepad.
    The copy from the input file to the output file is working OK, but when I try to open the output file with ShellExecute, I get an empty file, although that if I try to open it trhu notepad i see the file is not empty......

    Below the code I'm using

    void CANSIDecoderDlg::OnSelectOutput()
    {
    CFileDialog m_ldFile(TRUE);
    if (m_ldFile.DoModal() == IDOK)
    {
    m_Destination_File = m_ldFile.GetPathName();
    UpdateData(FALSE);
    }
    }


    void CANSIDecoderDlg::OnDecode()
    {
    .
    .
    .


    if( (Buffer =fopen(m_Destination_File, "w" )) == NULL )
    MessageBox("Destination File Not Found");

    else
    {
    .
    .
    .

    write a bunch of stuff in destination file
    .
    .
    .

    }

    UpdateData(FALSE);
    ShellExecute(NULL,
    "open",
    m_Destination_File,
    NULL,
    NULL,
    SW_SHOWNORMAL);

    }



    I'm a person with a simple taste...
    I only like the best.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    1. Please choose the windows forum when you post windows specific API questions
    2. Please use code tags to ensure your code is nicely formatted
    3. Did you close the file before trying to open it in notepad?
    4. Does the extension (eg. .txt) match one of the ones notepad is bound to?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    47
    Yes.... I forgot to close the file..... sorry for that... and thanks a lot... it's incredible how simple mistakes make you loose so much time...
    Once again.... thanks..
    I'm a person with a simple taste...
    I only like the best.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM