Utilizando Visual Studio.NET 2005
OlĂĄ pessoal, meu nome Ă© Mauricio Junior, estou disposto a mostrar como chamar programas do windows dentro de um programa Windows Forms como: calculadora, word, excel, windows explorer de uma maneira fĂĄcil e rĂĄpida.
Requisitos:
- Framework 2.0 instalado;
- Visual Studio.NET 2005;
- Linguagem C#.NET;
- Ter ou criar um programa do tipo Windows Forms
Na prĂĄtica
Bom para inĂcio de conversa, iremos utilizar o seguinte namespace System.Diagnostics.Process e o mĂ©todo Start para chamar qualquer tipo de programa de dentro do programa Windows Forms.
Segue algumas questÔes do método:
Starts a process resource and associates it with a Process component.
Overload List
Name |
Description |
Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component. Supported by the .NET Compact Framework. | |
Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new Process component. Supported by the .NET Compact Framework. | |
Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. | |
Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component. Supported by the .NET Compact Framework. | |
Starts a process resource by specifying the name of an application, a user name, a password and a domain and associates the resource with a new Process component. | |
Process.Start (String, String, String, SecureString, String) |
Starts a process resource by specifying the name of an application and a set of command-line arguments, a user name, password and domain and associates the resource with a new Process component. |
Na prĂłxima parte Ă© criar um botĂŁo para chamar diretamente a calculadora do windows. (ReferĂȘncia 1.1)
ReferĂȘncia: 1.1
Ao clicar duas vezes no botĂŁo, coloquei o seguinte cĂłdigo: (ReferĂȘncia 1.2)
private void toolStripButton5_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("calc"); } |
ReferĂȘncia: 1.2
Executei o sistema e apertei a tecla de atalho, automaticamente foi iniciado a calculadora do windows cujo apareceu na tela. (ReferĂȘncia 1.3)
ReferĂȘncia: 1.3
Para chamar outros programas como o word basta fazer da seguinte forma: (ReferĂȘncia 1.4)
private void toolStripButton5_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("winword"); } |
ReferĂȘncia: 1.4
Chamar o explorer: (ReferĂȘncia 1.5)
private void toolStripButton5_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("explorer"); } |
ReferĂȘncia: 1.5
Chamar o excel: (ReferĂȘncia 1.6)
private void toolStripButton5_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("excel"); } |
ReferĂȘncia: 1.6
E assim por diante. Espero ter ajudado qualquer dĂșvida, favor entrar em contato.
MaurĂcio Junior
E-mail: mauricio@ascompras.com
Site pessoal: www.mauriciojunior.org
Comunidade: www.aspneti.com