调试vc++调试和编译都没错误,但是不能够执行程序
      点击执行的时候会提示程序遇到问题需要关闭,请问这是为什么?点击调试时
     调试vc++后出现unhandled exception in c.exe:0xc0000005:acess violation 消息框
     并Loaded symbols for 'D:\by\xin\zp\zp\25811255WmvReader_demo\WmvReader\Debug\WmvStream.exe'
Loaded 'C:\WINDOWS\system32\ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wmvcore.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wmasf.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winspool.drv', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comdlg32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kmon.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Rising\AntiSpyware\comx3.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Rising\AntiSpyware\Syslay.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wtsapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winsta.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\netapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\urlmon.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\apphelp.dll', no matching symbolic information found.
The thread 0x12F0 has exited with code 0 (0x0).
The thread 0x14E4 has exited with code -1073741819 (0xC0000005).
The program 'D:\by\xin\zp\zp\25811255WmvReader_demo\WmvReader\Debug\WmvStream.exe' has exited with code -1073741819 (0xC0000005).

解决方案 »

  1.   

    我调试和编译都通过了,怎么不能够执行呢?一按执行,就会弹出消息框说这个应用程序出现问题需要关闭呢?试了很多次还是同样的结果.于是点击了调试出现如下的消息框"error LNK2001: unresolved external symbol __endthreadex".点击确定发现有一个黄色的箭头指到如下程序段 
    if (!pThread->InitInstance()) 

    if (pThread->m_pMainWnd != NULL) 

    TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); 
    pThread->m_pMainWnd->DestroyWindow(); 

    nReturnCode = pThread->ExitInstance(); 
    goto InitFailure; 
    }
      

  2.   

    pThread
    m_pMainWnd
    这些都初始化了吗,运行到这时有效吗?
      

  3.   

    贴出C...App::InitInstance()里面的代码。
      

  4.   

    程序是运行成功了的,
    你是不是在界面上用了 ActiveX,在 InitInstance 里没有初始化OLE啊?
      

  5.   

    用DEPENDS看看,有可能是少了动态库。
    DEPENDS是vc自带的工具。
      

  6.   

    贴出代码,看看了。必然弹message因为你不会设断点,呵呵
      

  7.   

    可否帮俺调试一哈呢.?代码如下:
    // WmvReaderDlg.cpp : implementation file
    //#include "stdafx.h"
    #include "WmvReader.h"
    #include "WmvReaderDlg.h"
    #include ".\wmvreaderdlg.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    BITMAPINFO* _colorHeader;// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
    {
    public:
    CAboutDlg();// Dialog Data
    enum { IDD = IDD_ABOUTBOX }; protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support// Implementation
    protected:
    DECLARE_MESSAGE_MAP()
    };CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
    {}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    }BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    END_MESSAGE_MAP()
    // CWmvReaderDlg dialogCWmvReaderDlg::CWmvReaderDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CWmvReaderDlg::IDD, pParent)
    {
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_wmvVideoStream = NULL;
    }void CWmvReaderDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);}BEGIN_MESSAGE_MAP(CWmvReaderDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    //}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
    END_MESSAGE_MAP()
    // CWmvReaderDlg message handlersBOOL CWmvReaderDlg::OnInitDialog()
    {
    CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
    pSysMenu->AppendMenu(MF_SEPARATOR);
    pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
    } // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here
    return TRUE;  // return TRUE  unless you set the focus to a control
    }void CWmvReaderDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else
    {
    CDialog::OnSysCommand(nID, lParam);
    }
    }// If you add a minimize button to your dialog, you will need the code below
    //  to draw the icon.  For MFC applications using the document/view model,
    //  this is automatically done for you by the framework.void CWmvReaderDlg::OnPaint() 
    {
    if (IsIconic())
    {
    CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
    CDialog::OnPaint();
    }
    }// The system calls this function to obtain the cursor to display while the user drags
    //  the minimized window.
    HCURSOR CWmvReaderDlg::OnQueryDragIcon()
    {
    return static_cast<HCURSOR>(m_hIcon);
    }void CWmvReaderDlg::OnBnClickedButton1()
    {
    // TODO: Add your control notification handler code here
    CString filename = "file";
    CFileDialog fdd(TRUE,
    NULL,
    NULL, 
    OFN_ALLOWMULTISELECT | OFN_NODEREFERENCELINKS | OFN_EXPLORER,"Wmv File (*.wmv)|*.wmv;*.WMV||",NULL); if (fdd.DoModal() == IDOK)
    {

    filename = fdd.GetFileName();
    }
    if(filename== "file")
    return; m_wmvVideoStream = new CWmvStream(); unsigned char *pBuffer = NULL;
    m_wmvVideoStream->OpenStream(filename);
    BITMAPINFO meir;
    memcpy(&(meir.bmiHeader),&(m_wmvVideoStream->GetBitmapInfoHeader()),sizeof(BITMAPINFOHEADER));
    _colorHeader = (BITMAPINFO *) new char [ sizeof(BITMAPINFO)+256*4]; ;
    RGBQUAD* p = _colorHeader->bmiColors;
    for (int i = 0; i <= 255; i++) {
    p[i].rgbBlue = i; 
    p[i].rgbGreen = i; 
    p[i].rgbRed = i; 
    p[i].rgbReserved = 0;
    }
    _colorHeader->bmiHeader = m_wmvVideoStream->GetBitmapInfoHeader();
    int ret; while( m_wmvVideoStream->NextFrame() != 0)
    {

    pBuffer = m_wmvVideoStream->GetColorData();
    // CPaintDC dc(this);
    CDC* dc = GetDC();
    HDC hdc = dc->GetSafeHdc();
    ret = SetDIBitsToDevice(hdc,0,0,
    _colorHeader->bmiHeader.biWidth,
    _colorHeader->bmiHeader.biHeight,
    0,0,
    0,
    _colorHeader->bmiHeader.biHeight,pBuffer,_colorHeader,DIB_RGB_COLORS);
    } if(m_wmvVideoStream)
    {
    delete m_wmvVideoStream;
    m_wmvVideoStream = NULL;
    }
    }
      

  8.   

    路径问题,调试时候的路径跟你直接运行的路径不一样。
    你把调试时的路径改为$(TargetDir),这样就以.exe文件所在文件夹为当前目录来启动程序并调试了,如果这样调试运行都没有问题,你再去直接运行程序就应该没有什么问题了。