|
Hello,
I'm maintaining an MFC application that reads and writes from/to the registry. Previously, it used the HKEY_LOCAL_MACHINE key. However, this meant that Vista users needed full OS administrative privileges, (and perhaps non-admin XP users, but there aren't a whole lot of those around) which isn't desirable. So, I changed the key used to HKEY_CURRENT_USER. This just appears to not work at all on Vista as a regular user, though it does work elsewhere.
How can I store values in the registry without administrative privileges?
Regards,
Sternocera
|
|
|
|
|
Sternocera wrote: This just appears to not work at all on Vista as a regular user...
Do the registry functions fail?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).
I would recommend the manifest resource file with the security section since it allows you to use registry and file functions without getting false positives from virtualization. I use "AsInvoker" for user apps.
"Windows via C/C++, Fifth Edition" by Richter has some good information on dealing with Vista and using manifests correctly.
The Microsoft endorsed way of properly designing an application for UAC is to use a security manifest section in your manifest file/resource.
Windows Vista Application Development Requirements for User Account Control Compatibility[^]
Create and Embed an application manifest[^]
Certified for Logo Test Case[^]
|
|
|
|
|
Bob,
Thanks for that, but all I want to do is stored some key:value pair application settings! Surely there is a simpler way?
bob16972 wrote: You need to include a security section in your manifest file to prevent Registry and File Virtualization for your application (or have the user turn User Access Control [UAC] off).
Why? I thought that registry and file virtualisation where ways in which
Vista supported applications that used the registry.
Regards,
Sternocera
|
|
|
|
|
Just brushing up my C++ here, and a quick question.
I see people pass by reference using the following methods
&int x;
int & x;
int &x;
Difference? Which is better practice? When declaring a function definition and you want that function to accept a reference, how do you define that function heading?
double myFunction(&int);
?
or do you include the variable name?
double myFunction(int &x);
Sorry to make you go over the basics, my book isn't very clear...
|
|
|
|
|
AFAIK, this: &int x; isn't valid C++.
the other two are identical.
double myFunction(&int);
that's not legal, either.
i always include the variable name, since the header is the first place i look when looking for documentation.
|
|
|
|
|
Hey, thanks for the response.
So you include the variable name in the function definition? Seems like the smart thing to do I guess, I'll try to pick up on that habit.
Thanks for the reply. 5'ed.
|
|
|
|
|
EliottA wrote:
So you include the variable name in the function definition?
yeah. it's not strictly required, but it's really handy to people who want to use the function.
|
|
|
|
|
Chris Losinger wrote: but it's really handy to people who want to use the function.
especially when you have more than one parameter with the same type (as seen in our code)
void f(int, int, double, double, int, int& );
void f(int a, int b, double aa, double bb, int g, int& r){}
This signature was proudly tested on animals.
|
|
|
|
|
Hello,
EliottA wrote:
& int x;
int & x;
int &x;
The first one is plainly illegal.
The second and third have no difference between them. Ideally, I would prefer the third one to avoid any confusion while declaring multiple variables in the same statement. But while you are declaring such a reference variable, you *must* initialize it properly by specifying which variable is it referring to. Unless which, you won't get it to compile.
If a function takes a parameter in by reference (as opposed to 'by value'), any changes made to the variable passed in will reflect on the original variable passed while making the function call (similar to pointers, but the syntax is much cleaner).
This might help you:
void FuncRef(int &n)
{
n = 0;
}
void FuncNormal(int n)
{
n = 4;
}
void _tmain(int argc, _TCHAR* argv[])
{
int i = 10;
int &Ref = i;
cout<<Ref<<endl;
Ref = 2;
cout<<i<<endl;
FuncRef(i);
cout<<i<<endl;
FuncNormal(i);
cout<<i<<endl;
}
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I have two values say "rakesh,gender" parsed into a cstring object(say obj = "rakesh,gender") from a file..(say notepad)..
In my application, they have used Trimright() and Trimleft() functions for this obj;
I changed my notepad file as unicode (before it was ANSI) now..
After passing those two functions (trimright and trimleft), its showing the obj with one square box at the beginning..("(square box)rakesh,gender");
How to remove the square box??
Can anyone guide me how to solve this issue?
Thanks,
Rakesh
|
|
|
|
|
It seems you trimmed using ANSI functions over a UNICODE string or viceversa
If Trimleft and Trimright are from CString , verify your project has been compiled for UNICODE (see the project properties). Also, verify that no ANSI to UNICODE translations are attempred while reading the file by the fucntions.
To have a check, just do a per-step debug and look how the string is represented in meory just after the reading is finished, with a ASCII only text (saved as UNICODE).
It should be "xx 00 xx 00 xx 00 xx ..... " where xx a two hex digits.
If it is "00 xx 00 xx 00 xx" probably you saved also a BOM or you saved with the wrong endianess (it is an option of the format, during "Save As" - something like UTF-16LE or UTF-16BE: 80x86 use LE format).
If it is "xx xx xx xx xx" it has been read as ANSI.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi,
im drawing a char inside Crect variable...and if the Font size of the char is increased then how can i increase the rect size based on the change in Font size of char ...
|
|
|
|
|
kumar sanghvi wrote: ...how can i increase the rect size...
Have you looked at the CRect methods such as InflateRect() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You may use, for instance, GetTextExtentPoint32 [^].
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]
|
|
|
|
|
ya..using GetTextExtentPoint32 ill get the width and height of the char..but how can i inflate the rect proportionally...may be should i inflate by the diff by which the char is changed...
Please correct me if im wrong..
|
|
|
|
|
When you know the geometric dimensions of your string then you may change the rectagle size accordingly (for instance, if your string has dimensions {w,h} then the rectangle maybe {w+b, h+b} where b is a fixed border, or, {w*(100+bp)/100, h*(100+bp)/100} where bp is a proportional border).
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]
|
|
|
|
|
Thanks for ur reply...
but how can i get the fixed border "b" or proportional border "bp"....
|
|
|
|
|
Well, suppose the text width is 120 pixels and the height is 20 pixels, then, a rectangle with a fixed, 5 pixels, border would have width = 120 + 2*5 = 130 pixels and height 20+2*5 = 30 pixels.
If you prefer a proportional border, say 5% , you may set width = 120*(100+5*2)/100 = 132 pixels and height = 20*(100+5*2) = 22 pixels.
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]
|
|
|
|
|
Hi,
I am relatively new to working with Visual Studio/VC++. My requirement is to display an animation (AVI or AGIF) in a dialog control. This works fine. But what I also want is that when the dialog window screen is maximized, this animation (running in the dialog) should also resize/maximize accordingly. When the screen returns to normal position, the animation should also return to its normal size. Is is possible to do this? Right now, I'm only able to maximize the screen and not the animation (The animation is retaining its size). Please help!
|
|
|
|
|
You need to resize the control that play the animation manually; I assume when it resizes, it will resize the movie automagically.
This signature was proudly tested on animals.
|
|
|
|
|
I am able to resize the control. I have used EASYSIZE macro with the control's ID. So, the control is getting resized. But the animation still remains of the same size. (Is this what you mean by resizing manually or are there any other settings/changes?)
|
|
|
|
|
which control using to play AVI/AGIF?
If using CAnimateCtrl then ACS_CENTER is set?
u can use the below mentioned APIs for any control to resize.
use MoveWindow or SetWindowPos
to resize the control according to change in size of parent Window.
http://msdn.microsoft.com/en-us/library/ms633534(VS.85).aspx[^]
Величие не Бога может быть недооценена.
modified on Wednesday, July 29, 2009 9:19 AM
|
|
|
|
|
Yes, I have set ACS_CENTER and I have used SetWindowPos. This helps me resize the control. But the image being displayed on the control does not resize. I am not sure if resizing the 'image' is even possible.
|
|
|
|
|
Hi, I want to draw a Hindi text with a bounding box around. Sample text "मैं हिन्दी नहीं बोल सकता हूँ।".
The problem is the last character with dependent vowel sign, the method misses the bottom part of the text.
0x0939, 0x0942, 0x0901 (devanagari letter ha, vowel sign uu, sign candrabindu)
C# code sample
string text = "मैं हिन्दी नहीं बोल सकता हूँ।";
Font font = new Font("Tahoma", 20.0f, FontStyle.Regular);
SizeF layoutArea = new SizeF(1000, 1000);
StringFormat stringFormat = new StringFormat();
SizeF measure = g.MeasureString(text, font, layoutArea, stringFormat);
g.DrawRectangle(Pens.Red, new Rectangle(50, 50, (int)measure.Width, (int)measure.Height));
g.DrawString(text, font, Brushes.Black, 50, 50);
I have also tried C++ functions GetTextExtentPoint32(), GetTextMetrics() and GetOutlineTextMetrics() to get the correct height but failed.
Any suggestions?
Thanks in advance,
Gywox
|
|
|
|