|
|
Thanx Im looking into your suggestions.
|
|
|
|
|
I am having a video decoder application for which I prepared a Release version.
The program crashes with a message "The instruction at 0x77fc8e1 referenced to a memory 0x0000001 which could not be written.
I inserted AfxMessageBox() at different points and finally found the bug pointing to a memory freeing portion. But if I remove one AfxMessageBox() the error code changes(0x0000001 becomes 0xfffffff). If I reposition the code then error occurs for some other memory freeing block. Has anyone come across such a behaviour. If so I need valuable suggestions.
|
|
|
|
|
|
I have gone through this article. The only possibilit that may occur for me is uninitialized local variables and bound errors. I have done with those except for a small doubt. How to initialize pointers such as int *temp_array and int **double_array.
|
|
|
|
|
jossion wrote: How to initialize pointers such as int *temp_array and int **double_array
int *temp_array pTemparray = NULL;
int **double_array pDoublearray = NULL;
Failure is not an option - it's built right in.
|
|
|
|
|
Hi
I have copied some files and dialog resources used in that file to
my application from some other application.Now while building the
application, I got too many errors saying undeclared all the ID's
of the resources.It seems this is mainly because resources Id's are
not defined in the resource.h file.
So, how to solve this problem?
With Regards
Neeraj Sinha
|
|
|
|
|
Update the resource.h file by adding the old ids from the first application to the new one. If there are id conflicts you have to resolve that.
--
======
Arman
|
|
|
|
|
i am getting the dword from read file operation
ReadFile(hFile, dwBuffer, sizeof(DWORD)*256, &dwNumRead,NULL);
where the dwBuffer is "C:\Documents and Settings\fsi_tc1g\Desktop" wil be i n dword format.
and i need to convert the dwBuffer to cstring.
so that i can use it for
ifstream ifs( dwBuffer, ios_base::binary );
and CFile finfo( m_filePath, CFile::modeRead );
how to convert and pass it to ifstreama and to CFile function.
please guide me.
Help Ever Hurt Never
|
|
|
|
|
sonavi wrote: ReadFile(hFile, dwBuffer, sizeof(DWORD)*256, &dwNumRead,NULL);
Second parameter is pointer to data buffer. And not DWORD , as you assumed. So you can use it as it is.
Prasad
MS MVP - VC++
|
|
|
|
|
The prefix 'dw' is misused here. dwBuffer is not DWORD but a buffer of character. So no CString conversion is needed in your case.
--
======
Arman
|
|
|
|
|
hi every one,
i have a problem that i have develop an application on MFC the application is running well on Windows Xp Professional but doesn't working in Windows Vista Home Edition.My application adds some value to registor for security region. can any one help me out why this is happing .
suraj
|
|
|
|
|
In Vista , there are lots of restrictions on how you deal with registry.
This[^] article may give you some idea.
Prasad
MS MVP - VC++
|
|
|
|
|
thx for great help but i cann't understand how we can enable UAC through MFC ? looking for help
suraj
|
|
|
|
|
Probably, you are writing registry entries to HKEY_LOCAL_MACHINE which is not allowed with UAC enabled. You need to to run it in elevated mode.
But, I advice you to separated the administrative task of writing to this registry entry in separate process. Otherwise, you are unnecessarily providing full access to you application.
Prasad
MS MVP - VC++
|
|
|
|
|
sir,
i have found out the problem actually the problem is due to installer which i developed using Visual stdio 6 . i have gone through a lot of articles and found that i need manifest file for Windows vista but i don't know how can i create it.will you plz help me out
suraj
|
|
|
|
|
Try putting this query in Vista forum. You could get better options.
Prasad
MS MVP - VC++
|
|
|
|
|
hi c++ guru.
i need your help... i'm new in hardcore c++ and currently working on a c++ container namely the priority_queue. i don't have problem using the priority_queue itself but i have this additional requirement to also consider the age of the items in the queue.
my current implementation only deals with the priority of the items in the queue by overloading the "<" operator. i don't know yet what to do when considering the age of the items in the priority_queue.
any help is greatly appreciated...
PS: sample code would be a great help...
charian
|
|
|
|
|
More certainty needed; is age another field in the queue item or you mean the time that an item has lived in the queue. At all events, seems you should redfine the < operator. Provide more info...
--
======
Arman
|
|
|
|
|
What i mean by age is the time that an item has lived in the queue.
i only have the following for now ...
1. template class for my queue:
template <class t=""> class ThreadSafePriorityQueue : public CComAutoCriticalSection
{
private:
priority_queue<t, vector<t=""> > m_q;
int m_intMaxSize;
public:
ThreadSafePriorityQueue()
{
m_intMaxSize = 10000;
}
ThreadSafePriorityQueue(int intMaxSize)
{
m_intMaxSize = intMaxSize;
}
~ThreadSafePriorityQueue()
{
}
bool push( const T& x )
{
bool rtn = true;
Lock();
if(m_q.size() > m_intMaxSize)
{
rtn = false;
}
else
{
m_q.push( x );
}
Unlock();
return rtn;
}
bool pop( T& x )
{
bool rtn = false;
Lock();
if( !m_q.empty() )
{
rtn = true;
x = m_q.top();
m_q.pop();
}
Unlock();
return rtn;
}
bool empty()
{
Lock();
bool rtn = m_q.empty();
Unlock();
return rtn;
}
T front()
{
Lock();
T rtn = m_q.top();
Unlock();
return rtn;
}
};
2. Then I have this structure that i pushed to the queue
typedef struct _StructPriorityRequest
{
int intPriority;
StructRequest structMessage;
bool operator < (const _StructPriorityRequest &structT2) const
{
return intPriority > structT2.intPriority;
}
} StructPriorityRequest;
How should i modify my codes so i could consider the age of the item in the queue? Please help me ....
|
|
|
|
|
StructPriorityRequest should have another field that shows the insertion time; integer value timeStart. Which will be initialized in push like so;
bool push( const T& x )
{
bool rtn = true;
Lock();
if(m_q.size() > m_intMaxSize)
{
rtn = false;
}
else
{
x.timeStart = time(NULL); // HERE
m_q.push( x );
}
Unlock();
return rtn;
}
Then modify the < operator of StructPriorityRequest like so;
bool operator < (const _StructPriorityRequest &structT2) const
{
int myAge = time(NULL) - timeStart;
int herAge = time(NULL) - structT2.timeStart;
return intPriority > structT2.intPriority && /*ALSO CONSIDER myAge and herAge */;
}
IMPORTANT:
As far a know, std::priority_queue does the element comparision inside push method not pop. But the method I've described works if the queue does comarision inside pop not push. So make sure if so, you have to change the container std::priority_queue. Otherwise you will have no way to calculate ages.
--
=====
Arman
|
|
|
|
|
First of all, I would like to thank you for your responses ...
After reading your answer, I just found out that I'm still on the right track ... Thank goodness
I just did the same concept after a lot of readings and research ...
The only difference is that i don't sort (or call tha comparison) when the pop method is called. What I did was I created a worker thread that will call the sort(or call tha comparison) after a certain time had elapsed. In effect, I'll be re-sorting my queue on given a period of time. I'm not sure if this is the efficient way though ...
Care to share your thoughts??
|
|
|
|
|
First of all, I would like to thank you for your responses ...
You are welcome.
Look. You've chosen a complicated way. Actually the problem can be solved without multithreading. Do not use multithreading unless it is reasonably resired. Do not be surprised if a strange synchronization issue gets put ahead. Also do not think you are done unless you are sure all the synchronization issues are considered [at least critical sections should be used to protect the queue from concurrent accesses].
What I'd do is create a custom priority queue [e.i. my own queue] and organize the pop method in a way that it finds the element with the highest priority and removes it. Even no sorting is required; only do find the 'max' element (the highest priority element) and remove/return it.
--
=====
Arman
|
|
|
|
|
Hi all:
Here is my codes:
int main (int argc, char* argv[])
argv[1] is a text file I will read from in my program:
FILE* fp = NULL;
fp = argv[1];
I will get a warning telling me "assignment from incompatible pointer type."
Why?
Thanks
|
|
|
|
|
argv[1] is a char* . fp is a FILE* . Since they don't point to the same type of object, you can't assign one to the other.
|
|
|
|