|
Happy dabbling.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
|
Please, don't cross post. You have already posted the same question on Q&A (and you got an answer there).
|
|
|
|
|
Hi All
I am try find out UAC is Enable or Disable through this code
HKEY pHKey;
BYTE pData[64];
DWORD type = REG_DWORD;
DWORD size =64;
LONG uVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0,KEY_ALL_ACCESS, &pHKey);
if(uVal != ERROR_SUCCESS)
{
}
RegQueryValueEx(pHKey, _T("EnableLUA"), 0, &type, pData, &size);
if(pData[0] == 1)
{
}
if(pData[0] == 0)
{
}
RegCloseKey(pHKey);
But it always show Enable.If UAC is enable or disable.
Please help me.
|
|
|
|
|
Why didn't you check RegQueryValueEx return value?
Anyway I would do:
...
DWORD dwEnable;
size = sizeof(dwEnable);
...
LONG lRet = RegQueryValueEx(pHKey, _T("EnableLUA"), 0, &type, (BYTE*) &dwEnable, &size);
if ( lRet != ERROR_SUCCESS)
{
}
else
{
if(dwEnable == 1)
{
}
else
{
}
}
[added]Thanks to MsmVc for pointing out the mistake[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Saturday, November 20, 2010 8:20 AM
|
|
|
|
|
Thanks for reply
modified on Saturday, November 20, 2010 7:03 AM
|
|
|
|
|
One more thing i want to discuss with you.When i follow your step then i am getting UAC Enable or Disabled in Windows 7.
Same code when i am running on Vista then give error.But when i run code Run AS Admin then show UAC Enable or Disable.
Can you explain me why this type of result showing.
Please help me
|
|
|
|
|
Access to the HKEY_LOCAL_MACHINE subtree is protected.
MsmVc wrote: Same code when i am running on Vista then give error.But when i run code Run AS Admin then show UAC Enable or Disable.
It looks like the only way to obtain it (It looks like you cannot programmatically elevate current process privileges, see, for instance here[^]) however, I'm not an expert.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
who can desribe the difference between new and malloc function and
I want to know how they work.Thanks!
|
|
|
|
|
Googling[^] gives many usefull hits, like this[^] for example. Do these answer your question or did you mean a more indept view on these?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Short answer: new gives a chance for objects initialization (by calling constructors) and cleanup (delete calls destructors) while malloc provides bare allocation functionality.
Short advice: while doing C++ development always use the new/delete approach.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
new creates new objects, malloc just reserves you a lump of memory and gives you a pointer to it. So when you say:
foo *p = new foo;
you're asking the compiler to generate the code for creating an original instance of foo (whatever that is) and to tell you where it is in the program's address space. Generally this means:
- The compiler generates code for reserving a lump of memory to store the object in
- It calls the appropriate constructor for foo and runs it on that lump of memory.
On the other hand when you say (in C):
foo *p = malloc( sizeof( foo ) );
you're saying "give me a lump of bytes that happens to be the size of a foo and I'll treat it as a foo." There can be any old rubbish in there. If you want it initialised into any reasonable state you've got to do it manually. Incidentally this is one of the reasons you'll find C programmers immediately memset ting allocated memory blocks or using calloc instead - it gets the memory into a known state. You'll also find that many decent C programmers bundle allocation and initialisation into functions and call them things like "construct_foo" to keep the operation atomic.
Incidentally there are loads of places you can plug into the object creation sequence process in C++ but very few (i.e. none I know of) of modifying the way malloc works in C. In C++ you can modify how the memory is reserved (by overloading operator new or using placement new), what to do if the allocation fails (set_new_handler ) and how the object is initialised (by writing constructors).
One final point. If new fails it throws an exception and winds back any initialisation or memory reservation that's already been completed. The exception is either bad_alloc if the memory reservation fails, or something from the constructor. If malloc fails it returns a NULL pointer, which is another good reason to use initialisation functions in C - you can handle all the errors in one place.
Cheers,
Ash
|
|
|
|
|
The best thing to do is to put a breakpoint on the line where new is called and then step into the code.
You can see all the things that it does and finally calls into the Windows API.
You could also overload new in one of your classes and then debug into it.
|
|
|
|
|
|
Hi,
I have to add property pages to a property sheet at runtime.
How can I exchange data of this page at runtime?
|
|
|
|
|
DoDataExchange() is not supposed to be called directly. You can use UpdateData().
|
|
|
|
|
You cannot do this.
You will have to do this using the functions instead.
Internally, the DDX_xxx wrappers do exactly this.
So for controls created dynamically you will have to do this yourself.
|
|
|
|
|
Hey,
this is my code:
connect(s, (SOCKADDR*) &addrin, sizeof(addrin));
send(s, stRequest.c_str(), stRequest.length(), 0);
cout << "stRequest sent." << endl;
recv(s, buffer, sizeof(buffer), 0);
cout << "buffer received." << endl;
Now this works perfectly fine if the webserver is working well, but sometimes it just sits there trying to recv() forever..
Iam not exactly sure what causes it but either way, I need a way to set a timeout or something similiar..
I couldn't really find something helpfull on google, so yea I thought maybe you guys could help me out.
|
|
|
|
|
|
ALLERSLIT wrote: Now this works perfectly fine if the webserver is working well, but sometimes it just sits there trying to recv() forever..
Iam not exactly sure what causes it but either way, I need a way to set a timeout or something similiar..
There are multiple choices:
- adjust the send/receive timeouts with setsockopt(), see SO_SNDTIMEO and SO_RCVTIMEO
- use non-blocking/asynchronous sockets, makes event based applications so much easier
- use a C++ networking library/API offering timeouts or search for a HTTP client class, would be my recommendation
Happy coding!
|
|
|
|
|
hello guys...im doing small project in TAPI.
- I show all the available lines in combo box.
- Now when I select a line device from combo box; I get its index and pass it to lineOpen(), but this does't work.
- Finally I hard-coded the line device id (ZERO in this case) which worked absolutely fine.
My question is: why does the combo box method is't working as it should be. What should I do?Any idea? thnx
|
|
|
|
|
overloaded Name wrote: My question is: why does the combo box method is't working as it should be. What should I do?Any idea? thnx
What do you mean with that?
Could you please post the relevant code?
Have you checked the method's return value?
(To sum up: "have you used the debugger?")
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Could you please post the relevant code?
well there is nothing much for the code. I get index and pass it which does't work.
If I hard cord the line device id then it works fine. Here is the code
DWORD index = m_comboDevices.GetCurSel();
OpenLine(index);
WaitForIncomingCall(index);
CaptureEvents();
Everything is fine so the only problem is; selecting the line device from combo box is not working.
|
|
|
|
|
There are two possible problems in the obove code:
1. You do not check that the return value from GetCurSel() is a valid response (i.e. no error checking).
2. Are you sure that the CombBox index value is the same as the line number? What does WaitForIncomingCall() actually do?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
overloaded Name wrote: DWORD index = m_comboDevices.GetCurSel(); //m_comboDevices = control variable of combo box
OpenLine(index); //a function opens a line with provided argument
WaitForIncomingCall(index); //it waits for incoming calls on the provided line (argument)
CaptureEvents(); //this function captures events.
The correct approach here is:
DWORD index = m_comboDevices.GetCurSel();
if (index == CB_ERR)
{
}
..
Moreover: why don't you use the debugger (or, for instance, the TRACE macro) to inspect index value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|