|
I'm using ShellExecuteEX just to get started with my project, and I'm sure there will be offers of a better way to complete the task. My post yesterday was to build the parameter string for ShellExecuteEX, in which I run the Pkgmgr.exe program
There are 2 ways to run the program
1. pkgmgr.exe /iu:myparameters - starts program, but quickly releases shell once program starts.
2. Start /w pkgmgr.exe /iu:myparamters - starts program, does not release shell until it's complete.
I want the second method, so my program waits until the shell completes, but ShellExecuteEx actually checks for the existence of the program file as a pre-flight check.
I was also wondering if there is a way to attach a window of something to so progress.
lp_Operation = "open";
lp_File = "pkgmgr.exe";
lp_Directory = msi_DIR_AppVolumeFolder_II;
lp_Parameters = caWin._create_IIS_Pkgmgr_Install_Parameters();
SHELLEXECUTEINFO lpExecInfo;
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = lp_File;
lpExecInfo.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS ;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = lp_Operation;
lpExecInfo.lpParameters = lp_Parameters;
lpExecInfo.lpDirectory = lp_Directory;
lpExecInfo.nShow = SW_SHOW ;
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
exit_Code = ShellExecuteEx(&lpExecInfo);
if(lpExecInfo.hProcess !=NULL) {
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
::CloseHandle(lpExecInfo.hProcess);
}
|
|
|
|
|
To get a "progress window", you could run the pkgmgr.exe from the command line:
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K (see below)
/Q Turns echo off
/D Disable execution of AutoRun commands from registry (see below)
/A Causes the output of internal commands to a pipe or file to be ANSI
/U Causes the output of internal commands to a pipe or file to be
Unicode
/T:fg Sets the foreground/background colors (see COLOR /? for more info)
/E:ON Enable command extensions (see below)
/E:OFF Disable command extensions (see below)
/F:ON Enable file and directory name completion characters (see below)
/F:OFF Disable file and directory name completion characters (see below)
/V:ON Enable delayed environment variable expansion using ! as the
delimiter. For example, /V:ON would allow !var! to expand the
variable var at execution time. The var syntax expands variables
at input time, which is quite a different thing when inside of a FOR
loop.
/V:OFF Disable delayed environment expansion.
So, do the following:
lp_File = "cmd.exe"
lp_Parameters = CString("/k pkgmgr.exe ") + lp_Parameters;
This will start a command prompt and then run the pkgmgr.exe program.
To get the full help on cmd, start a command prompt (this *is* cmd.exe) and type cmd /?
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Good idea, didn't think of that.
What about the Start /w pkgmgr.exe to satisfy the pkgmgr?
or /k Start /w pkgmgr.exe /iu:
Let me try them all out first and see what happens
Thanks, be back in an hour
|
|
|
|
|
I didn't like the cmd window hanging there with a blinking cursor, Although it did the job.
I added the CoIntialize to the Shell Execute, and it grabs the process, and doesn't let go until the pkgmgr.exe completes now. Before it just came back after the program started running. Now I just need to add the exitCode stuff in case it fails for some reason, and check the errorlevel code at the end.
I'm going to leave it at this for now.
SHELLEXECUTEINFO lpExecInfo = {0};
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = lp_File;
lpExecInfo.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS ;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = lp_Operation;
lpExecInfo.lpParameters = lp_Parameters;
lpExecInfo.lpDirectory = lp_Directory;
lpExecInfo.nShow = SW_SHOW ;
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if ( FAILED( hr ) ) {
CoUninitialize();
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) ) {
wprintf( L"CoInitialize failed. Error 0x%0x\n", hr );
goto comError;
}
}
exit_Code = ShellExecuteEx(&lpExecInfo);
if(lpExecInfo.hProcess !=NULL) {
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
::CloseHandle(lpExecInfo.hProcess);
}
comError:
CoUninitialize();
|
|
|
|
|
you can use cmd /c instead of cmd /k and then the command window will disappear once pkgmgr.exe completes.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
I have a C program and here I invoke the Weka software how can I do? I thank you all for your help!
|
|
|
|
|
|
what I want to do and a C program to invoke the software Weka. I can do this if you like? eg with the previous answer but I would like to understand how to go about my problem! thanks to all
|
|
|
|
|
Did you bother to follow the links provided by Madhu? They clearly demonstrate how to solve your problem.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I'm still amazed by some of the laziness shown by some site users...
|
|
|
|
|
hi!
how do i get counter of item (index of item in CTreeCtrl) with its HTREEITEM ?
for example: user selects 3th item of CTreeCtrl. in code, with GetSelectedItem() function we have HTREEITEM of item. but index of it?(in this example 3)
please help me...
Zo.Naderi-Iran
|
|
|
|
|
The index based on what? What would be index 0?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
The index concept is not applicable for a TreeItem. The HTREEITEM itself is an index identifier for the item.
Loop through each items and store the index values and HTREEITEM in a map for future use.
zon_cpp wrote: user selects 3th item of CTreeCtrl.
If your issue is to get the exact item when the user clicks on a treeitem - I have a suggestion, to use CTreeCtrl's HitTest[^] to get the item from selected point.
|
|
|
|
|
when user click on item of Tree view. for example 3th item: how do i get (3) numeral index this item?
Zo.Naderi-Iran
|
|
|
|
|
You don't. A Tree does not have or use an index. Even if it had, the moment an item gets removed or added, any stored index values would all be invalidated - so you cannot store an index and hope to later retrieve the correct item through that index, because it might no longer be valid!
The HTREEITEM value you get is what is generally called a 'handle'. It serves as a reference to the actual item, and it will remain valid until this child item is removed from the tree. You should use that handle and retrieve the child item, using HTREEITEM GetChildItem(HTREEITEM hItem) const; (see http://msdn.microsoft.com/en-US/library/yk3ystd6%28v=VS.80%29.aspx[^]).
|
|
|
|
|
Why you need the actual "position" (I assume that's what you want) ?
Assuming you want the position in regards with the parent node
parent
- node1
- node2
- node3
- node4
Anyway, a suggestion :
CTreeCtrl::GetParent of selected node and then use CTreeCtrl::GetChildItem and CTreeCtrl::GetNextSiblingItem (or other similar member) in a loop to get the next item; just count.
Watched code never compiles.
|
|
|
|
|
Good idea, and it actually answers the question - but I wonder whether that's what he (or she) actually needs
|
|
|
|
|
Wouldn't calling GetPrevSiblingItem[^] to walk "upwards" until it returns no more items and counting that work?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
probably.
Watched code never compiles.
|
|
|
|
|
zon_cpp wrote: for example: user selects 3th item of CTreeCtrl.
3rd item relative to what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
One way: you can pass index in LPARAM lParam argument when inserting items
in treeview; then use GetSelectedItem to get handle to selected tree item
and get it index with CTreeCtrl::GetItem .
HTREEITEM hItem = m_treeFeature.GetSelectedItem();
TVITEM tvItem = {0};
tvItem.mask = TVIF_PARAM;
tvItem.hItem = hItem;
m_treeFeature.GetItem(&tvItem);
int nindex = (int)tvItem.lParam;
HTREEITEM GetSelectedItem( )
http://msdn.microsoft.com/en-us/library/xw6h5d91(v=vs.80).aspx[^]
|
|
|
|
|
In my MFC application i am using CRichEdit control for multiline text.
I have set the below properties for the rich edit control.
ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
Vertical and Horizontal Scrollbar appears automatically when the text entered is more than the display area. This is working as expected.
I am having one clear button in my application which is to clear the text in rich edit control. But when i click the clear button vertical scrollbar disappears but the horizantal scrollbar is not disappearing.
Can anyone help me out in this? .
|
|
|
|
|
I have already responded to this question here[^]. Please do not post in multiple forums.
|
|
|
|
|
Hi!
how do i select 3th item of a CTreeCtrl?
SelectItem() function needs HTREEITEM of specified item, but i have index of item (for example 3th item)
please help me...
Zo.Naderi-Iran
|
|
|
|
|
It's not possible to access nodes by index. You must know the handle of the node. If you don't have records of the node handles, you can parse the tree:
HTREEITEM hRoot = myTree.GetRootItem();
HTREEITEM hChild1 = myTree.GetChildItem(hRoot);
HTREEITEM hChild2 = myTree.GetNextSiblingItem(hChild1)
HTREEITEM hChild3 = myTree.GetNextSiblingItem(hChild2)
|
|
|
|