|
Hi all
My problem in short is, that I call an external console program and this goes wrong:
1. it stops showing its output after a certain point. But only if called by me
2. it asks for "anykey" at the end. yet it does not accept input from my
This only happens if called by me through CreateProcess. I use umeca74's class to redirect the programs output.
When called from the shell, all works well and I can press "anykey" to end the program.
Does anyone have a clue how I can solve Problem 1 + 2? I'm desperate
Thanx a lot in advance, pat le cat
|
|
|
|
|
Problem #1 sounds like an issue within the class you are using to redirect output. You may want to check with the original author of the article to see if he has any suggestions.
For problem #2, it could be the program you are calling is using one of the functions to 'read any key' that reads directly from the console, rather than from the standard input. If that is the case, you may need to use the SendInput() Windows API function to directly 'inject' a keypress into the keyboard input stream.
Software Zen: delete this;
|
|
|
|
|
Sounds interesting, but since I am creating a foreign process via CreateProcess, how I can send any input to this process? SendInput doesn't offer any parameter for that. I just tried it now and it didn't work. My app is a GUI (MFC) app and the one I'm lauching is a console.
Thanx for that quick answer.
To Problem #1, maybe the console app is using printf() for a few outputs, but is then switching over to some other (maybe unbuffered) kind of console output? How can I gather/intercept all console output?
pat le clueless
|
|
|
|
|
SendInput doesn't need to know which process you are intending the input for, since it is injecting keypresses into the keyboard input stream. It's as if you were pressing the keys on the keyboard yourself.
PatLeCat wrote:
To Problem #1, maybe the console app is using printf() for a few outputs, but is then switching over to some other (maybe unbuffered) kind of console output? How can I gather/intercept all console output?
There may be a method for intercepting console output. Try investigating this topic[^] in the MSDN, which discusses console applications.
Software Zen: delete this;
|
|
|
|
|
Thanx again for your answer Gary.
The thing is, I have not enough means to take over control of another process, as it seems. Sending the Input via SendInput might just do the same as if I was pressing any key, if it directly goes to the keyboard buffer. But I want to target this precise process, which I do by taking over the input-stream. But it didn't work anyhow
With std-redirect I do not take over control of the program but it's output stream. Whereas if it doesn't send output there, I cannot do anyting about it. Unless I find another stream I can take over....
Besides I don't have a console where I could read it's content from. I'm calling this program from my GUI app.
Sadly my problem remains unsolved. This is really very annoying. Something so little becomes such a huge nag.
|
|
|
|
|
I am in the process of debugging an SDI (Single Document Interface) program. I have a very big class (Engine Class) that I call from the FormView class, and I have a few values in the Document class. I use CreateFile, then CreateFileMappingObject to read and write data to and from files from the Engine class. When I tried to use Save As or Open from the Menu for a few integers (not related to the date I am using the File Mapping Object for) in the Document class, the program crashes. If I simply run the program without using Save or Open, it runs. Whenever I use Save or Open, after that, the program fails to map into the files. The data I save and retrieve using Save or Open are NOT related in any way to the FMO data.
When I ran the Engine class in Console mode, whenever I clicked on the (x) to close the program, I would get an error and it would crash. I was thinking it could be related to the CStrings I use, but Im not sure...
Can anyone help me??
If you have further specific questions, I will answer ASAP...
Thank you!
Kem
|
|
|
|
|
Is it possible to programmatically find out if the monitor is connected to the computer? I would be very grateful if someone could provide that answer!
|
|
|
|
|
Hello
I was using EnumDisplayMonitors to find all monitors on the system. Try it.
<br />
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL);<br />
<br />
..<br />
<br />
BOOL CALLBACK MonitorEnumProc(<br />
HMONITOR hMonitor,
HDC hdcMonitor,
LPRECT lprcMonitor,
LPARAM dwData
)<br />
{<br />
MONITORINFO mi;<br />
mi.cbSize = sizeof(mi);<br />
<br />
if (GetMonitorInfo(hMonitor, &mi))<br />
{<br />
...<br />
}<br />
return TRUE;<br />
}<br />
|
|
|
|
|
Thanks, but unfortunately it still finds the monitor when it's been unplugged
|
|
|
|
|
GetDevicePowerState()
suhredayan There is no spoon.
|
|
|
|
|
Thanks, that function looks to be what I need, but it fails when I use the monitor handle given by EnumDisplayMonitors
|
|
|
|
|
i had make an application (exe) that display the name of user logon to the computer. when i doubleclik on exe it displays the user name. i m using windows xp.
now i want that when computer start my application automatically start can any body tell me what to do.i had made that application in visual c++ not in the .net framework.
ddd
|
|
|
|
|
If you are looking to run your application when a user login, then put a shorcut of your app in the following folder:
%userprofile%\Start Menu\Programs\Startup
or add a string value containing your applications full path in the following registry key.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run <br />
suhredayan There is no spoon.
|
|
|
|
|
will it works for all users of that computer and will my application will become a service ( not seen on process list of CTRL+ALt+DEl) in xp.
someone told me that if it does not work then u had to write the service.
ddd
|
|
|
|
|
tasleem143 wrote:
will it works for all users of that computer and will my application will become a service ( not seen on process list of CTRL+ALt+DEl) in xp.
someone told me that if it does not work then u had to write the service.
As stated in my post, It starts the application only if the user login. To make it work for all user login write to the registry path : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run But remember it requires administrator privilage to write to this key.
But if you are looking to run your application always irrespetive of whether user logs in or not, then you will have to make your application a NT service. There are several good articles here in codeproject to write NT service. CP search.[^]
suhredayan There is no spoon.
|
|
|
|
|
What is a good algorith for removing duplicates from a sorted vector
alex
|
|
|
|
|
It depends. What choices have you considered so far?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
actually i'm kind of lost. i have an idea to copy the first element in the vector and compare it to the rest, if they are equal pop_back(), else continue and so on, but i dont know where to start
|
|
|
|
|
In-place removal is definitely one possibility. See this[^] link for more information.
Alternatively, you could walk the source vector and copy non-duplicates to a target vector.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
hiho@ll
i'm working on a project using directshow
what i need now is a filter which duplicates
i mean, i need a filter which has one input pin and 2 output pins and it only forwards the input to the 2 output pins without any transformation
i need this vor DV video input and the audio input both
anybody knows a filter which can do this for me?
thx@ll
|
|
|
|
|
I am working with c++. How can i change console diplay mode to full screen.
We Believe in Excellence
|
|
|
|
|
Actually, I've used the CMDITabs from this site and been very happy with it. What I want to do is shrink the tab control's width by some amount to make room for a drop down combo box. In other words, to make a control out of CMDITabs (essentially a CTabCtrl) and a CComboBox.
What steps do I need to do? Should I use CMDITabs as a base, or use CWnd as a base and add both components. I frankly don't know where to start.
Thank you.
|
|
|
|
|
hi...
i want som help in my project
Home Work: The Log Entry application
Due date 22/03/1426
Heba KURDI and Mona BENAISSA
As a member of a software development team, you have been delegated the task of implementing a C++ class that will be used to store a log entry.
A security guard may be required to keep a log of people entering and leaving a building, and note what their reasons for being in the building were. A log entry typically contains a sequence number to identify the entry, the name of the person making the entry, the date and time of the entry, and a short message that explains the purpose of the entry and other required details.
The LogEntry class:
The class which you are required to implement stores the following information.
LogEntry Class
Field Data Type Description
LogEntryID Unsigned Integer A unique identification code associated with each log entry. It must be unique and in the range 1 to 9999. Also see NextAvailableLogID below. The default value is 0.
LastName 20 Characters The last name of the person submitting the log entry. The default value is a null string.
Initials 2 Characters The initials of the given names of the person submitting the log entry. The default value is a null string.
Date 10 Characters The date of the log entry stored in YYYY-MM-DD format. We will refer to this format as “Reverse Date FormT”. All stored dates must be after 2000-01-01, and no later than 9999-12-31. The default date is 2000-01-01.
Time 4 Characters The time of the log entry in HHMM 24 hour format, in increments of a minute. The times will range from 0000 to 2359. The default value is 0000.
LogMessage Up to 60 characters The message entered for this log entry. The message may contain up to 60 characters. The default value is a null string.
DateFormat A single character This data field is used to determine how the dates will be displayed in reports. It is set by the SetDateFormat method to ‘F’ if the date is to be displayed in forward format (i.e. DD-MM-YYYY), or ‘R’ if the date is to be displayed in reverse format (i.e. YYYY-MM-DD).
You are required to implement the following public member and friend functions for this LogEntry class. You may implement other private member functions if you wish.
Default Constructor: A default Constructor to initialise all data to their default values.
Overloaded Extraction Operator Function: An overloaded extraction operator function to enable a user to submit a log entry from the keyboard. This function should perform the following processes and validations.
Prompt the user for a LastName and Initials and ensure that these are not null. The name can have no more than 20 characters and there can be a maximum of 2 characters in the initials.
Prompt the user to enter the Date and the Time. The date and time must be validated. That is, 1 <= Day <= 31, 1 <= Month <= 12, and 2000 <= Year <= 9999. Do not worry about leap years, or months with less than 31 days, etc - just keep things simple. The date should be entered in DD-MM-YYYY format and stored in YYYY-MM-DD format.
For the time, 00 <= Hour <= 23, 00 <= Minute <= 59. Time is in a 24 hour format that goes up to 2359 and then wraps to 0000.
Prompt the user for a valid LogMessage, which can have a maximum of 60 characters.
If any invalid input is encountered, then a meaningful and informative error message must be displayed to the user and they should then be prompted to enter the data again, or your program should adjust the data to make it valid.
Note that this extraction operator function should not set the LogEntryID field, as this will be done separately when the main program calls the SetLogEntryID member function. (See below).
You should note that the format of the date stored in the report is different from the format used to enter the date at the keyboard. Your function will need to manipulate the date from the entry format to that required for storage.
DisplayReportHeading :
This function simply displays the report heading. That is, this function should display the following.
ID Date Time Init Surname Message
---- ---------- ---- ---- -------------------- ------------------------------
SetLogEntryID :
This member function should simply set the LogEntryID for the current log entry to a value passed to the function. This function should be called by the main program. (See below).
SetDateFormat:
This member function should simply set the DateFormat for the current log entry to a value passed to the function. The value passed to it must be either ‘F’ or ‘R’. The default value is ‘F’. This function should be called by main program. (See below).
Overloaded Insertion Operator Function :
An overloaded insertion operator function to display the information in a log entry to the screen.
This function should output the details of the log entry onto a tabular report on the screen. An example of this output for 4 log entries is as follows. You should note that the format of the date displayed in the report may be different from the format used to store it in the log entry. Your function will need to manipulate the date from the stored format to that required for the report display.
You should also note that the message is wrapped if it is longer than 30 characters; and that the wrapping does not split up any words.
0001 01-01-2000 0100 ML Turnbull William Smith entered the
building to deliver flowers.
0002 01-01-2000 0134 ML Turnbull William Smith exited the
building.
0003 01-01-2000 0500 ML Turnbull Staff changeover, Turnbull
off, Schlotzer on.
0004 01-01-2000 0516 A Schlotzer Garbage truck collected
contents of 2 wheeley bins.
Main Program :
The LogEntry class will be used in a test application program that you will write. The test application will allow the user to enter up to 20 log entries and be able to display a summary report of the log contents. A sample of the type of report your test program should produce is as follows.
ID Date Time Init Surname Message
---- ---------- ---- ---- -------------------- ------------------------------
0001 01-01-2000 0100 ML Turnbull William Smith entered the
building to deliver flowers.
0002 01-01-2000 0134 ML Turnbull William Smith exited the
building.
0003 01-01-2000 0500 ML Turnbull Staff changeover, Turnbull
off, Schlotzer on.
0004 01-01-2000 0516 A Schlotzer Garbage truck collected
contents of 2 wheeley bins.
Your main program should declare the following data fields.
Field Data Type Description
NextAvailableLogID Unsigned Integer Initially, this item should be set to 1, and then incremented by 1 each time a new log entry is recorded. This variable enables the LogEntryID to be automatically allocated by the system to the next available number by the SetLogEntryID member function.
NumberOfLogEntries Unsigned Integer Initially, this item should be set to 0, and then incremented by 1 after each customer's account is validated by the Overloaded Input member function.
Your main program should also demonstrate all of the functionality in the LogEntry class. For example, this main program should:
Set the NextAvailableLogID to its initial value of 1.
Invoke the Default Constructor member function by declaring an array of type LogEntry of size 20.
Keep invoking the Overloaded Extraction member function for these log entries, until the user has recorded all 20 log entries or until the user does not want to record any more entries. During this phase, the program should :
Call the SetLogEntryID member function to automatically set the LogEntryID for the current log entry.
Increment the NextAvailableLogID. (See above).
Increment the NumberOfLogEntries. (See above).
Invoke the Display Report Headings member function.
Call the SetDateFormat member function to set the DateFormat for displaying each log entry.
Invoke the Overloaded Insertion member function for all log entries to display the details for each customer
|
|
|
|
|
I'll be more than happy to do your homework assignment for you if you can explain what Heba KURDI and Mona BENAISSA mean.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Heba KURDI and Mona BENAISSA mean
it seems, they are his/her Project Guide!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|