Thread: Exe crashes with Stack Dump

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Exe crashes with Stack Dump

    I have written a small prog that takes input from user via an input dialog then creates a folder and shows the folder in the C:
    drive. I have tested this on win 95/98 and ME with no probs. But when I tried to test on win 98SE which are also on NT network the prog crashes out performing a stack dump. Can anyone help me with this I am at a loss to see what is wrong. Thank you.

    Paul

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    How are we supposed to help you if you don't supply your program and/or sourcecode?
    // Gliptic

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Sorry

    Sorry thought there might have been some general probs dealing with Win98SE or NT, sourcecode is below. Thank you

    Paul

    #include <owl\applicat.h>
    #include <owl\framewin.h>
    #include <owl\inputdia.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <fstream.h>
    #include <iostream.h>
    #include <owl\window.rh>
    #include "userin.h"
    #include <windows.h>
    #include <owl/owlpch.h>
    #include <shellapi.h>
    #pragma argsused
    #include <owl\dialog.h>



    const MaxBuffer = 81;



    class TWinApp : public TApplication
    {
    EnableBWCC();
    EnableCtl3d();

    public:
    TWinApp() : TApplication() {}

    protected:
    virtual void InitMainWindow();
    };


    class TMainWindow : public TWindow
    {
    public:
    TMainWindow() : TWindow(0, 0, 0) {}

    protected:
    void CMFileInput();
    void CMHelpabout();



    virtual BOOL CanClose();

    DECLARE_RESPONSE_TABLE(TMainWindow);
    };
    DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow)
    EV_COMMAND(CM_FILEINPUT, CMFileInput),
    EV_COMMAND(CM_HELPABOUT, CMHelpabout),


    END_RESPONSE_TABLE;



    void TMainWindow::CMFileInput()
    {
    char s[MaxBuffer];
    char dir[128];
    strcpy(dir, "MD C:\\");
    strcpy(s, "User Name");
    TInputDialog* pDlg;


    pDlg = new TInputDialog(this, "Find User","Enter Name of User",
    s, sizeof(s));
    if (pDlg->Execute() == IDOK) {
    strcat(dir, s);
    ofstream a_file("C:\\example.bat", ios::trunc );
    a_file<<dir;
    a_file.close();

    int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR s, int i);
    {
    ShellExecute(
    GetDesktopWindow(),
    NULL,
    getenv("COMSPEC"),
    " /C example.bat",
    "c:\\",
    SW_HIDE);

    }
    HINSTANCE heh;
    heh = ShellExecute(NULL,"open", NULL, NULL, "C:\\" ,SW_SHOWNORMAL);


    }
    }

    void TMainWindow::CMHelpabout()
    {
    TDialog(this, IDD_ABOUT).Execute();
    }




    BOOL TMainWindow::CanClose()
    {
    return MessageBox("Want to close this Application",
    "Query", MB_YESNO | MB_ICONQUESTION) ==IDYES;
    }

    void TWinApp::InitMainWindow()
    {
    MainWindow = new TFrameWindow(0, "Enter Users Name",
    new TMainWindow, SW_MINIMIZE); //SW_SHOW

    MainWindow->AssignMenu(IDM_MENU);

    }
    int OwlMain(int /* argc */, char** /*argv[] */)
    {
    TWinApp app;
    return app.Run();
    }

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    void TMainWindow::CMFileInput() 
    { 
    char s[MaxBuffer]; 
    char dir[128]; 
    strcpy(dir, "MD C:\\"); 
    strcpy(s, "User Name"); 
    TInputDialog* pDlg; 
    
    
    pDlg = new TInputDialog(this, "Find User","Enter Name of User", 
    s, sizeof(s)); 
    if (pDlg->Execute() == IDOK) { 
    strcat(dir, s); 
    ofstream a_file("C:\\example.bat", ios::trunc ); 
    a_file<<dir; 
    a_file.close(); 
    
    int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR s, int i); 
    { 
    ShellExecute( 
    GetDesktopWindow(), 
    NULL, 
    getenv("COMSPEC"), 
    " /C example.bat", 
    "c:\\", 
    SW_HIDE); 
    
    } 
    HINSTANCE heh; 
    heh = ShellExecute(NULL,"open", NULL, NULL, "C:\\" ,SW_SHOWNORMAL); 
    
    
    } 
    }
    Why is your WinMain inside your TMainWindow::CMFileInput() function? Plus it has a semicolon after the declaration, which is odd. If it was me, I would remove these lines:
    int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR s, int i);
    {

    and one of the closing braces at the end of the function.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Smile

    Thanx I will try that

    Paul

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 02:56 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM