如何防止vc程序弹出"确定" "取消"对话框

解决方案 »

  1.   

    Hook MessageBox等相关函数,屏蔽其功能即可.
      

  2.   

    是这样的,我的程序有时会报错误。弹出一个对话框,上面有两个按钮,一个时“确定”一个时“取消”如果想退出程序点击“确定”,如果想调试点击“取消”。#include <WINDOWS.H>
    #include <LIST>
    #include <string>
    #include <IOSTREAM>
    using namespace std;
    int main(int argc, char* argv[])
    {
    SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
    char *p = NULL;
    *p = '1';      // pop up a dialog box ,how can i avoid this??
    printf("%s",p);
    return 0;
    }
    上面程序中我故意造了一个内存访问出错,现在我不想让客户看见那个对话框,请问怎么做??
    SetErrorMode行不行?
      

  3.   

    你的程序应该是资源引用出错,比如说引用了没有赋初值的NULL指针,你想让客户不看到那个“退出和调试”程序的对话框,解决你程序的问题是本质。
    你好好找找吧,程序肯定有BUG!
      

  4.   

    try{
      char *p = NULL;
    *p = '1';      // pop up a dialog box ,how can i avoid this??
    printf("%s",p);
    }catch(...){
      return 0;
    }
      

  5.   

    加一个ASSERT()   可以看起来也许好一点  查一下SEH的资料,这个好象的处理错误的,不懂
      

  6.   

    int main(int argc, char* argv[])
    {
    SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); char *p = NULL;
    __try{
    *p = '1'; 
    }__except(0, 1){
    //
    }// pop up a dialog box ,how can i avoid this??
    printf("%s",p);
    return 0;
    }