473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show the window of already started copy of process?

1 New Member
I try to do it in this way:
it is reaction on event OnLoad
Expand|Select|Wrap|Line Numbers
  1.             cpr = Process.GetCurrentProcess();
  2.             Process[] spr = Process.GetProcessesByName(cpr.ProcessName);
  3.             if(spr.Length==2)
  4.                 {
  5.                     int num=0;
  6.                     if (cpr.Id == spr[0].Id){ num=1; }
  7.                     else if (cpr.Id == spr[1].Id) { num = 0; }
  8.                     IntPtr wh = spr[num].MainWindowHandle;
  9.                     Control f = Form.FromChildHandle(wh);
  10.                     if(f!=null){ f.FindForm().Show();}
  11.                     cpr.Kill();
  12.                 }
  13.  
But I have problem in string
Expand|Select|Wrap|Line Numbers
  1. Control f = Form.FromChildHandle(wh);
  2.  
After this instruction in "f" there is "null", but there is form associated with process "spr[num]".
I don't understand, why this way doesn't work
Help me please
Mar 31 '07 #1
1 1262
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. What is the value of wh?
Apr 3 '07 #2

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

Similar topics

11
5074
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text. Spy++ gives that this window is called _Wwg. How we can get a handle to this window assuming that we do not know beforehand the name of the process,
8
11525
by: Mészáros Tamás | last post by:
Hi all, how can I set an app's main window to visible from an other application? My problem is, that I know only the handle of the other app's main process, because the application's main window is set to hidden, so it doesn't have a mainwindowHandle, so I can't send a message to it. Any idea? Thank's in advance,
0
1638
by: cvetomir.todorov | last post by:
We have an app which must be single instance. When we start the app we check if it is already running (using the Process object in the System.Diagnostics namespace) locating it by the name of the process. It is not the problem. When it is already running we have to maximize the already started application and bring it on top of other windows. When we find our process we get the main window handle from the Process object: IntPtr hWnd =...
6
8519
by: Marcus | last post by:
How do I do it in c#? My current solution works sometimes, but sometimes the form comes behind the fullscreen application. I am using the following in the forms constructor this.WindowState = FormWindowState.Normal; this.Focus(); this.BringToFront();
4
6395
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database to look a and I am loosing tremendious amounts of time trying to organize it so that I could view it. Regards, Alexandre Brisebois
6
5011
by: Jen | last post by:
I've implemented single-instance functionality in my .exe by using the mutex method. Works great. But when the .exe detects that it is not the first instance I want to bring the main window of the first instance to the foreground and set focus to it before the .exe exits. Is this possible using pure .NET calls or do I need Windows API calls and what are they?
3
7922
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory but the tray icon is not there. If I start the program after Windows has booted up the icon shows every time. I am assuming that the reason is due to the icon being created before the system tray is loaded/running. I have used a timer with...
3
2782
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window (not web-based or part of current application) brought to the front and focused (findwindow api) and have the button scrape the contents of the focused window so the contents can be parsed and entered into the web application. Ideally, I would...
20
3234
by: Alexey Kulentsov | last post by:
Hi all! Windows XP, Apache 2.2, PHP 5.2.5 as apache module (php5apache2_2.dll) I need to run background process and see output but for current moment all methods runs it as process not as application (visible in task manager but no window attached). I tried exec, ``, popen(), with and without start and psexec. Is here any way to run it as separate process, without waiting (psexec -d) and with visible window? Small example running...
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.