|
I use the following code in two apps I wrote, app1 run first and call app2 with parameters. I don´t know if there is a better way but it worked fine.
In APP1 the caller app:
char arg[10];//parameter to pass from app1 to app2
fflush(NULL);
//call app2.exe and leaves app1 waiting.
_spawnl(P_WAIT,"app2.exe","app2.exe",arg,NULL);
//call app2.exe and ends app1.
//_execl( "EcoBase.exe", NULL, NULL,NULL, NULL );
In InitInstance() of the called app2:
//check if there are paremeters
if(m_lpCmdLine[0]==_T('\0'))
{
//normal execution of app2 without parameters
if(!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
else//execution of app2 with parameters
{
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNew;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
//do what you want to do with parameters in m_lpComdLine
}
cheers!!
Daniel Cespedes Daza
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Many different possibilities: mappedFiles, mailslots, sockets, WM_COPYDATA. If the data is fixed, you can use SendMessage/SendMessageTimeout with registered message, etc, etc, etc
|
|
|
|
|
Thanks for that. What I have decided to do is this:
// in app1
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
ZeroMemory( &StartupInfo,sizeof(StartupInfo) );
StartupInfo.cb = sizeof( StartupInfo );
if( CreateProcess("d:\\MyApp1.exe","TestString",
NULL,NULL,FALSE,0,NULL,
NULL,&StartupInfo,&ProcessInfo ))
{
WaitForSingleObject( ProcessInfo.hProcess,INFINITE );
CloseHandle( ProcessInfo.hThread );
CloseHandle( ProcessInfo.hProcess );
}
else
{
cout << "Error - Opening Process..";
}
The second parameter is the command line argument. So now I can use GetCommandLine() function.
But I can't get GetCommandLine to work for me. Can someone show me please how to use this function??
Thanks for all ur help.
|
|
|
|
|
I have now got GetCommandLine() function but I can't see my messagebox in the second app..
// in app2
CString str = GetCommandLine();
AfxMessageBox( str );
Thanks..
|
|
|
|
|
I want to connect to my mail server and get mails with Windows Sockets. I want to how can I connect to mail my server with its name ,not with its IP,because I don't know it IP.Any Suggestion?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
|
OK Nish. Thanks.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
OK Nish. Thanks.
See :- http://www.codeproject.com/internet/winsockintro02.asp
if(inet_addr(servername)==INADDR_NONE)
{
hp=gethostbyname(servername);
}
else
{
addr=inet_addr(servername);
hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
}
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
Oh Nish,Thankssssss,I found your article myself. There is no need to paste code. I just say thank you for your reply.Your article is very clear and I find the answer from it very easily. What did you think about my answer man?
Anyway,thank you again.I find the answer from your article,
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
Oh Nish,Thankssssss,I found your article myself
Oh sorry! I just felt guilty at the lazy response I had given you Anyway glad to know you found what you were looking for
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
I've written very handy application for my CP library and I can search through my CP files very quick.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hello, everyone!
After downloading a sourcecode from codeproject, I compiled and linked it, a link error LNK2001 appeared, I found it is caused by this code: char *chpBuf = new char[10]; if I marked off it or change the chpBuf into char array chpBuf[10]. The problem will be solved.
I also try to change the setting of VC, but it doesn't work. I wonder if some of you once met simmilar problem and how you sovle it?
Thanks.
Ray
|
|
|
|
|
Which article are you talking about?
jhaga
|
|
|
|
|
Hi Ray,
Is that struct member alignment in
(Settings:C++\Code Generation) settings is different from the default(marked with *)?
OR
Is this comes only with Release Mode build? In which build mode this problem appears?
regards
~Hari~
|
|
|
|
|
Friends, I want to cach the event of opening a perticuler application, for that i use Windows Hook. I get the handel of the window but from which application/proccess this window belongs i dont know.
Is there any procedure which give me the process Name, if i will supplied it the window Handle
Waiting for the Positive reply
|
|
|
|
|
GetWindowThreadProcessId - get process ID from window handle
OpenProcess - get process handle
Call EnumProcessModules, for each enumerated module call GetModuleFileNameEx.
|
|
|
|
|
Friends, I want to cach the event of opening a perticuler application, for that i use Windows Hook. I get the handel of the window but from which application/proccess this window belongs i dont know.
Is there any procedure which give me the process Name, if i will supplied it the window Handle
Waiting for the Positive reply
|
|
|
|
|
: while capturing a DV Type-2 file using Microsoft Soft DV encoder "MS DV Encoder" i noticed that the type-2 encoded file size is less than the type-2 file captured from any camcoder using directshow.(Type-1 is ok).
e.g
30 sec type-2 captured from DV Camcoder = 100MB
30 sec type-2 captured from "MS DV Encoder" = 80 MB
I have tried all the interfaces (like IAMVideoCompression ,IDVEnc ..) available on "MS DV Encoder" to do some tweaking but the results are same.
so any one who can help me or explain the reason?????
Liaqat
|
|
|
|
|
Hi, I'm creating a MDI application, with different views (e.g data view, chart view) link to the same doc.
When I open these views the childframe titled "doc:1", "doc:2".
However, I want to change the titled as "doc:data", "doc:chart", is it possible ? If yes then how to do it ? Thanks a lot!
|
|
|
|
|
You can overide the void OnUpdateFrameTitle(BOOL bAddToTitle) method in the frame window classes of your documents (CMDIChildWnd derived):
void CChartFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle);
SetWindowText("doc:chart");
}
Pavel
Sonork 100.15206
|
|
|
|
|
Hi,
Hope the following code snippet will help.
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
//--- Following Lines will do the trick---
cs.style &= ~FWS_ADDTOTITLE;
cs.lpszName = "APP NAME : CHILD DOC NAME";
//----------------------------------------
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
//--- Following Lines will do the trick---
cs.style &= ~FWS_ADDTOTITLE;
cs.lpszName = "Mainframe";
//----------------------------------------
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
regards
~Hari~
|
|
|
|
|
The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.How can I prevent this type of termination.
|
|
|
|
|
YSRao wrote:
The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.
I suppose they are dialog based. If it's so, then override OnOK and OnCancel handlers.
Pavel
Sonork 100.15206
|
|
|
|
|
I assume you've written a dialog based app.
Override the OnOK() and OnCancel() handlers to simply return; without calling the base class methods. Then, add a button (eg: IDC_BUTTON_EXIT ) to your dialog and call CDialog::OnOK() in its handler.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I guess this is a dialog-based app, so you need to override CYourDlg::PreTranslateMessage to catch WM_KEYDOWN messages with (wParam == VK_RETURN || wParam == VK_ESCAPE) . You may simply return TRUE from this function (with no base implementation call) to get rid of the behavior you mentioned.
Regards,
BB
|
|
|
|