Re: Error Using ShellExecute
From: Drebin (thedrebin_at_hotmail.com)
Date: 09/17/04
- Previous message: John Giblin: "Re: Error Using ShellExecute"
- In reply to: John Giblin: "Re: Error Using ShellExecute"
- Next in thread: John Giblin: "Re: Error Using ShellExecute"
- Reply: John Giblin: "Re: Error Using ShellExecute"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Sep 2004 17:47:47 GMT
Yeah, my bad... that's because it sends that to the shell, which in turns
kicks off iexplorer.exe - which is a different process.. you CAN do this
though:
System.Diagnostics.Process objProc = new System.Diagnostics.Process();
objProc.StartInfo.FileName = "notepad.exe";
objProc.Start();
MessageBox.Show(objProc.MainWindowTitle);
So, if you want to instantiate iexpore.exe manually, then this should work??
HTH and sorry for the confusion
"John Giblin" <jwgiblin3@hotmail.com> wrote in message
news:3d6785ec.0409170923.7e625ca0@posting.google.com...
> Thanks. That is exaclty what I wanted to do.
>
> The only thing now is that the objProc is returns null
>
> I want to be able to use that object. Thanks
>
> John
>
>
> "Drebin" <thedrebin@hotmail.com> wrote in message
news:<8In2d.3099$Qv5.1401@newssvr33.news.prodigy.com>...
> > I don't think I understand what it is you want to do, but did you know
you
> > could do this:
> > System.Diagnostics.Process objProc =
> > System.Diagnostics.Process.Start("http://www.yahoo.com/");
> >
> > That tells the OS to "run" that, it knows it's a URL and opens the
default
> > browser.. plus now, you have a handle (objProc) to the process. Nice and
> > clean, no unmanaged code or pointers.. HTH
> >
> >
> >
> >
> >
> > "John Giblin" <jwgiblin3@hotmail.com> wrote in message
> > news:3d6785ec.0409161313.2b12c6e9@posting.google.com...
> >
> > >I get the following error when I use the code listed below:
> > > An unhandled exception of type 'System.Security.SecurityException'
> > > occurred in TestsCSharpApp.exe
> > >
> > > Additional information: System.Security.Permissions.SecurityPermission
> > >
> > >
> > > I am not sure I am heading in the right direction, but what I am
> > > trying to do is open IE, navigate to a page, when that page has load
> > > and the session is created, to login to another page to create the
> > > session for the user. I was able to do this in javascript, but I had 2
> > > problems. One is that I was prompted if I wanted to execute active
> > > script. The Other is when I use the window.close() to the initiating
> > > page, I was prompted whether I wanted to close this window.
> > >
> > > Any Advice would be appreciated. Thanks
> > >
> > > Code:
> > > =====
> > > public void RunExec()
> > > {
> > >
> > > // Set default values
> > > OwnerHandle = IntPtr.Zero;
> > > Verb = "IExpore.exe";
> > > Path = "http://www.yahoo.com";
> > > Parameters = "";
> > > WorkingFolder = "";
> > > ShowMode = ShowWindowCommands.SW_MAXIMIZE;
> > > Execute();
> > > }
> > >
> > > public bool Execute()
> > > {
> > > int iRetVal;
> > > iRetVal = (int)ShellExecute(
> > > OwnerHandle,
> > > Verb,
> > > Path,
> > > Parameters,
> > > WorkingFolder,
> > > (int)ShowMode);
> > >
> > > return (iRetVal > 32) ? true : false;
> > > }
> > >
> > > // Performs an operation on a specified file.
> > > [DllImport("shell32.dll")]
> > > public static extern IntPtr ShellExecute(
> > > IntPtr hwnd, // Handle to a parent window.
> > > [MarshalAs(UnmanagedType.LPStr)]
> > > String lpOperation, // Pointer to a null-terminated string,
> > > referred to in this case as a verb,
> > > // that specifies the action to be performed.
> > > [MarshalAs(UnmanagedType.LPStr)]
> > > String lpFile, // Pointer to a null-terminated string that
> > > specifies the file or object on which
> > > // to execute the specified verb.
> > > [MarshalAs(UnmanagedType.LPStr)]
> > > String lpParameters, // If the lpFile parameter specifies an
> > > executable file, lpParameters is a pointer
> > > // to a null-terminated string that specifies the parameters to be
> > > passed
> > > // to the application.
> > > [MarshalAs(UnmanagedType.LPStr)]
> > > String lpDirectory, // Pointer to a null-terminated string that
> > > specifies the default directory.
> > > Int32 nShowCmd); // Flags that specify how an application is to be
> > > displayed when it is opened.
- Previous message: John Giblin: "Re: Error Using ShellExecute"
- In reply to: John Giblin: "Re: Error Using ShellExecute"
- Next in thread: John Giblin: "Re: Error Using ShellExecute"
- Reply: John Giblin: "Re: Error Using ShellExecute"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|