|
chandu004 wrote: what is the mistake here.
The "mistake" is that you are not using SHFileOperation() to copy the folder contents.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
thanks for your reply.
can you pleaase explain me how and where to use this function?
thanks in advance.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
chandu004 wrote: can you pleaase explain me how and where to use this function?
See here and here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Rajesh R Subramanian wrote:
Redirecting an arbitrary Console's Input/Output[^]
dear rajesh,
this seems to be a perfect source match for my type of requirement.
today iam planning to integrate this feature into my app.
but i found it in vs 2008. i have to use it in vc 6.0.
i will try it and come here if iam facing any problems.
many more thanks again.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
You can hide the console if you use CreateProcess by setting the STARTF_USESHOWWINDOW flag and SW_HIDE in the wShowwindow members of the STARTUPINFO parameter. By I don't think you can run an internal DOS command using CreateProcess.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: You can hide the console if you use CreateProcess by setting the STARTF_USESHOWWINDOW flag and SW_HIDE in the wShowwindow members of the STARTUPINFO parameter
oh thank you. i will try it now.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
iam still unable to achieve it.
the return value of CreateProcess is 0.
can you please give some clues?
thank you.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
|
I often use ShellExecuteEx (look it up to know what libraries to link.) This wraps CreateProcess in an easier to use form. I've cut and paste a modified version here.)
To execute a copy; pass "cmd.exe" as the app and "/c command" as the args. Set pDir to the dir where you want the operation to take place. Pass false for show. (The /c tells cmd.exe to execute the command and then exit.)
bool Execute(LPCTSTR pApp, LPCTSTR pArgs, bool show, LPCTSTR pDir)
{
if (!pApp)
{
SetLastError(ERROR_FILE_NOT_FOUND);
return false;
}
SHELLEXECUTEINFO execInfo;
memset(&execInfo, 0, sizeof(execInfo));
execInfo.cbSize = sizeof(execInfo);
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
execInfo.lpFile = pApp;
execInfo.lpParameters = pArgs;
execInfo.nShow = show ? SW_SHOW : SW_HIDE;
char path[MAX_PATH];
if (pDir)
{
execInfo.lpDirectory = pDir;
}
else
{
lstrcpyn(path, pApp, MAX_PATH);
if (PathRemoveFileSpec(path))
{
if (path[0])
execInfo.lpDirectory = path;
}
}
if (execInfo.lpDirectory && !DTDirExists(execInfo.lpDirectory))
{
SetLastError(ERROR_PATH_NOT_FOUND);
return false;
}
if (!ShellExecuteEx(&execInfo))
return false;
if (execInfo.hProcess)
CloseHandle(execInfo.hProcess);
return true;
}
modified on Tuesday, August 4, 2009 11:15 AM
|
|
|
|
|
thank you,
i would try your logic also.
thanks again.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Why does the statement:
printf("This is Raza. \r Who are you? ");
gives the following output.
Who are you?
What effect does the carriage return makes on the text to be printed out?
|
|
|
|
|
i think ,
carriage return(\r) brings the control to the 1st column and linefeed (\n) takes it to the new line.
so u should use \r\n
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Add a new line to it.
printf("This is Raza. \r\n Who are you? ");
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Someone has down-voted you both. I balanced it... Probably you were suggesting \r\n, while it should have been \n ?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
thank you.
but, AFAIK, while using normal printf, \r\n and \n does the same. but for some consoles like(hyperterminal for example) what i have observed is
using only \n gives the output somehting like
hello
.....world
so i felt using both would be a standard way.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
modified on Monday, June 29, 2009 7:41 AM
|
|
|
|
|
\r brings the carriage back to the beginning of the current line (without inserting a line feed) and that erases the existing text. To understand what I mean, try this:
printf("ABCDEFGHIJ \r");
To solve this, use \n instead of \r .
\n will insert a line feed and will return to the beginning of the newly inserted line.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hallo, i have the following function in SDI-application:
void CMyClass::Myfunction()
{
CString strOutput;
LPMSG *pmsg = NULL;
for(int i = 0; i < 3000; i++)
{
::PeekMessage(NULL,NULL,0,0,PM_NOYIELD | PM_REMOVE);
strOutput.Format ("%d",i);
m_ptrOutput->SetWindowTextA (strOutput);
}
}
as you see the for-loop goes 3000 times and should print the value of i, what happens when this function starts
is the appliction FREEZ. I do not have any idea why this happens and how to solve this problem.Please help.
|
|
|
|
|
What is that magic number 3000?
Why do you want to loop 3000 times?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
loop 3000 to get the rows from a database :
select * from DB;
|
|
|
|
|
susanne1 wrote: LPMSG *pmsg = NULL;
What is the purpose of this pointer variable? You aren't using it anywhere in your code. Not to mention LPMSG is already a pointer to a MSG structure.
void Func()
{
CString szOutput;
MSG msg;
for(int i=0; i<3000; i++)
{
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
szOutput.Format(_T("%d"), i);
OutputDebugString(szOutput);
}
Why would you do something like this? Are you trying to understand how PeekMessage works or ... ?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i must do it because i have over 40000 rows in the database(wher can i find a tutorial that explain how peekmessgae works??)
do not i need to intialize the msg before i use it?
i used the PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);in the loop that retrives the rows but nothing changed positively??
|
|
|
|
|
You actually are in need of a good book. For book recommendations, see here[^].
Here[^] is a good tutorial on threading. But, that can hardly help you if you don't get a good grip of the basics at first.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
okay thanks but for now how can i solve this problem?
|
|
|
|
|
You cannot solve this problem until you understand the basics. If I start to tell why you should not use PeekMessage there, I'll have to explain what a worker thread is, thread synchronization, applying everything together in your program, etc., Too much of stuff to be discussed in a thread like this. You are desperately in need of a book and go buy one or two. Your program can wait until you're good enough to solve it.
And no pal, I do not feel like providing you a quick-fix. Sorry about that.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You should sometimes (e.g. after reading of 100 data) call a function like this.
If you remove the message from the queue, you should dispatch the message. You can call PeekMessage with other filters too (e.g. for a special window or other messages). But the last call should not use any filters!
void PeekMessages()
{
MSG msg;
// check for paint-messages ...
while ( PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) )
{ // ... and dispatch these
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// only to prevent ghost-window on vista!
// we dont use the result and let the message
// in the queue (PM_NOREMOVE)
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
}
|
|
|
|