By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

how to start a new process

P: 52
how to start a new process (for example opening a notepad)
from a c++ program??
i tried the following code but it gives error
fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option

Expand|Select|Wrap|Line Numbers
  1. #using <mscorlib.dll>
  2. #using <system.dll>
  3. #using <System.Windows.Forms.dll>
  4. int main(){
  5. //Use no more than one assignment when you test this code. 
  6.    //System::String * target= "http://www.microsoft.com";
  7.    //System::String * target = "ftp://ftp.microsoft.com";
  8.    System::String * target = "C:\\Program Files\\Microsoft Visual Studio\\INSTALL.HTM"; 
  9.    try
  10.    {
  11.       System::Diagnostics::Process::Start(target);
  12.    }
  13.    catch (System::ComponentModel::Win32Exception * noBrowser) 
  14.    {
  15.       if (noBrowser->ErrorCode==-2147467259)
  16.          System::Windows::Forms::MessageBox::Show(noBrowser->Message);
  17.    }
  18.    catch (System::Exception * other)
  19.    {
  20.       System::Windows::Forms::MessageBox::Show(other->Message);
  21.    } 
  22. return 0;
  23.  
Jun 20 '07 #1
Share this Question
Share on Google+
2 Replies


P: 15
I don't know if it is suitable for VC++ .NET program, but you may use system() from stdlib. Maybe even Win32 CreateProcess can do.



how to start a new process (for example opening a notepad)
from a c++ program??
i tried the following code but it gives error
fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option

Expand|Select|Wrap|Line Numbers
  1. #using <mscorlib.dll>
  2. #using <system.dll>
  3. #using <System.Windows.Forms.dll>
  4. int main(){
  5. //Use no more than one assignment when you test this code. 
  6.    //System::String * target= "http://www.microsoft.com";
  7.    //System::String * target = "ftp://ftp.microsoft.com";
  8.    System::String * target = "C:\\Program Files\\Microsoft Visual Studio\\INSTALL.HTM"; 
  9.    try
  10.    {
  11.       System::Diagnostics::Process::Start(target);
  12.    }
  13.    catch (System::ComponentModel::Win32Exception * noBrowser) 
  14.    {
  15.       if (noBrowser->ErrorCode==-2147467259)
  16.          System::Windows::Forms::MessageBox::Show(noBrowser->Message);
  17.    }
  18.    catch (System::Exception * other)
  19.    {
  20.       System::Windows::Forms::MessageBox::Show(other->Message);
  21.    } 
  22. return 0;
  23.  
Jun 20 '07 #2

P: 52
i got it on my own..thnks
Jun 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.