|
|
Hi all,
i am a newbie in VC++..
I have a service written in vc++ (say service.exe).
I want to print a message in the command line if I run "service.exe /V" in command line. Is it possible to do this??. I tried with "_tprintf" but its not working.. Following is the version portion of my code.. please help...
INT APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
::_tcsupr(lpCmdLine);
if (::_tcsstr(lpCmdLine, "/V") != NULL)
{
_tprintf(_T("Version:")) ;
}
}
|
|
|
|
|
|
try,
#ifdef _UNICODE
#pragma comment (linker, "/subsystem:console /entry:wWinMainCRTStartup")
#else //_UNICODE
#pragma comment (linker, "/subsystem:console /entry:WinMainCRTStartup")
#endif //_UNICODE
|
|
|
|
|
Thanks a lot
It worked!!!!
|
|
|
|
|
Hi all,
i have one TreeCtrl and one ListCtrl , When i select a string from listCtrl and then click on Tree Ctrl the slected string is becomes null.
i want to carry this selected string from List Ctrl to Tree Ctrl or any other Ctrl.
how can i do this.
Please anyone can help me.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You can define your own message and like WM_SYNC_MYTEXT and send it to the specified control window. that message has to be handled at the tree control side (i.e derive your own tree control from CTreeCtrl) and handle message inside ON_MESSAGE macro inside the message map)
Please check MSDN
Message Handling and mapping[^]
User defined handlers[^]
There may be a better solution for your problem. What I've said is a quick solution.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
"You can define your own message and like WM_SYNC_MYTEXT and send it to the specified control window. that message has to be handled at the tree control side (i.e derive your own tree control from CTreeCtrl) and handle message inside ON_MESSAGE macro inside the message map)
Please check MSDN
Message Handling and mapping[^]
User defined handlers[^]
"
i have no idea of Message Mapping ,so please tell me with example.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: ...the slected string is becomes null.
What exactly does this mean?
ThatsMe. wrote: i want to carry this selected string from List Ctrl to Tree Ctrl or any other Ctrl.
Ok, so what's the problem? If you have obtained the string from the list control (into a variable of some sort), the list control is no longer part of the problem.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
in my application i m select a string from ListCtrl and perform an action in treeCtrl according to selected string,but after selection of string in ListCtrl when i click on Tree ctrl the selected string is lost there is no string.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: ...when i click on Tree ctrl the selected string is lost there is no string.
So are you deleting it from the list control?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no i don't want to delete it ,it is just bemomes NULL after click on tree view.
i want to perform any action like open any dialog according to selected string from list view.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: ...it is just bemomes NULL after click on tree view.
So are you adding a NULL item, or changing an existing item to NULL ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No i want to use it same as selected from ListCtrl.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
i dont know how can selected string becomes NULL.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Assuming you are using MFC, you've likely got something like:
int nIndex = m_list.GetNextItem(-1, LVNI_SELECTED);
CString strItem = m_list.GetItemText(nIndex, 0); Now until you assign another value to strItem , it will retain its value indefinitely. Interacting with a tree control has nothing to do with it.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ThatsMe. wrote: ...i want to use it same as selected from ListCtrl.
This makes no sense. What are you trying to say?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have created a MFC Activex Control using C++ and I am trying to use that control in C# Windows Application. During Build it shows error as:
EgActivexCtrl fatal error LNK1104: cannot open file 'Debug/EgActivexCtrl.ocx'
Please help me to sort out this error... Thanks
Palanivel
|
|
|
|
|
i was trying to get white color in my application.
my background is grey. when i try to bitblt my dc with paint dc in onpaint i am using SRCPAINT.
so white color is becoming grey.
|
|
|
|
|
if you want the background color of your application to white handle WM_ERASEBKGND and Fill with white color,
CWnd::OnEraseBkgnd(CDC *pDC)
{
pDC->PatBlt(..., WHITENESS) or pDC->FillRect()
}
|
|
|
|
|
|
Hi All,
I am developing an application in which I need to connect to a server and send some commands and retrieve the response. For this, I am using a third party console client application called Plink. Plink requires a console window to start and it cannot be opened by double clicking it. The entire process of login and sending commands and receiving response is automated in my application. Also plink has to be started with a initial command "plink <protocol> <server ip="">".
Code flow:
------------
m_Stdout = GetStdHandle(STD_OUTPUT_HANDLE);
m_StdIn = GetStdHandle(STD_INPUT_HANDLE);
SecureZeroMemory(&m_ProcInfo,sizeof(PROCESS_INFORMATION));
SecureZeroMemory(&m_StartInfo,sizeof(STARTUPINFO));
// Set up members of the STARTUPINFO structure.
m_StartInfo.cb = sizeof(STARTUPINFO);
m_StartInfo.hStdError = m_Stdout;
m_StartInfo.hStdOutput = m_Stdout;
m_StartInfo.hStdInput = m_StdIn;
m_StartInfo.dwFlags = STARTF_USESTDHANDLES;
// Create the child process.
wcscpy(m_Cmdline,_T("plink -telnet <server ip="">")); // server IP is not typed here for security purpose
m_RetVal = CreateProcess(0,
m_Cmdline, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&m_StartInfo, // STARTUPINFO pointer
&m_ProcInfo); // receives PROCESS_INFORMATION
memset(m_UserName,0,BUFSIZE);
wcscpy(m_UserName,_T("pdt2"));
wcscat(m_UserName,_T("\r\n"));
m_BytesToWrite = wcslen(m_UserName);
m_RetVal = WriteConsole(m_Stdout,m_UserName,m_BytesToWrite,&dwWritten,NULL);
if(m_RetVal)
{
fprintf(m_FilePtr,"Write to console succeeded\n");
ReadFromConsole();
}
else
{
m_ErrorCode = WSAGetLastError();
ErrorExit("Write To Console failed",m_ErrorCode);
}
-------------
This is where it fails. After writing the username string to the console, I should get back the password prompt in the console window which doesnt happen.The WriteConsole API succeeds and returns 1 but the application doesnt get back the password prompt as should be the case.In WriteConsole API I pass the standard output handle m_Stdout.
Can anyone say whats going wrong?
Thanks in advance for any kind of help.
Jyoti
|
|
|
|
|
Console expects "\n" as newline character rather then "\r\n".
-Saurabh
|
|
|
|
|
Hi Saurabh,
Thanks for replying.
I even tried with "\n" only but that too is not working.I suspect that WriteConsole is writing to the standard output but console is not able to send the username string to the server. Or may be we need to send the username to Plink somehow so that it sends the username to the server.
Thanks,
Jyoti
|
|
|
|
|
Member 4744683 wrote: m_RetVal = WriteConsole(m_Stdout,m_UserName,m_BytesToWrite,&dwWritten,NULL);
What is the value of dwWritten after this call?
Member 4744683 wrote: After writing the username string to the console...
Do you see it being written, or are you just assuming?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|