|
I dont know whether this is a problem of express edition. How ever I am using professional edition and in that the folder structure is as follows
<projectname>
|
->DEBUG
->RELEASE
-><project name="">
|
->DEDUG ( this is the intermeidate directory and $(IntDir) macro will hold this path )
->RELEASE
->.cpp, .h etc</project></projectname>
Any way can u tell me what is the value of $(IntDir) MACRO in the project settings? You can find it from project settings..
|
|
|
|
|
It's $(TargetFileName).intermediate.manifest
|
|
|
|
|
then check the file in that location.
|
|
|
|
|
Hi all,
I have a BMP image which has to written into an AVI file.
The scenario is i will get a frame/BMP from the camera and i should save into an AVI file then i will get next frame after 1 minute and should add that also into the avi.
Please suggest how to do and plz give an eg. of how to write a bmp into AVI
Thanx in Advance....
Vidya
|
|
|
|
|
|
|
Hi,
I see two solutions:
1 - The best way ( C++ \ COM ):
- Use directshow
- Made a source filter that receive your bmp and inject it on graph.
=> You can add compression filter to reduce size.
2 - The old school way:
Avi file in uncompressed mode store frame as bitmap.
a - Write avi header with fake info (see avi spec for more detail).
b - Add each bitmap add the end of the file (see avi spec for more detail).
c - Rewrite the header.
-> You can found avi spec here:
- http://yaai.sourceforge.net/yaai/fileformat.html (fast).
- http://www.wotsit.org (full doc)
-> The file generated is very big because of no compression.
-> Take care to file size because of file system limitation.
-> To reduce size you can store jpeg instead of bmp (MJPEG)
-> Use jpeg6b lib (freeware & open source) to converter bmp -> jpeg.
Bye...
...
|
|
|
|
|
I am making a program that will take in a txt with 3 peices of info per line, group, program, parameters. The program needs to make a CreateProcess for each program in the first group, then wait until all programs have completed, then start on the next group. In the end, it prints out the results. The WaitForMultipleObjecst is not working and when I "GetLastError()" it comes back error:6 which I believe means an invalid handle. I have other problems with the code I know (timers always come back zero), but that's okay for now.
The Code:
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
using namespace std;
class ProgramDetails
{
public:
int m_group;
string m_programToLaunch;
string m_programParams;
DWORD m_exitCode;
SYSTEMTIME m_kTime;
SYSTEMTIME m_uTime;
ProgramDetails(string group, string programToLaunch, string programParams);
ProgramDetails(int gp, string pL, string pP, DWORD eC, SYSTEMTIME kT, SYSTEMTIME uT);
ProgramDetails();
void Display () const;
};
//constructors
ProgramDetails::ProgramDetails(){};
ProgramDetails::ProgramDetails(string gp, string pL, string pP)
{
istringstream iss(gp);
iss >> m_group; // this should be tested
m_programToLaunch = pL;
m_programParams = pP;
}
ProgramDetails::ProgramDetails(int gp, string pL, string pP, DWORD eC, SYSTEMTIME kT, SYSTEMTIME uT)
{
m_group = gp;
m_programToLaunch = pL;
m_programParams = pP;
m_exitCode = eC;
m_kTime = kT;
m_uTime = uT;
}
// setting up one line of output
void ProgramDetails::Display() const
{
cout << m_group << "\t" << m_kTime.wHour << ":" << m_kTime.wMinute << ":" << m_kTime.wSecond << ":"<< m_kTime.wMilliseconds;
cout << setw(3) << "\t" << m_uTime.wHour << ":" << m_uTime.wMinute << ":" << m_uTime.wSecond << ":" << m_uTime.wMilliseconds;
cout << setw(4)<< "\t" << m_exitCode << "\t\t" << m_programToLaunch << "\t" << m_programParams<< endl;
}
// printing out the vector
void DisplayVector(const vector<ProgramDetails>& finishedList)
{
cout << "Group\t" << "KernelTime\t" << "UserTime\t" << "ExitCode\t" << "Program\t\t" << "Parameters" << endl;
cout << "-----\t" << "----------\t" << "--------\t" << "--------\t" << "-------\t\t" << "----------" << endl;
for(unsigned int i = 0; i < finishedList.size(); ++i)
{
finishedList[i].Display();
}
}
int main(int argc, char* argv[] )
{
//const char* str = argv[1]; // remember to uncomment this line and the ifstrea fileStream(str) line
std::vector<ProgramDetails> progList;
std::vector<ProgramDetails> finishedList;
string line;
ifstream fileStream ("input3.txt");// remember to comment out this line
//ifstream fileStream(str);
while(getline(fileStream, line))
{
istringstream iss(line);
string group;
string programToLaunch;
string programParameters;
getline(iss, group, ',');
getline(iss, programToLaunch, ',');
getline(iss, programParameters);
ProgramDetails details(group, programToLaunch, programParameters);
progList.push_back(details);
}
//cout << progList.size() << endl;
STARTUPINFO sinfo ={0};
sinfo.cb = sizeof(STARTUPINFO);
PROCESS_INFORMATION pi = {0};
//int n = progList.size();
HANDLE* myThreads = NULL;
//myThreads = new HANDLE[n];
//for(int k = 0; k < n; ++k)
//{
// myThreads[k] = 0;
//}
int currGroup = progList[0].m_group;
vector<HANDLE> vecHandles;
for(unsigned int i = 0; i < progList.size();++i)
{
if(progList[i].m_group == currGroup)
{
string str1 = progList[i].m_programToLaunch;
string str2 = progList[i].m_programParams;
//cout << str1 << "," << str2 << endl;
string command = str1 + " " + str2;
unsigned long const CP_MAX_COMMANDLINE = 32768;
try
{
char* commandLine = new char[CP_MAX_COMMANDLINE];
strncpy_s(commandLine, CP_MAX_COMMANDLINE, command.c_str(), command.size());
CreateProcessA(NULL, commandLine, NULL, NULL, false, 0, NULL, NULL, &sinfo, &pi);
}
catch(std::bad_alloc& )
{
wcerr << L"Insufficient Memeory to launch application" << endl;
return 1;
}
DWORD exitCode = 0;
GetExitCodeProcess(pi.hProcess, &exitCode);
FILETIME creationTime, exitTime, kernelTime, userTime;
int Timer = GetProcessTimes(pi.hProcess, &creationTime, &exitTime, &kernelTime, &userTime);
//cout << "Timer Says: " << Timer;
SYSTEMTIME cTime, eTime, kTime, uTime;
::FileTimeToSystemTime(&creationTime, &cTime);
::FileTimeToSystemTime(&exitTime, &eTime);
::FileTimeToSystemTime(&kernelTime, &kTime);
::FileTimeToSystemTime(&userTime, &uTime);
vecHandles.push_back(pi.hProcess);
ProgramDetails finDetails(currGroup, str1, str2, exitCode, kTime, uTime);
finishedList.push_back(finDetails);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
{
myThreads = new HANDLE[i];
for(unsigned int k = 0; k < i; ++k)
{
myThreads[k] = vecHandles[k];
}
DWORD dwResults = WaitForMultipleObjects(i, myThreads, TRUE ,INFINITE);
switch(dwResults) {
case WAIT_OBJECT_0:
cout << "Got the first one" << endl;
break;
case WAIT_OBJECT_0 + 1:
cout << "Got the second one to work" << endl;
break;
case WAIT_OBJECT_0 + 2:
cout << "Got WHEEEE!!! third one to work" << endl;
break;
default:
cout << "Error: " << GetLastError();
break;
}
Sleep(2000);
currGroup = progList[i].m_group;
--i;
}
if(i == progList.size()-1)
{
myThreads = new HANDLE[i];
for(unsigned int k = 0; k < i; ++k)
{
myThreads[k] = vecHandles[k];
}
DWORD dwResults = WaitForMultipleObjects(i, myThreads, TRUE ,INFINITE);
switch(dwResults) {
case WAIT_OBJECT_0:
cout << "Got the first one" << endl;
break;
case WAIT_OBJECT_0 + 1:
cout << "Got the second one to work" << endl;
break;
case WAIT_OBJECT_0 + 2:
cout << "Got WHEEEE!!! third one to work" << endl;
break;
default:
cout << "Error: " << GetLastError();
break;
}
}
}
delete [] myThreads;
myThreads = NULL;
DisplayVector(finishedList);
return 0;
}
|
|
|
|
|
You're putting the handles into a vector and then closing the handle.
vecHandles.push_back(pi.hProcess); <<<<<--------
ProgramDetails finDetails(currGroup, str1, str2, exitCode, kTime, uTime);
finishedList.push_back(finDetails);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess); <<<<<--------
(And why use a vector? You already know the number of items.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks for the quick response. I have remove both of these lines and still get the same results. Actually I don't know the number of items already. This program will have a txt file piped in that lists the programs and groupNumbers. I also did this with a dynamic array without the vector and got the same results. Did it with a static array to test it and voila... same results. Any other mistakes you can see in the code?
|
|
|
|
|
Check the return from CreateProcess to make sure it's being created.
Note that you should close PROCESS_INFORMATION::hThread right away and PROCESS_INFORMATION::hProcess before terminating the program.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Yes, the CreateProcess is being made, BOOL comes back as true, and both test programs launch. I have also put the code back in to close the thread and the process.
|
|
|
|
|
Make sure the process handle is closed AFTER the wait, else it will fail. I wrote the following small program that successfully waited on both handles. I guess I just can't see where your program is going wrong right now.
HANDLE handles[2];
STARTUPINFO sinfo;
memset(&sinfo, 0, sizeof(sinfo));
PROCESS_INFORMATION pi;
if (CreateProcessA(NULL, "C:\\Util\\ProcMon.exe", NULL, NULL, false, 0, NULL, NULL, &sinfo, &pi))
{
handles[0] = pi.hProcess;
}
CloseHandle(pi.hThread);
if (CreateProcessA(NULL, "C:\\Util\\ProcExp.exe", NULL, NULL, false, 0, NULL, NULL, &sinfo, &pi))
{
handles[1] = pi.hProcess;
}
CloseHandle(pi.hThread);
int result = WaitForMultipleObjects(2, handles, TRUE, INFINITE);
if (result < 0 || result > 1)
{
printf("Error: %d\n", result);
}
CloseHandle(handles[0]);
CloseHandle(handles[1]);
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks for all your help, it really is helping me out. I will look at your code and see what I can do.
|
|
|
|
|
Compiled and ran it. The way you've nested loops, particularly if(i == progList.size()-1) , made the program not do what it looks like it's supposed to do, but the [single] wait did work for me. You should be using vecHandles since what matters is the number of actual handles you actually have.
It also appears that you'd be leaking a myThreads pointer after you finish with the first wait and if you allocate memory for the second.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I added in the if(i==progList.size()-1) to ensure I caught the last group that ran through since it would never see the else code. I have moved all the timer sutff and put it into the else block now. This clears up my timer problem. Essentially what I am looking at now is making the PROCESS_INFORMATION into a dynamic array so I can store all the pi information for later. Then I run this
CreateProcessA(NULL, commandLine, NULL, NULL, false, 0, NULL, NULL, &;sinfo, &;pi[i]);
and put it into the vector of handles for later.
vecHandles.push_back(pi[i].hProcess);
It loops here for a while, when the groupNumber changes is now goes to the else block and executes
I made another dynamic array, but this time it is an array of handles the size of (i) called myThreads
WaitForMultipleObjects(n, myThreads, TRUE ,INFINITE);
DWORD exitCode = 0;
GetExitCodeProcess(pi[i].hProcess, &exitCode);
Put the timing stuff here
The timing now works fine
Now I have to concentrate on getting this done:
ProgramDetails finDetails(currGroup, str1, str2, exitCode, kTime, uTime);
finishedList.push_back(finDetails);
Now close the handles
CloseHandle(pi[i].hThread);
CloseHandle(pi[i].hProcess);
The problem I am now facing is how to put the currGroup, str1, and str2 from each process into the final vector along with the timing information and exit code.
Have I confused things enough now? This has been a slow painful process.
|
|
|
|
|
wjeanveau wrote: This has been a slow painful process.
It almost always is. And when your done, you'll wonder why it was so hard.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Tomorrow will be a better day to look at it again. Thanks for trying.
|
|
|
|
|
Hi Guys,
I've been searching extensively over the past couple of days but still have trouble reading bits from a file. I'm trying to read the header of an MPEG ts file.
Here is what I have:
<br />
<br />
struct TS_PACKET_HEADER {<br />
unsigned int sync_byte:8; <br />
unsigned int payload_unit_start_indicator:1;<br />
unsigned int transport_error_indicator:1;<br />
unsigned int transport_priority:1;<br />
unsigned int PID:13;<br />
unsigned int scrambling_control:2;<br />
unsigned int adaptive_field_exists:2;<br />
unsigned int payload_data_exists:1;<br />
unsigned int continuity_counter:4;<br />
};<br />
<br />
...<br />
<br />
<br />
<br />
int size;<br />
unsigned char* buffer;<br />
<br />
std::ifstream inputFile("mpeg.ts", std::ios::in | std::ios::binary);<br />
if (inputFile.is_open()) <br />
{<br />
size = 4;<br />
buffer = new unsigned char[size];<br />
inputFile.seekg(0);<br />
inputFile.read( reinterpret_cast<char*>(buffer), size);<br />
<br />
TS_PACKET_HEADER header = * (TS_PACKET_HEADER*) buffer;<br />
}<br />
</char*>
The first byte reads fine but the next two bytes (payload_unit_start_indicator, transport_error_indicator, transport_priority and PID) read incorrectly.
Where am i going wrong and is there a better way to do this?
Packet header information:
http://en.wikipedia.org/wiki/Transport_stream#Important_elements_of_a_transport_stream[^]
|
|
|
|
|
Disable the padding and try.
#pragma pack(1)
struct TS_PACKET_HEADER {
unsigned int sync_byte:8;
unsigned int payload_unit_start_indicator:1;
unsigned int transport_error_indicator:1;
unsigned int transport_priority:1;
unsigned int PID:13;
unsigned int scrambling_control:2;
unsigned int adaptive_field_exists:2;
unsigned int payload_data_exists:1;
unsigned int continuity_counter:4;
};
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
A solution more secure :
#pragma pack (push, 1)
....
#pragma pack (pop)
An other things, your structure size is : 33 bits.
Align it to 40 bits or 64 bits by adding a fake data at the end.
bye...
...
|
|
|
|
|
Thanks for all your replies.
I've read up on it a bit and have tried both pragma pack(1) before the struct and pragma pack(push, 1) ... pragma pack(pop) around the struct and both have not worked.
This[^] also verifies what you have said.
I havent disable padding though. I've look for how to do this but cant find it for either GCC of Visual Studio. I've also had a look at this[^] to no avail.
The header was incorrect. I've removed payload_data_exists:1 and made adaptive_field_exists:2
http://www.erg.abdn.ac.uk/research/future-net/digital-video/mpeg2-trans.html[^]
|
|
|
|
|
I have to wonder if this structure is correct:
botnet wrote: // header structure
struct TS_PACKET_HEADER {
unsigned int sync_byte:8;
unsigned int payload_unit_start_indicator:1;
unsigned int transport_error_indicator:1;
unsigned int transport_priority:1;
unsigned int PID:13;
unsigned int scrambling_control:2;
unsigned int adaptive_field_exists:2;
unsigned int payload_data_exists:1;
unsigned int continuity_counter:4;
};
The reason I ask is that it contains 33 bits, so it would read 8 bytes from the file.
Also, there are many types of MPEG - MP3, MP4, MPEG, etc.
You might want to check for the file format at www.wotsit.org
Perhaps there are supposed to be some padding bits in there somewhere?
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi all,
I am writing an MFC program (VC++ 6) that generates a report and supposedly able to print it out. The report is fine, but somehow it prints a blank page to the printer. After days of debugging the code, I still cannot locate the problem. This is why I can't simply post the problematic code here, I don't know which part is the problem! (Please forgive me if this is really not the right way to ask)
Here I created a (much) simplified code that simulates my problem. It could be because:
1. It is SDI-based program, but I deleted the CDocument class since I don't need it.
2. I use Easy! Reports (http://www.codeproject.com/KB/miscctrl/easyreports.aspx[^]) to generate the report
3. The report is shown using a custom control (http://www.codeproject.com/KB/docview/dfv.aspx[^])
4. Lastly, I am trying to print without using doc/view framework (http://www.codeproject.com/KB/printing/printing_wo_docview.aspx[^])
Could anyone please help me here. From what I understand, all I have to do is prepare the device context for printing (using number 4 above) and send it to the report generator function (number 2). Yet, it prints a blank page.
If anyone could please take a glance and point me to the right direction, I would really appreciate it. Thanks.
Download link: http://rs324.rapidshare.com/files/121245334/TestReport.zip[^]
|
|
|
|
|
Hi, I will afterwards take a look to your code.
On the other hand...
1) The document should not be a problem to print or not to print.
2) If you are seeing the things in your screen, the easy reports should not be the problem
3)...
4) It is ok, you can do it.
Some check-points I faced in one project...
Are you taking care on your MAPMODE and page Orientation? (screen are pixels with a meaning, but printers... this is another world)
Are you taking care about the m_rectDraw and page offsets?
Are you using CreaterPrinterDC??
ADD: You may want to take a look here[^]
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Monday, June 9, 2008 2:21 PM
|
|
|
|
|