我在我的应用程序里面需要代码注册控件 hh.ocx ,
我的应用程序是几于对话框做的,
我应该在哪儿注册?我该如何做?谢谢?我在初始化  ,以及PreCreate....里都不行?????????

解决方案 »

  1.   

    BOOL CYourApp::InitInstance()
    {
      ...
      if(ShellExecute(NULL,"OPEN","regsvr32.exe","/s hh.ocx",NULL,SW_SHOW)==0)
      {
        AfxMessageBox("注册失败!!!");
        return FALSE;
      }
      return TRUE;
    }
      

  2.   


    先 LoadLibrary("Your.dll"); 然后 GetProcAddress 得到 DllRegisterServer 函数的地址,然后执行。
      

  3.   

    BOOL CYourApp::InitInstance()
    {
      ...
      if(system("regsvr32.exe","/s hh.ocx"))
      {
        AfxMessageBox("注册失败!!!");
        return FALSE;
      }
      return TRUE;
    }