473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how to start a new process

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
2 4677
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
i got it on my own..thnks
Jun 20 '07 #3

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

Similar topics

0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
6
by: Dmitri Shvetsov | last post by:
Hi, Can I start an external process from the Web Service? I'm using a code, compiler keeps silence, compiles ok and starts the project. When I trace in Debugger it doesn't start an external...
4
by: Yiu | last post by:
upgent help i want to start IE explorer using C# i try many code such as below: ProcessStartInfo startInfo = new ProcessStartInfo("IEXPLORE.EXE"); Process.Start(startInfo); or Process...
0
by: henning.friese | last post by:
Hello NG, I'm need to write some code which creates tiff files from various document types (doc, pdf, xls). I want to do this by ShellExecuting (via System.Diagnostics.Process) the doc-files...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.