|
Hi,
Is there any way to convert a HKEY value to it's corresponding registry key name?i.e how do you convert (HKEY) 0x80000000 to HKEY_CLASSES_ROOT ?
|
|
|
|
|
HKEY_CLASSES_ROOT is a macro, defined as
#define HKEY_CLASSES_ROOT ((HKEY)0x80000000)
Do you need to "convert" it to a string?
Instead of using the long-drawn-out switch() statement approach, do it this way:
<br />
#define MAKE_SZ(something) #something <br />
<br />
const char *szHKCR = MAKE_SZ(HKEY_CLASSES_ROOT);<br />
<br />
printf("\n%s",szHKCR);<br />
The 'something' in the macro parameter can be 'anything'. It need not be a pre-defined macro like HKEY_CLASSES_ROOT is. For example, the following will also work:
<br />
const char *Dummy = MAKE_SZ(uioiasdhfkjasdhf);<br />
<br />
printf("\n%s",Dummy);<br />
HTH
Bikram Singh
|
|
|
|
|
Dear Vikram ,
Your method works fine for predefined keys like HKEY_LOCAL_MACHINE etc.But what about HKEY values returned by functions like RegOpenKey,RegCreateKey ? Eg:
RegOpenKey(HKEY_CURRENT_CONFIG,TEXT("Software\\Fonts"),&hKey) returns an integer value in hKey.I want to somehow get the keyname "HKEY_CURRENT_CONFIG\Software\Fonts" from the value in HKEY .
Any suggestions????????????
|
|
|
|
|
My name is BIKRAM, dude.
While I can, possibly, with difficulty, attempt to find out the keypath from a handle-value, its not worth the trouble.
It seems you have either a design problem or are attempting to intercept a function call from a process. In either case, you will need to re-think your strategy. I could help you in this, but i do knot know exactly what you want to accomplish and why.
Bikram Singh
|
|
|
|
|
Hi friends,
I am trying to devlop a Single Document (Document/View Architecture) MFC application, which has Three frames. Left frame has a Hierarchy tree and on selection of any leaf node, number (not fixed) of images be displayed on the right upper frame (four picture per row) dynamically as shown below.
---------------------------------------
| | |
| | |
| Tree | Images |
| | |
| | |
| |-----------------------------
| | |
| | Discription |
| | |
--------- -----------------------------
On click of an image its description should be displayed in right lower frame
My first priority is to display images dynamically.
Example: when there are 10 images, it should display 4 in first row, 4 in second row and last 2 in third row.
If any material/example/sample code/suggestion, Please reply me.
I need it very argently. Please help me.
Thanx
|
|
|
|
|
You might want to search for thumbnail in the MFC/C++-articles, I got 4 hits. You will most probably get a few good ideas there.
|
|
|
|
|
Thanx Johan.
I got some usefull info from the search.
In deed I was looking for similar which I got in search.
Thanx again
|
|
|
|
|
Hi,
In .NET the class view , resource view etc can be docked on the left hand side of the screen and then
when the mouse hovers over them they jut out and can be viewed. Does anyone have an example of how this could be implemented ?
Thankyou,
flip
|
|
|
|
|
1. I have a class that, due to some restrictions, can be instantiated only once at any one time. I was thinking of doing that by using a global variable (I know it's bad...), the code might look like this:
A::A()
{
if(GLOBAL_A_INSTANTIATED > 0)
{
delete this;
return;
}
GLOBAL_A_INSTANTIATED = 1;
.....
.....
}
A::~A()
{
GLOBAL_A_INSTANTIATED = 0;
}
my concern is, how about auto-variables that are instantiated without the new operator? Will this work?
Or are there any better solutions other than using a global variable?
2. Should I declare my member variables that will be updated by a callback function as volatile?
Thanks!
|
|
|
|
|
Indrawati wrote:
my concern is, how about auto-variables that are instantiated without the new operator? Will this work?
Yes, it would work the same as for instanced instantiated using the new operator.
Indrawati wrote:
Or are there any better solutions other than using a global variable?
You could use a static data member in the class. Or use some Windows-specific technique like creating a mutex with a unique name.
Indrawati wrote:
2. Should I declare my member variables that will be updated by a callback function as volatile?
You dont really need to use the volatile keyword unless you are using multiple threads..
Bikram Singh
|
|
|
|
|
Hi
Thanks for the reply.
I have searched the net for some more information, but according to C++ FAQ Lite, delete this must not be invoked on local objects which are allocated on the stack (http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.14), so I guess that means I can't do that on auto-variable, can I?
And regarding the 2nd question, if the callback function is called by another thread, I have to declare the variable as volatile, right?
Thanks!
|
|
|
|
|
Oops, sorry i didnt notice the 'delete this' is your code earlier.
Calling delete this for a stack-based object will cause an exception, because the stack cannot be "freed" until a function returns.
If you are using this technique in your code, you should not be using stack-based objects at all.
Consider this:
void First(void)<br />
{<br />
MyClass a;<br />
}<br />
<br />
void Second(void)<br />
{<br />
MyClass b;<br />
First();<br />
}
In this scenario, how would you prevent the second stack-based object being created in the call to First() ?
For this reason, either you should only use object instantiation via the new operator, or use some a BOOL data member to disable unwanted-instances' functionality. The latter is ofcourse tedious, and prone to errors.
You could, throw an execption in the constructor when you detect that a class instance is not the first instance.
Then, in every place you use this class via stack/freestore, you could use exception handling.
Bikram Singh
|
|
|
|
|
Anonymous wrote:
And regarding the 2nd question, if the callback function is called by another thread, I have to declare the variable as volatile, right?
Yes, you should declare the variable as volatile. Also, note that if you declare a struct to be volatile, all it's members are automatically made volatile.
Bikram Singh
|
|
|
|
|
Would a Singlton work for you situation?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
as in subject.
What is the simplest way to check programatically if
Borland Database Engine is installed on local computer?
Thanks
|
|
|
|
|
Easiest to try and initialize it:
if(DbiInit(NULL) == DBIERR_NONE)<br />
{<br />
ShowMessage("BDE is installed");<br />
}
Bikram Singh
|
|
|
|
|
Hi,
I wonder if there is a way to execute a program from memory.
I've read exe-data from resources and I must execute it without writing to disk.
How could it be done?
NodeX
|
|
|
|
|
Not an area I know much about but trying doing a Google search for: Exe Packers or something like that. These are programs that compress Exe's and then decompress them when they are run.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Not a way that I know of. Why are not able to write to disk first?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I'm thinking about simple protection against debugging
NodeX
|
|
|
|
|
What does debugging an application have to do with anything? And why do you want to be protected from it? If an application has errors, I would think you'd want to know about them.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i have encoded exe-data (flash projector) in resources and i don't want others to get stuff (images etc.) from it...
ok.. it will only protect from simple resource-hackers etc. not from debugging (sorry for imprecision )
NodeX
|
|
|
|
|
Can you not write it to some temporary folder using an obscure name (i.e., nothing obvious), and then delete it when done? Other than that, I know of no way to run something from memory. It's a stretch, but you might search for something about "injecting code into another process' address space."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
As a last resort i will do it with temp folder...
but i can't assume that the person who will have my cd-rom with exe, grant me an access to temp folder...
NodeX
|
|
|
|
|
NodeX wrote:
but i can't assume that the person who will have my cd-rom with exe, grant me an access to temp folder...
Why not use SHGetFolderPath() with CSIDL_LOCAL_APPDATA or CSIDL_PROFILE as the CSIDL?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|