"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:OG**************@TK2MSFTNGP06.phx.gbl...
Since when has C# been C++?
That's a pretty stupid question. Where did you read that I or anyone else
said that it was?
You can do exactly what you said in 3 line of code in
C#/VB.NET because you can say (VB.NET code):
So what?
As Open is the default verb in 'notepad.exe %1' you don't need to declare
the ProcessStartInfo. Plus, you do not need to use ShellExecute either
because the process will start a new instance of notepad launching what
txt
file you passed to it
No kidding? The OP asked about the .Net framework equivalent of Win32's
ShellExecute(). I could have simply pointed him to the framework classes in
question and told him he needed to set the UseShellExecute flag. Instead I
gave him a copy of C# compilable code. Sorry I disappointed you.
I could have given him C++, but didn't for three reasons.
1) I don't like to post code I haven't compiled and didn't have the time
when I posted to open up the IDE and build a sample.
2) There are two managed variants of C++, and I don't know which one he is
using.
3) For small tasks that make use of the framework, the difference between C#
and C++ is little more than syntatctic sugar for competent developers.
That said, this is the C++/CLI equivalent of the C# I posted:
// Process.cpp : main project file.
#include "stdafx.h"
using namespace System;
using namespace System::Diagnostics;
int main(array<System::String ^^args)
{
Process ^p;
ProcessStartInfo ^pInfo;
pInfo = gcnew ProcessStartInfo();
pInfo->Verb = "open";
pInfo->FileName = "c:\\foo.txt";
pInfo->UseShellExecute = true;
p = Process::Start(pInfo);
}
Regards,
Will