Does ShellExecute run in separate thread?

How can I wait for ShellExecute command. I believe that it spawns a thread.
Is there any way to synchronize that?

rgds
subhash


1
11/7/2003 1:32:55 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
690 Views

Similar Articles

[PageSpeed] 28

    Use ShellExecuteEx() or CreateProcess() { +WaitForSingleObject() } if
you want to wait on the process that it runs.

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

"Subhash Badri" <subhash.badri@in.bosch.com> wrote in message
news:bog6ug$9qv$1@ns2.fe.internet.bosch.com...
> How can I wait for ShellExecute command. I believe that it spawns a
thread.
> Is there any way to synchronize that?
>
> rgds
> subhash
>
>


1
CheckAbdoul
11/7/2003 2:13:12 PM
My own preference is to put that WaitForSingleObject in a separate thread, which leaves
the GUI alive while the process runs. For example

/* static */ UINT CMyView::WaitForProcess(LPVOID p)
    {
      MyProcessInfo * info = (MyProcessInfo *)p;
      ::WaitForSingleObject(info->process, INFINITE);
      info->wnd->PostMessage(UWM_PROCESS_FINISHED, (WPARAM)info->process);
      delete info;
     }

class MyProcessInfo { 
     public:
         MyProcessInfo(CWnd * w, HANDLE h) { wnd = w; process = h; }
         CWnd * wnd;
         HANDLE process;
};

ShellExecuteEx(&shellinfo);
MyProcessInfo * info = new ProcessInfo(this, shellinfo.hProcess);
AfxBeginThread(WaitForProcess, info);
ProcessRunning = TRUE;

ON_[REGISTERED_]MESSAGE(UWM_PROCESS_FINISHED, OnProcessFinished)

LRESULT CMView::OnProcessFinished(WPARAM, LPARAM)
   {
    ProcessRunning = TRUE;
    return 0;
   } 

// For those menu items you want to disable while the process is running, e.g.,
// the RunProcess menu item (whatever you call it)
void CMyView::OnUpdateRunProcess(CCmdUI * pCmdUI)
    {
     pCmdUI->Enable(!ProcessRunning);
    }

On Fri, 7 Nov 2003 09:13:12 -0500, "CheckAbdoul" <checkabdoul at mvps dot org> wrote:

>    Use ShellExecuteEx() or CreateProcess() { +WaitForSingleObject() } if
>you want to wait on the process that it runs.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
1
newcomer (15975)
11/7/2003 5:46:22 PM
Reply:

Similar Artilces:

Windows Mail running at startup
Should I expect to see the Windows Mail process running&nbsp;when the system first powers up (i.e. before I&nbsp;try to open up&nbsp;email) ? Does this suggest a problem ?&nbsp; I am just wondering, as&nbsp;I have&nbsp;other problems with Windows Mail. Post Originated from http://www.VistaForums.com Vista Support Forums There should not be any Windows Mail process running under those = conditions. Check your All Programs/Startup folder. If nothing there, open MSCONFIG=20 and look under its Startup tab and Processes tab. --=20 Gary VanderMolen, Microsoft MVP ...

Running code when hyperlink clicked
Hello, I am definitely baffled. I am trying to run code when a hyperlink is clicked. I am using Excel 2007, the hyperlink is created in a cell on Sheet 1 using "=hyperlink()", the hyperlink is to a video clip, and events are definitely enabled. I had tried two things, either of which would be fine: 1. I put the following code in Sheet1, and it did not respond at all. What am I doing wrong? Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Sheets("Sheet1").Range("B1") = "It Ran" End Sub 2. I put the following...

How do I create a running report on Excel
I am trying to create a running production census for a medical facility. I just need to know how to get the data to automaticly contine with the ongoing numbers. If your data starts in A2, put the following formula in B2 and copy it down your sheet. =A2+B1 HTH, Gary Brown "Michellle M" <MichellleM@discussions.microsoft.com> wrote in message news:47144A4B-A4A6-4B5B-B9E1-20BD06743793@microsoft.com... >I am trying to create a running production census for a medical facility. I > just need to know how to get the data to automaticly contine with the > ongoing >...

Microsoft Run Time Error Mesaages
Please can someone help me or point me in the right direction over an ongoing problem I have. Whilst using the Internet, I constantly get a Microsoft Message pop-up on the screen saying the "Run-Time" Error has expired. No matter whether you click on "OK" or the red cross box in the top left hand corner of the message box, the internet is immediately shut down and you have to reopen it to continue. This is most annoying when you are in the middle of a specific function on the internet. Can someone please tell me how to rectify this problem. ...

Anyone get a Silverlight application to run in the Status Screen
I cannot get it to work. The friendly message of "This program cannot display the webpage" always appears when I add the silverlight app to the page. I turned off friendly messages in IE but that does not seem to change the message presented by store operations. Thanks KB ...

Windows Installer runs every time I get a new email message
Hi: I am running XP and MS Office 2003. In Outlook, each time I get a new message, Windows Installer runs ("preparing to install"). So if I get 75 new messages, that message flashes 75 times. Any ideas on how to fix this? Thanks, Richard I am having the same problem and have not been able to find a solution. Did you have any luck yet? Thanks in advance for any help you can provide. Tim "Richard" wrote: > Hi: > > I am running XP and MS Office 2003. In Outlook, each time > I get a new message, Windows Installer runs ("preparing > to install&...

Cannot run Outlook
I am running windows XP Professional and have a BT Yahoo Broadband connection. I can operate Outlook express but cannot even open Outlook. It keeps telling me that my server is not available and jsut shuts down. I have used Outlook with Windows 2000 and the same broadband connection. Any suggestions? Have you tried the repair installation? David "Marshall-Dyckes" <anonymous@discussions.microsoft.com> wrote in message news:fd4201c3be2e$866d50f0$a601280a@phx.gbl... > I am running windows XP Professional and have a BT Yahoo > Broadband connection. I can operate Outloo...

Sort data separated by commas
Good day and thanks for reading. I am working on a file where a cell contains data separated by a comma. ex: Col A Col B Row 1 {Medium, Blue, hard } { 153 } Row 2 {Big, Red, soft } { 230 } Row 3 {Small, Pink, hard } { 50 } Row 5 {Big, Blue, soft } { 250 } Where { } are the limits of the cell What I am looking for is a way to sort Column A by the second value on each cell, ex: (Blue, Red, Pink) Any help is greatly appreciated. thanks What I would to is use the "text...

auto update xls document from separate file
What I want to do is have one separate xls file to use as a database, then when any changes are made to this file, have other files automatically update, without actually opening them and separatly adding the data. Is this possible? -- kaplonk ------------------------------------------------------------------------ kaplonk's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=9283 View this thread: http://www.excelforum.com/showthread.php?threadid=376235 kaplonk, No. You must open an Excel file to change it. You could have the change happen automatically when you...

Outlook runs in the background
When I get in Outlook to check e-mail and then get out of Outlook, I have to completely reboot the computer before I can get back in Outlook. When I am shutting down, I get a screen that more or less says that Outlook is running in the background (although it doesn't show when I do Ctrl-Alt-Del). We have reinstalled Outlook, but it still hasn't helped. In Task Manager, on the Processes tab, do you see any instances on Outlook.exe or MAPISP32.EXE when this happens? Usually, Outlook not gracefully closing is caused by PDA software such as ActiveSync, FAX software, or other pr...

Running rules on mailbox other than the default
I seem to remember someone on her saying that rules in Outlook won't run on anything other than the default mailbox. I'm curious to know why that is and if anyone has ideas on how to get around that. My situation is as follows...I'm running Outlook 2003 that connects through Microsoft Exchange Server (I don't know which version). I have 3 different mailbox folders that I can access in Outlook: My personal mailbox (all the mail that comes in addressed to me), a mailbox for security issues (all the mail that comes in addressed to the security email), and another one for...

Script running isinteg -test for all mailbox stores on a server
Hi, Does anybody have a script for: 1. dismounting information stores 2. running isinteg for information store - output to a logfile 3. mounting information store again This would be a nice feature to run once and a while to check that everything is ok! Kind rgds Peter Jensen On Tue, 16 Aug 2005 10:33:17 +0200, "Peter Jensen" <peter.topp@mail.dk> wrote: >Hi, > >Does anybody have a script for: > >1. dismounting information stores >2. running isinteg for information store - output to a logfile >3. mounting information store again > >This would...

Access 2003 code does not run in Access 2007
On my form, I have 2 unbound txt boxes, one named Search_Name and One named Search_Town. There is a command button named CmdSearch. On clicking the CmdSearch, the following code runs. In previous versions of access, it returns all records with names and/or towns that are entered in the text boxes and filters out records that do not match the search criteria. Why does this code not nork in Access 2007? Private Sub CmdSearch_Click() 'myfilter is the variable to be built that will be the filter string Dim myfilter As String 'like is in there to allow near matches, not exact matc...

VB6 service under Server 2008 can't run another VB application
I have a VB6 service that has been running for years on 2000 and 2003. I'm trying get it to work on Server 2008 and it's not working. The service calls shell to run another VB6 .exe program. This .exe program is not being called when the VB6 service program is run as a service. If I run the program as an application, it works like it should. Obviously, something in 2008 needs to be changed to allow this but I don't know what it would be. sr Steve Ricketts brought next idea : > I have a VB6 service that has been running for years on 2000 and 2003. I'm...

Run-time Error 7
Hi: Every time that I open Microsoft Excel 2002 (opening a blank spreadsheet), I get a Visual Basic dialog box that says "Run-Time Error 7". It does not seem to be a problem, really. I just press the "End" button in this VBA dialogue box and Excel opens just fine. It's more of a nuisance than a problem. Does anyone know how to get rid of this box so that it doesn't pop-up? Thanks! childofthe1980s Hi There's a poorly written addin residing either in Excel's startup folder (see Tools > Options for location) or installed (See Tools > Addin for...

Linking Separate Spreadsheets Together
Using Excel 2000, I have worksheet #1 with a product price list containing the following columns: - product ID - name - description - cost - price - taxable - active - product page url - image url I want to connect 3 additional worksheets (#2, #3 & #4) that will contain the same data but NOT in the same column order. My objective is to have the data in #2, #3 & #4 be automatically updated when any changes occur in worksheet #1. Your assistance is kindly appreciated. Hal. "H SELIM" <HSELIM@AOL.COM> wrote in news:ukU6dkW2DHA.1908 @TK2MSFTNGP10.phx.gbl: > I wa...

How to create a report with Frames running based on a linkage
Hi All, I want to build a SSRS report with two frames (or windows )in it. The way I want the report to work in on the left hand frame I will source data from a query to list products. When the user clicks on left hand frame on a product I want the right hand frame to list all sales for that product. I want to keep both the left and right frames to be visible. Please note the left frame is running a query creating a dataset something like this: SELECT ProductName From Products where region = p_region (the region is selected as a report parameter) I want the list of pr...

Opening multiple txt files into one workbook as separate sheets
I have seen posts about opening multiple txt files from a folder and saving each of them as a separate .xls. Is there a macro that would open all the .txt or .dat files in the directory that the .xls resides and put them as a new sheet in that folders .xls? IE. Folder1 data1.dat data2.dat Excel.xls 1.After running the macro in Excel.xls in Folder1 it has sheets data1.dat and data2.dat 2. Then if I move Excel.xls to Folder 2 with data3.dat and data4.dat and ran the macro again... Excel.xls would have data1.dat data2.dat data3.dat data4.dat Maybe this page will help http://www.rondebr...

Posting message to a thread
Hello group... A few days back I posted a question about passing data from a secondary thread back to the main application thread. I received some really useful (and enlightening responses!)... I hope I'll get equally great answers to this one too... Well, this time I'm looking at various available options of sending a notification message from the main thread to a secondary one. Actually, I need to notify the secondary thread of a timer event. i.e. when the timer fires, I need to notify the secondary thread to stop its execution. Do I absolutely need to have a user-interfac...

What are the differences between Thread created by AfxBeginThread and CreateThread
thank you very much! babylon wrote: > thank you very much! > > AfxBeginThread initializes the MFC library for operation in the thread, and then it initializes the C++ runtime library for operation in the thread, and calls CreateThread, which is the API for creating the thread itself. If your thread uses the libraries then you must initialize them for each thread by using AfxBeginThread. -- Scott McPhillips [VC++ MVP] "babylon" <amuro@hotmail.com> wrote in message news:<uBIippPMEHA.3472@TK2MSFTNGP09.phx.gbl>... > thank you very much! AfxBeginTh...

how to make that the subform can grow without running over the textboxes at the bottom of the mainform.
Hi I have mainform that contains textboxes then subform datasheet beneath and after that there is a textboxes again. The problem is when the mainform grows it runs over the textboxes that at the button of the main form. I need to know how to make that the subform can grow without running over the textboxes at the bottom of the mainform. Thanks Set the Can Grow attribute for the detail section, assuming that's where the various controls are located. HTH -- -Larry- -- "Chipcom" <bz1977@gmail.com> wrote in message news:1191388299.890979.46580@d55g2000hsg.googlegroups.co...

run total in excel
Iis there a formula that will keep a running total in excel example: C2=5 B2=5 total in A2 =10 now if I change C2 to 8 then A2 will be 18 and if I change B2 to 12 then A2 will = 30 I dont want to use VBA if at all possible -- grizz Hi Grizzly In A2 type =c2+b2 Any number you will type in C2 & b2 will be added to A2 Regards John "grizzly6969" <grizzly6969@discussions.microsoft.com> wrote in message news:98451D4C-63CB-4913-A34A-9D327A3980A1@microsoft.com... > Iis there a formula that will keep a running total in excel > example: > C2=5 B2=5 total in A2 =10 ...

Running macro when starting worksheet
Is there a way when you open a Excel Spreadsheet to automatically run before any manipulation of the file happens? Any help would be great. Thanks. C.Fillmore Two ways, Create a macro named Auto_Open or add the code to the Workbook_Open event in the ThisWorkbook code modeul. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "surveyorinva" <surveyorinva@discussions.microsoft.com> wrote in message news:FAB3C72E-4D69-49D0-A621-363DE617A035@microsoft.com... > Is there a way when you ope...

HELP: Running two Macros, one before the other
I have this Excel spreadsheet in which I want to automate, I have two macros once called Macro_GetData, and Macro_FormatData. Both these Macros work fine, but when I try to automate them it runs the 2nd Macro before the 1st Macro is even finish. I tried to use the "Application.Wait" command but that just stopped the macros entirely. What I want the macro to do is to run the first Macro (Macro_GetData) and when that's finished then run the second Macro (Macro_FormatData). The second Macro cannot work unless the first macro is completed. How can I go about doing this? Bobbak, It s...

Two Domains, each running its own Exchange servers
This is a multi-part message in MIME format. ------=_NextPart_000_0242_01C63656.7A9FD3E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How does one allow access to the mailbox of another domain which is on a = different Exchange box? For example, I'm logged into domain1 with AD2k3 and runnng Exchange 2k3 = using my Outlook 2k3; I want to access my mailbox which is in domain2 = with AD2k, running Exchange 5.5... I tried giving permission on the = other user account on the Exchange 5.5 by entering in "domain1\user" = under ...