473,664 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

increasing Excel process place in taskmanager hierarchy

Bob
Hi,
I have an application that uses a excel in conjuction with a third
party application. I create an excel instance in c# and mark it as
invisible. The third party application is programmed to interact with
excel and everything works fine as I monitor interactions with my
hidden excel sheet. The problem comes if a user opens another
instance of excel. Is there any way that I can use the process
classes or another means to increase my invisible excel's task-
manager priority to be above every other excel instance? Making my
Excel application visible and then invisible temporarily makes it most
recent one but it creates a flickering and is likely resource
intensive.

Thanks,
Bob
Sep 6 '08 #1
6 1651
I've never had need to try this, but
System.Diagnost ics.Process.Pri orityClass seems to be appropriate for this.
"Bob" <bs********@yah oo.comwrote in message
news:c2******** *************** ***********@w1g 2000prk.googleg roups.com...
Hi,
I have an application that uses a excel in conjuction with a third
party application. I create an excel instance in c# and mark it as
invisible. The third party application is programmed to interact with
excel and everything works fine as I monitor interactions with my
hidden excel sheet. The problem comes if a user opens another
instance of excel. Is there any way that I can use the process
classes or another means to increase my invisible excel's task-
manager priority to be above every other excel instance? Making my
Excel application visible and then invisible temporarily makes it most
recent one but it creates a flickering and is likely resource
intensive.

Thanks,
Bob
Sep 6 '08 #2
Bob
On Sep 6, 7:47*am, "Family Tree Mike"
<FamilyTreeM... @ThisOldHouse.c omwrote:
I've never had need to try this, but
System.Diagnost ics.Process.Pri orityClass seems to be appropriate for this..

"Bob" <bshumsk...@yah oo.comwrote in message

news:c2******** *************** ***********@w1g 2000prk.googleg roups.com...
Hi,
I have an application that uses a excel in conjuction with a third
party application. *I create an excel instance in c# and mark it as
invisible. *The third party application is programmed to interact with
excel *and everything works fine as I monitor interactions with my
hidden excel sheet. *The problem comes if a user opens another
instance of excel. *Is there any way that I can use the process
classes or another means to *increase my invisible excel's task-
manager priority to be above every other excel instance? Making my
Excel application visible and then invisible temporarily makes it most
recent one but it creates a flickering and is likely resource
intensive.
Thanks,
Bob
I don't think that is the right solution. It throws an exception when
I try to change the priority either in C# or manually in task
manager. More generally, I am not trying to increase the programs
processor priority (ie how fast it executes), but rather just make
sure it is the top excel instance in visibility. Does a process with
higher priority show higher in visibility?
Sep 6 '08 #3
That is a different question than you asked before in my opinion...

The solution will likely involve FindWindow,
http://www.pinvoke.net/default.aspx/user32.FindWindow, and
SetForegroundWi ndow,
http://www.pinvoke.net/default.aspx/...regroundWindow.

Now, the tricky part which I cannot answer, is how are you going to know
when to execute the code? I mean, that if you put in a timer and check if a
process of Excel exists, then you will be constantly moving Excel to the
front. This would be annoying as a user.

Then there is also the condition where there are more than one Excel
window...

"Bob" <bs********@yah oo.comwrote in message
news:22******** *************** ***********@n38 g2000prl.google groups.com...
I don't think that is the right solution. It throws an exception when
I try to change the priority either in C# or manually in task
manager. More generally, I am not trying to increase the programs
processor priority (ie how fast it executes), but rather just make
sure it is the top excel instance in visibility. Does a process with
higher priority show higher in visibility?

Sep 6 '08 #4
Bob

Thanks for your response, sorry if my question was unclear. Is this
the correct way to implement your suggestion, I am not used to
PInvoke. If it is correct, it doesn't seem to work.

[DllImport("user 32.dll")]
[return: MarshalAs(Unman agedType.Bool)]
static extern bool SetForegroundWi ndow(IntPtr hWnd);

void b1_Click(object sender, EventArgs e)
{


Process[] allProcesses=Pr ocess.GetProces ses();
for (int i = 0; i < allProcesses.Le ngth; i++)
{
if (allProcesses[i].ProcessName.Co ntains("EXCEL") ){
excelHndl=allPr ocesses[i].Handle;
excelProc = allProcesses[i];
}
}

SetForegroundWi ndow(excelHndl) ;
}
Thanks Again,
Bob
Sep 7 '08 #5
Close... This line:

excelHndl=allPr ocesses[i].Handle;

should be:

excelHndl=allPr ocesses[i].MainWindowHand le;

"Bob" <bs********@yah oo.comwrote in message
news:8c******** *************** ***********@b30 g2000prf.google groups.com...
>
Thanks for your response, sorry if my question was unclear. Is this
the correct way to implement your suggestion, I am not used to
PInvoke. If it is correct, it doesn't seem to work.

[DllImport("user 32.dll")]
[return: MarshalAs(Unman agedType.Bool)]
static extern bool SetForegroundWi ndow(IntPtr hWnd);

void b1_Click(object sender, EventArgs e)
{


Process[] allProcesses=Pr ocess.GetProces ses();
for (int i = 0; i < allProcesses.Le ngth; i++)
{
if (allProcesses[i].ProcessName.Co ntains("EXCEL") ){
excelHndl=allPr ocesses[i].Handle;
excelProc = allProcesses[i];
}
}

SetForegroundWi ndow(excelHndl) ;
}
Thanks Again,
Bob
Sep 7 '08 #6
Bob
On Sep 6, 9:41*pm, "Family Tree Mike"
<FamilyTreeM... @ThisOldHouse.c omwrote:
Close... *This line:

* excelHndl=allPr ocesses[i].Handle;

should be:

* excelHndl=allPr ocesses[i].MainWindowHand le;

"Bob" <bshumsk...@yah oo.comwrote in message

news:8c******** *************** ***********@b30 g2000prf.google groups.com...
Thanks for your response, sorry if my question was unclear. Is this
the correct way to implement your suggestion, I am not used to
PInvoke. *If it is correct, it doesn't seem to work.
*[DllImport("user 32.dll")]
* * * [return: MarshalAs(Unman agedType.Bool)]
* * * static extern bool SetForegroundWi ndow(IntPtr hWnd);
* * * void b1_Click(object sender, EventArgs e)
* * * {
* * * * * Process[] allProcesses=Pr ocess.GetProces ses();
* * * * * * for (int i = 0; i < allProcesses.Le ngth; i++)
* * * * * {
* * * * * *if * (allProcesses[i].ProcessName.Co ntains("EXCEL") ){
* * * * * * * * * excelHndl=allPr ocesses[i].Handle;
* * * * * * * * * excelProc = allProcesses[i];
* * * * * * * }
* * * * * }
* * * * * SetForegroundWi ndow(excelHndl) ;
}
Thanks Again,
Bob
Beautiful, thanks! This seems to work fine as long as I initialize the
excel instance to be visible, get the main window handle then, and
then make it invisible.
Sep 7 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10692
by: Sri | last post by:
I am writing an asp.net applicaition using VB coding. In a function, I am opening an excel file with the following code, Dim objExcel As Object Dim objWorkBook As Object objExcel = CreateObject("Excel.Application") objWorkBook = objExcel.Workbooks.Open(targetfilename) * targetfilename is a variable that stores the excel file name and path. In the error handler,
10
5580
by: Mark Day | last post by:
Hi All, I am using Access 2000 to generate over 40 Excel charts and pivot tables using early binding to the Excel 9.0 object library. I am finding that if I show the Excel object while processing the charts, the whole process completes in around 2 minutes. However if I hide the Excel object the same process takes around 27 minutes to complete. I have played around with screen updating and this makes no real difference to the time. Does...
10
14417
by: Sorin Dolha [MCSD .NET] | last post by:
I would like to start a process from C# code as another user. The C# code is executed as the ASPNET user because it relies in a Web Page class, and I would like that the process will run as another user to gain the required rights for execution (the external process needs to create a mailbox in Exchange, so it needs to be run as an Exchange Full Administrator-powered user). For the moment, I have tries using the Start() static method of the...
3
3325
by: hari krishna | last post by:
hi, I am generating excel reports through vb.Net. After creating excel.application and the report is generated, each report leaves Excel in memory. I can see them in task manager in Process tab (as EXCEL). So the memory has been taken by excel objects and memory is being full. i want to delete or kill this objects which are in memory. i wrote the code as 'myexcel.quit()' , myexcel=nothing. but still it is in memory. pls tell me how to...
2
2293
by: Larry Jones | last post by:
I want to place information from an active Excel spreadsheet to a VB.net form. I just want to place numbers from an Excel cell in a standard VB.net text box. Does anyone have sample code to demonstrate this process? I have tried coding the process myself without success. I have just purchased a 2003 version of VB.net and I am not sure if it is me or changes in the program. I would like a working example to check my setup. Thanks,
1
1841
by: Dwight | last post by:
The place I'm working for has a need to sort an excel spread sheet the contains data from bill of materials. The spreadsheets can be up to 60,000 records. We had a process that did it in a macro but didn't do it correctly. Another developer wrote a program in VB.net and did a recursive hieartical sort. This worked fine for small files, but large files it took over an hour. The sorting is based on different criteia for each record type...
1
1939
by: myname | last post by:
Hello, in VB.Net, I use Excel to display results : dim xl as new Excel.Application // creates an Excel process // snip (putting values into cells) xl.Visible = true If the user closes the Excel file, the Excel process remains in memory until my program is closed, which is good.
2
2524
by: B.N.Prabhu | last post by:
In my web application(C#) . I am adding one excel sheet and then save and closing that excel file. In the finally bloack i gave Marshal.ReleaseComObject(clsExcel); But when i go and see in the TaskManager --Processes Tab its still having that Excel.exe. If i opened more than one excel sheet and do these operations then more than one Excel.exe is displaying in the list. Please any one give me the solution for this issue.
4
5733
by: spirit | last post by:
Hi, I have C++ code to write data to a .csv file thereby resulting in an excel spreadsheet. I was just wondering whether it wud be possible for us to further manipulate the csv file like for example filling a cell with a particular color etc...with C++ code? Thanks fr your suggestions and help,
0
8437
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
8348
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
8861
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
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
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
4185
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...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
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.