|
Use the static Process.Start methods to launch your slave application. You will need the path of the executable and can optionally specify arguments which will be passed to your application.
Both overloads of the Start method return a object of the Process class. Store it and call the Kill method of this instance when you want to shut down your slave application.
For passing of information between applications, there exist several ways. You could use a socket connection, Remoting or just send Windows messages. It depends on what you want to send, if the communication should be uni- or bidirectional and some other facts.
www.troschuetz.de
|
|
|
|
|
Calling Process.Kill like Stefan said is an option, but it's not a very good one. This terminates the process and leaves the OS to free handles. If you need your process to close these yourself for any reason, use Process.CloseMainWindow then Process.Close . See the method documentation for Process.Close for an example.
To communicate between the two applications, you should consider using .NET Remoting with a TcpChannel if they are both .NET applications. This is by far the easiest way for communications, despite the overhead of TCP (in .NET 2.0, they are adding an IpcChannel ). If they aren't, then there's a myriad of ways to do this from using RPC (you'll have to P/Invoke the necessary APIs in your .NET application) to global memory to shared pipes, etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
THX for the correction considering the Process.Kill method. I will remember that
www.troschuetz.de
|
|
|
|
|
I'd like to start a help-project in my VS.Net. The VS-Help states, that I have to start a new project an then follow the instructions of the New Project Wizzard.
But if I do so, there is no New Project Wizzart. How get I back to this wizzard?
Thanks
Ariadne
|
|
|
|
|
Just click on the File menu and select New->Project. There's your "wizard". From there you can create different project types. Some have wizards and some are just templates. In order for a Help project to show up, you need to download the VSHIK from http://msdn.microsoft.com/downloads[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Stewart!
but if I try to install VSHIK.exe I get
Visual Studio .NET must be installed to run this insallation package
But VS.NET is installed...
Did I something wrong?
|
|
|
|
|
Check the system requirements for the VSHIK. There are two different versions of Visual Studio .NET, mind you (2002 and 2003). If the VSHIK uses Windows Installer (IIRC, it does), you can create a transform (if you know how) that will install it for the other version of Visual Studio .NET. In most cases, this should work just fine.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks: it works
Ariadne
|
|
|
|
|
can anybody show me how to add checkboxes to DataGrid and how to know the items that is checked.
Rock Throught The Night
|
|
|
|
|
|
I have a class i made that is derived from a label. I was wondering how in the heck do you disable word wrap? I tried this.AutoSize=false; but that doesn't seem to effect anything.
I was looking for something like WordWrap but i don't see anything like. Is there a function i can call to dispable this? Cause what happens is the text on my label is sometimes longer than the label and instead of cutting it off it just makes the label height bigger so it can accomidate the length. Basically word wrapping it.
Thanks for the help
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
As usual, the solution comes down to the underlying Windows common control - the Static Control[^]. You can disable word wrap using the SS_LEFTNOWORDWRAP (0x000c) style. Tie it to a property like so:
public class MyLabel : Label
{
private bool wordWrap = true;
private const int SS_LEFTNOWORDWRAP = 0x000c;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
if (!wordWrap) cp.ClassStyle |= SS_LEFTNOWORDWRAP;
return cp;
}
}
[DefaultValue(true)]
public bool WordWrap
{
get { return wordWrap; }
set
{
if (wordWrap != value)
{
wordWrap = value;
RecreateHandle();
}
}
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I want to add my own functionality (Some Menu Item) to VC6.0 IDE. Can we do that ?? If yes, how to do that? If anybody got some clue, just advise.
Thanks and Regards,
Satya.
Never never never give up.
|
|
|
|
|
SatyaDY wrote:
If anybody got some clue
First CLUE: Post in the correct forum
SatyaDY wrote:
just advise
Advice: Post in the correct forum
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
1. how i will know which version of .net framework that is there in my machine.
2. how i will locate through programming.
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
sreejith ss nair wrote:
1. how i will know which version of .net framework that is there in my machine.
There's no excuse to not know what software is on your computer, unless network administrators are pushing out installations. Never blindly install anything on your machine. This is true for any machine and for any application.
You can figure it out many ways. The easiest is to browse to %WINDIR%\Microsoft.NET\Framework. The sub-directories in there will tell, so long as their full of files (newer frameworks install a few files into older directories, but it's noticably fewer files). v1.0.3705 corresponds to the .NET Framework 1.0. v1.1.4322 corresponds to the .NET Framework 1.1. You can also just open Add/Remove Programs from the Control Panel and look as well.
Programmatically, it's really quite easy. Read about the Environment.Version property in the .NET Framework SDK. The Version.Major and Version.Minor numbers should correspond to the .NET Framework version that you're running under.
Note that the assembly versions don't reflect this. .NET 1.0's assemblies versions are 1.0.3300.0, while the SP2 file versions are 1.0.3300.228. The .NET 1.1 assemblies are version 1.0.5500.0. I don't know why, but that's the facts. I will tell that Microsoft does change the file versions to reflect the service pack changes, but the assembly version remains unchanged so that code targeting that .NET version doesn't need to be recompiled or redirected. File versions are for informational purposes where assembly versions describe both the assembly as well as a type within that assembly. Different versions mean different assemblies or types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
How do I create the IDataSourceLocator (hWnd) for my MSDASC.DataLinks object without first calling the PromptNew() method plus DialogResult.OK ??
I have a program where I want the user to be able to edit a connection string known (loaded) when the program starts. I want to be able to do something like this:
private ADODB._Connection m_AdoDbConn;
// then, create m_AdoDbConn without calling PromptNew() so I can do..
m_AdoDbConn.ConnectionString = sConnStrLoadedFromDisk;
object o = (object) m_AdoDbConn;
MSDASC.DataLinks oDlg = new MSDASC.DataLinksClass();
oDlg.PromptEdit(ref o);
---------------
TIA,
Matt
|
|
|
|
|
All you need is a valid connection string. I created an RCW from the MSDASC typelib and imported the PIA for ADODB (ADODB.dll). My sample code below worked fine (except that I changed the computer name in the ConnectionString ):
using System;
using ADODB;
using MSDASC;
public class EditDSN
{
static void Main()
{
ConnectionClass conn = new ConnectionClass();
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;"
+ "Data Source=MACHINE;Initial Catalog=master";
object o = conn;
DataLinksClass links = new DataLinksClass();
links.PromptEdit(ref o);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath, You are the man! Thank You.
|
|
|
|
|
Does anyone know how to control scrolling programactically, e.g. scroll to the very end of the form?
Thanks!
|
|
|
|
|
P/Invoke SendMessage and send either the WM_HSCROLL (0x0114) or the WM_VSCROLL (0x0115) messages to the control handle (see the Control.Handle property in the .NET Framework SDK).
This has been covered many times here in the C# forum in the past, so I direct you to a previous response and urge you to try searching for answers first by clicking "Search comments" above the message board, or search the articles using the search textbox underneat the CodeProject logo.
See http://www.codeproject.com/script/comments/forums.asp?msg=719589&forumid=1649#xx719589xx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am developing a NotifyIcon app with C#. I want to show the context menu
when user left-clicks on the icon, the same as he/she right-clicks on it. In
that event handler, myNotifyIcon_Click(), I call
myNotifyIcon.ContextMenu.Show method. But I am not sure what these two
parameters I should feed.
Thanks in advance.
David
|
|
|
|
|
There are many ways of doing this. The NotifyIcon component encapsulates the Shell_NotifyIcon functions and context menu-related functions like TrackPopupMenuEx . While you could simply P/Invoke the latter API as well as a few others, the easiest way would be to use Reflection to invoke the method that already does all this for you:
MethodInfo method = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null) method.Invoke(notifyIcon1, null); If you want to know how that method works, use the IL Disassembler (ildasm.exe) that ships with the .NET Framework SDK if you know how to read Intermediate Language (IL), or a good decompiler like .NET Reflector[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please read the code snippets below
snippet 1: Drawing rectangle using Device Context
-------------------------------------------------------------[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool Rectangle(
IntPtr hdc,
int ulCornerX, int ulCornerY,
int lrCornerX, int lrCornerY);
public void GetHdcForGDI(PaintEventArgs e)
{
// Create pen.
Pen redPen = new Pen(Color.Red, 1);
// Draw rectangle with GDI+.
e.Graphics.DrawRectangle(redPen, 10, 10, 100, 50);
// Get handle to device context.
IntPtr hdc = new IntPtr();
hdc = e.Graphics.GetHdc();
// Draw rectangle with GDI using default pen.
Rectangle(hdc, 10, 70, 110, 120);
// Release handle to device context.
e.Graphics.ReleaseHdc(hdc);
}
-------------------------------------------------------------
snippet 2: Drawing rectangle using PrintPageEvntArgs
-------------------------------------------------------------
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Pen redPen = new Pen(Color.Red, 1);
e.Graphics.DrawRectangle(redPen, 100, 100, 100, 100);
}
-------------------------------------------------------------
Please explain what is difference between drawing rectangle using Device Context and PrintPageEvntArgs in terms of the concept and merits
regards
|
|
|
|
|
A device context can be practically any output device, from a monitor to a printer to a virtual screen buffer. You actually have to set up a device context (or get it from an existing source) and translate all the units if necessary. It also requires marshaling to a P/Invoke'd function.
Painting to a printer using the .NET FCL printing capabilities handle everything for you and should be used. Besides, look at what you had to do to draw a simple rectangle using the HDC compared to the Graphics object (which is actually a GDI+ object, where an HDC is used most often for GDI).
If you want to learn more, read about the HDC and GDI functions in the Platform SDK and compare that with the graphics information in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|