|
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.
|
|
|
|
|
As Mike said those are two different pointers.
If you are trying to open files, you have to call fopen library function. Google it.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi guys:
Please consider if the following statement is correct:
In C, Even when I employ dynamic memory allocation in full, I will still need at least one buffer with fixed length to store the string my program reads from a text file before I can use "strlen()" to determine the length of the string and allocate memory for it.
Thank you
|
|
|
|
|
NewZealander wrote: Please consider if the following statement is correct:
Ok, it's been considered. Now what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
NewZealander wrote: I will still need at least one buffer with fixed length
False.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I have class derived from CFileDialog that keeps failing when I select to many files (4-5 works fine). My problem is that I want to find out why it is failing, but the only way I can find to do this is by using CommDlgExtendedError(). However, I cannot check the return code against the values as stated in MSDN because they don't actually seem to be defined anywhere(including Commdlg.h). I don't know if this is a VS2005 issue or not. The code being returned is 12291.
Any suggestions?
Dustin
-- modified at 17:29 Tuesday 24th April, 2007
|
|
|
|
|
12291 == 0x3003 == FNERR_BUFFERTOOSMALL
Clearly documented in the SDK under CommDlgExtendedError()...
"The CommDlgExtendedError function returns a common dialog box error code. This code indicates
the most recent error to occur during the execution of one of the common dialog box functions.
These error codes are defined in Cderr.h."
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Now what are the odds that the answer would be in the first line of the help file. I did actually find that a few minutes ago and have been trying to increase my buffer size by changing the OPENFILENAME.nMaxFile, but this is appearantly causing memory to be over written and failing on initialization of the dialog. I'm getting an access violation error and the call stack shows only assembly.
Any idea how to correctly increase the buffer size?
Dustin
|
|
|
|
|
Dustin Henry wrote: Now what are the odds that the answer would be in the first line of the help file.
that's the reason for my smart-alec reply
Increasing OPENFILENAME.nMaxFile isn't the only thing you need to do. You also need to increase
the size of the buffer pointed to by OPENFILENAME.lpstrFile.
//example
DWORD dwMaxFileLength = MAX_PATH * 10;
MyOFN.lpstrFile = new TCHAR[dwMaxFileLength];
MyOFN.nMaxFile = dwMaxFileLength;
...
delete[] MyOFN.lpstrFile;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
That fixed it. Thanks for the help Mark.
|
|
|
|
|
No problem!
I thought I'd mention that "MAX_PATH * 10" was arbitrary. It may be a good idea to consider
how many files a typical user will select normally and adjust the size accordingly.
You'll have one path and how ever many filenames.
I have no personal set formula. I chose MAX_PATH * 32 in my apps for multiple-select file dialogs
for no reason other than that's the first thing that came to mind and roughly 8K (16K for Unicode)
bytes of temporary memory is cheap I bet 1/10th of that has never been exceeded .
Have fun!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Can't you use the Error Lookup (errlook.exe) tool that ships with VS?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Probably he got the error code ERR_ASK_AT_CP
|
|
|
|