MFC, Open File dialog and shellExecute for regsvr32


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Browse for OCX and then execute Regsvr32
  2.  
  3. // http://www.functionx.com/visualc/controls/filedialog.htm
  4. CFileDialog fileDlg(
  5. true, // open
  6. NULL,
  7. NULL,
  8. OFN_FILEMUSTEXIST,
  9. "OCX Files (*.ocx)|*.ocx|All Files (*.*)|*.*||",
  10. this );
  11.  
  12. bool bOk = fileDlg.DoModal() == IDOK ;
  13.  
  14. if ( bOk )
  15. {
  16. CString pathName = fileDlg.GetPathName();
  17.  
  18. ShellExecute( // WinExec is obsolete.
  19. this->m_hWnd, // hwnd
  20. "open", // operation/verb.
  21. "regsvr32.exe", // executable.
  22. pathName, // parameters.
  23. NULL, // directory
  24. SW_SHOW ); // how to be displayed
  25.  
  26. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.