|
I have a problem executing a particular child process from my Windows MFC application. The call is simply the name of the executable and an input file as commandline option (see below):
CString commandline = "runall.exe datafile.txt";
switch(WinExec(commandline ,SW_SHOWNORMAL))
{
error handling.....
}
The child process starts, but terminates almost immediately without doing its simulations, and without returning any error values. In a console-window the process runs correctly when using the same call. This puzzles me since I also run several other child processes from my application, whithout experiencing the same problems. Launching the process through functions, like spawn or system, etc., does not help either. This child application uses quite a deal of memory, so it could be a memory problem? However, since it runs correctly in a console window even when the parent application is also running, the total amount of memory on the computer must be large enough. Are there some settings I could alter to increase the memory that can be allocated by my application? Any hint on what might be the problem here will be highly appreciated!
Thank you in advance!
maladuk
I am using Visual C++ 6.0
|
|
|
|
|
My first guess would be a relative vs. absolute path issue.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, I have checked this. The call work fine if I use it for another child application.
Thanks anyway!
m
|
|
|
|
|
maladuk wrote: No, I have checked this.
But in your code snippet, commandline is using a relative path. Change it to an absolute path to see what happens.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well, using
commandline = "C:\\mydir\\runall.exe C:\\mydir\\datafile.txt";
does not help.
m
|
|
|
|
|
What if you use CreateProcess() instead of WinExec() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The code snippet indicates that some assumptions may not be valid:
1. Does the child program run? Save the result of the WinExec call in
a variable and check it. Add a positive statement that the program was run properly,
2. Does the child program read the command line correctly? You need postive and negative results here too.
3. Can the child process find the input file? WinExec may be able to locate the program to run but the program may not be able to locate the input file. Pay attention to the current directory and how WinExec finds the child program.
My guess is that #3 is the problem since you can run the child program
independently.
modified on Tuesday, December 11, 2007 1:04:27 PM
|
|
|
|
|
I have two methods.. OnCheck() which will check the record in listview control and another method Onchecklist() which will disabel or enable the buttons. Now my query is I want to check more than 1 record in the listview controls and store the indexes in an array. Then I want to pass each one to the OnCheckEPayList() method.
Any pointers would be greatly helpful.
Thanks,
Sai
|
|
|
|
|
Your question isn't clear at all. What are you trying to do exactly ? Please, think that we do not see your code and so we have no idead at all what OnCheck Onchecklist are doing, which buttons you are talking about and what you store in the listview.
Anyway, it seems you are looking for a container class. Did you have a look at std::vector (or std::list) ?
|
|
|
|
|
Cedric Moonen wrote: Please, think that we do not see your code...
Come on, Cedric. When you took the oath to join the super-secret club, the welcome kit contained a pair of "spy" binoculars for just this purpose.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: the welcome kit contained a pair of "spy" binoculars for just this purpose.
Like those[^] we liked so much when we were kids?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Are you wanting to know which items in the list control are selected? If so, use the GetSelectedCount() and GetNextItem(..., LVNI_SELECTED) methods.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
if you are using a CListBox , have a look at GetSelItems , but your list but be set to use multiselect (and/or extended select) style.
if you are using a CListCtrl use CListCtrl::GetSelectedCount and CListCtrl::GetNextItem ( see this[^] )
|
|
|
|
|
I have gotten all the code page identifiers using the function EnumSystemCodePages...but i can't seem to find any function that returns the descriptive name of a particular code page...like the names shown in the 'Advanced' tab of Regional and Language Options...anyone know how to get the descriptions?
|
|
|
|
|
Haroon Sarwar wrote: ...but i can't seem to find any function that returns the descriptive name of a particular code page...like the names shown in the 'Advanced' tab of Regional and Language Options...anyone know how to get the descriptions?
I just googled with EnumSystemCodePages and the third entry in the list was this --> http://www.codeproject.com/KB/system/codepage.aspx[^]
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
thanks....don't know how i managed to miss it!
|
|
|
|
|
How to copy a file from pocket PC to destktop PC.I want to get the best method.Please help me.Thank you!The follow is my code,but I need the better measure.Which fuction can do it?
CString strFileNamePC=_T("d:\\nini.txt");
CString strFileNamePPC=_T("\\nini.txt");
CFile oldFile;
oldFile.Open(strFileNamePC, CFile::modeWrite|CFile::modeCreate|CFile::typeBinary);
BSTR bstr = strFileNamePPC.AllocSysString();
SysFreeString(bstr);
CeRapiInit();
HANDLE h;
h = CeCreateFile(bstr, GENERIC_READ, 0/*cannot be shared*/, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
char cTemp[BUFFER_SIZE];
DWORD nbytes;
CString s;
int iTotBytes = 0;
DWORD n=CeGetFileSize(h,NULL);
if(h!=INVALID_HANDLE_VALUE)
{
//AfxMessageBox("??");
while(CeReadFile(h, cTemp, (DWORD)n,&nbytes,NULL) && (nbytes>=1) )
{
oldFile.Write(cTemp,n);
}
}
CeCloseHandle(h);
oldFile.Close();
CeRapiUninit();
Yunasheng Ni
ni_yuansheng
|
|
|
|
|
Why not just use CopyFile() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi,
for my one of application, i installed diffrent printer model through printer Drivers INF file, My application works fine.
Now i needed that when i'm parsing INF file through my program, how can i sure that pertincular printer model is PnP capable or not. is there any standerd way to decide this when reading a INF file. for example for an INF file the [ModelSection] defined as:
/////////////////////////////////////////////////////////////
; Model sections
;
; Each section here corresponds with an entry listed in the
; [Manufacturer] section, above. The models will be displayed in the order
; that they appear in the INF file.
[HP]
; HP Color LaserJet 4700
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\Hewlett-PackardHP_CoF1B4,DOT4PRT\Hewlett-PackardHP_CoF1B4&PRINT_HPZ,DOT4PRT\Hewlett-PackardHP_CoF1B4&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6217,DOT4PRT\vid_03f0&pid_6217&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6217&DOT4&PRINT_HPZ,DOT4PRT\VID_03F0&PID_6217&Rev_0100,DOT4PRT\VID_03F0&PID_6217&Rev_0100&DOT4&PRINT_HPZ,DOT4PRT\VID_03F0&PID_6217&Rev_0100&PRINT_HPZ
; HP Color LaserJet 4730
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\Hewlett-PackardHP_Co2FFA,DOT4PRT\Hewlett-PackardHP_Co2FFA&PRINT_HPZ,DOT4PRT\Hewlett-PackardHP_Co2FFA&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6317,DOT4PRT\vid_03f0&pid_6317&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6317&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6317&Rev_0100,DOT4PRT\vid_03f0&pid_6317&Rev_0100&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6317&Rev_0100&DOT4&PRINT_HPZ
; HP LaserJet 3050
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_3217&mi_00&PRINT_HPZ,DOT4PRT\Vid_03f0&Pid_3217&mi_00&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3217&Rev_0100&mi_00&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3217&Rev_0100&mi_00&DOT4&PRINT_HPZ
; HP LaserJet 3052
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_3317&mi_00&PRINT_HPZ,DOT4PRT\Vid_03f0&Pid_3317&mi_00&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3317&Rev_0100&mi_00&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3317&Rev_0100&mi_00&DOT4&PRINT_HPZ
; HP LaserJet 3055
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_3417&mi_00&PRINT_HPZ,DOT4PRT\Vid_03f0&Pid_3417&mi_00&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3417&Rev_0100&mi_00&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3417&Rev_0100&mi_00&DOT4&PRINT_HPZ
; HP LaserJet 3390/3392
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_3517&mi_00&PRINT_HPZ,DOT4PRT\Vid_03f0&Pid_3517&mi_00&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3517&Rev_0100&mi_00&PRINT_HPZ,DOT4PRT\vid_03f0&pid_3517&Rev_0100&mi_00&DOT4&PRINT_HPZ
; HP LaserJet 5200
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_6417,DOT4PRT\vid_03f0&pid_6417&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6417&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6417&Rev_0100,DOT4PRT\vid_03f0&pid_6417&Rev_0100&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6417&Rev_0100&DOT4&PRINT_HPZ
; HP LaserJet 5200L
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\vid_03f0&pid_6617,DOT4PRT\vid_03f0&pid_6617&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6617&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6617&Rev_0100,DOT4PRT\vid_03f0&pid_6617&Rev_0100&PRINT_HPZ,DOT4PRT\vid_03f0&pid_6617&Rev_0100&DOT4&PRINT_HPZ
; HP LaserJet 3005
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\Hewlett-PackardHP_La023A,DOT4PRT\Hewlett-PackardHP_La023A&PRINT_HPZ,DOT4PRT\Hewlett-PackardHP_La023A&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7317,DOT4PRT\vid_03f0&pid_7317&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7317&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7317&Rev_0100,DOT4PRT\vid_03f0&pid_7317&Rev_0100&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7317&Rev_0100&DOT4&PRINT_HPZ
; HP LaserJet 3004
%HP_Mombi_Driver_Name% = hpmcpdp6.gpd,LPTENUM\HPUPD_PCL6,DOT4PRT\Hewlett-PackardHP_LaC2FB,DOT4PRT\Hewlett-PackardHP_LaC2FB&PRINT_HPZ,DOT4PRT\Hewlett-PackardHP_LaC2FB&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7617,DOT4PRT\vid_03f0&pid_7617&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7617&DOT4&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7617&Rev_0100,DOT4PRT\vid_03f0&pid_7617&Rev_0100&PRINT_HPZ,DOT4PRT\vid_03f0&pid_7617&Rev_0100&DOT4&PRINT_HPZ
////////////////////////////////////////////////////////////////////
But i'm not getting how to decide which model is Pnp capable or not.plz help me.
Thanks in advance
Ashish
|
|
|
|
|
Hi,
I need to get a handle to the "Save As" Dialog of another
application once the user Clicks "Save As" Option in that
application.So as to kill the dialog Immediately.
I used FindWindowEx and EnumChildWindows but no use.
Using Spy++ I tried to get the class name of the "Save As"
Dialog it shows "#32770 (Dialog)" as is for any dialog box.
HWND hWnd = ::FindWindowEx(st_hwnd,NULL,
(LPCWSTR)"#32770 (Dialog)",(LPCWSTR)"Save As");
Even if "Save As" Dialog is not the immediate child window
for FindWindowEx to work,it should work with
EnumChildWindows,but doesn't.
HWND hWndChild = NULL;
EnumChildWindows(pWndWmp->m_hWnd, EnumAppearanceChildProc, (LPARAM)&hWndChild);
BOOL CALLBACK EnumAppearanceChildProc(HWND hwnd, LPARAM lParam)
{
CString str = _T("");
CWnd *pChildWnd = CWnd::FromHandle(hwnd);
pChildWnd->GetWindowTextW(str);
if(_tcscmp(str,_T("Save")) == 0)
{
*reinterpret_cast<hwnd*>(lParam) = hwnd;
return FALSE;
}
return TRUE;
}</hwnd*>
What could be the problem? Is there a way where I can
get the handle to the "Save As" dialog of another application?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
I am using a slider control i need the change the background colour of the background colour. I tried to change in the OnCtlColor. Please anyone suggest anything.
|
|
|
|
|
|
When begin dragging, them dragging image will offset twards left and up a little to the original one. I'd like the two images (original and dragging) in the same rect at the very begining. Here is the code:
void CDragDropListCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW *pNMListView = (NM_LISTVIEW*)pNMHDR;
SetCapture();
CImageList *pIL=GetImageList(LVSIL_NORMAL);
CRect rt;
GetItemRect(pNMListView->iItem,&rt,LVIR_ICON);
CPoint pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
pt.x-=rt.left;
pt.y-=rt.top;
pIL->BeginDrag(pNMListView->iItem,pt);
ClientToScreen(&rt);
pIL->DragEnter(NULL,rt.TopLeft());
m_Dragging=TRUE;
*pResult = 0;
}
modified on Thursday, December 06, 2007 5:33:04 AM
|
|
|
|
|
Is there anyway to access a remote hard disk and process it as if it was a local hard disk? I mean, I want to read sectors of data from the remote hard disk which is connected to another machine in the same LAN. Can anyone tell me about how I can get a handle to the remote disk?
Regards,
Vijay.
|
|
|
|
|
Using the CWMPPlayer4 wrapper how should I get for event notifications?
Like, when a file is finished playing or when come back from full screen viwer etc.
(CWMPPlayer4 is composed without IWMPEvents Interface)
Please answer.
Thanks.
|
|
|
|
|