|
Hi all,
I am trying to get a value from registry.but it gives 234 error code.That value will contain only a few digits. I have allocated size of 1000. But it is giving the same error code.Can anyone please help me?
Here is the code:
HKEY hkey1,hkey2;
DWORD dwData = REG_SZ;
DWORD dwSize;
char szChk[102];
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Test",0, KEY_QUERY_VALUE,&hkey1))
return;
if(RegQueryValueEx(hkey1,"CHECK",NULL, &dwData, (LPBYTE)szCHK,&dwSize))
return;
Thanks,
|
|
|
|
|
The dwSize is an in_out parameter, meaning you have to specify the initial size of the buffer and the function after executing will return the actual size of the data.
So do this -
DWORD dwSize = 102;
|
|
|
|
|
no... its not working... again it is giving same error code
|
|
|
|
|
Please see an example[^] here
Do not forget to release the memory in that example
(free(PerfData) at the ending of the main() ).virtual void BeHappy() = 0;
|
|
|
|
|
Try to init your size-variable :
char szChk[102];
DWORD dwSize(sizeof(szChk)); virtual void BeHappy() = 0;
|
|
|
|
|
On closer inspection of your code, RegOpenKeyEx return ERROR_SUCCESS if successful.
The value of ERROR_SUCCESS is 0 .
This means RegOpenKeyEx in your code has failed.
Change your if statement to check if the return value is ERROR_SUCCESS .
Please read the documentation on what each function returns.
|
|
|
|
|
Karthika85 wrote: I am trying to get a value from registry.but it gives 234 error code.
It's not necessarily an error. RegQueryValueEx() can return ERROR_MORE_DATA . Read the docs to find out when and why this happens."One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I reference this Using the Windows 2000/XP Object Selection Dialog[^]. It's great article, but what i need is to get specified user list or group, such as "administrators" group, and all users in this groups, what should i set with the filter?
Say:
1. "administrators" group
2. users in "administrators" group
3. "users" group
4. users in "users" group
In a word, my purpose is to get only 1&&2&&3&&4, NOT all the users and groups in local PC, what should i do set with the filter?One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...
|
|
|
|
|
i am not clearing with your question.
are you want current user or all details of user.
|
|
|
|
|
yes, i only want to get all user name in a specified group. Say, user1, user2 are both administrator on local PC, i want to get their names and save the strings into a list. So do "users" group. One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...
|
|
|
|
|
Syouki_kou wrote: but what i need is to get specified user list or group, such as "administrators" group, and all users in this groups, what should i set with the filter?
Have you tried NetGroupGetUsers() and/or NetLocalGroupGetMembers() ?"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thank you for your reply, i know the two API. But i still want to use the system pick up dialog to finish my work. I just have no idea for set the filter. One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...
|
|
|
|
|
you should filter the needed persons out of the list. Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I don't know what the needed persons are, the user press a button on my application will invoke the pick up dialog. My purpose is, no matter what operation user do on the dialog, it will only return "administrators" or "users". One day a pretty girl asked me:"Do u think you are handsome?" "I don't think so!".She gave a slap in my face:"Why lying?"...
|
|
|
|
|
|
Not being able to read Korean, I can't judge if the article is good or not, but there is sample code there for you to follow.
Have you tried following it? If so, what difficulties did you face? It's not reasonable to expect someone to put more effort into answering your question than you did asking and researching it. (By appearances - you may have put LOTS of work in)
I would also disencourage you from creating gifs. There were legal issues, and pgms have all the advantages of gif, with many advantages (ie, alpha channel).
Good luck,
Iain.I have now moved to Sweden for love (awwww).
|
|
|
|
|
Use TWordDocument and TWordApplcation components, Can you create the program hidden toolbar of ms-word ?
|
|
|
|
|
How do I get the base class name of a derived class? I tried using typeid but that only gives me the name of the derived class, not the base class. I have a array that stores many different objects and I am looking for one that is derived from a particular Base class. For example, I did the following:
class A { };
class B : A { };
class C { };
A* pA = null;
B* pB = array[hashValue]; //contains objects of type A, B, and C
if (typeid(*pB) == typeid(A))
//pB is derived from Class A
What function do I need to call in order to get the correct base class?
|
|
|
|
|
I don't know what your "array" is, but you can't put objects of different types in a C++ array or in an STL container. You can put pointers to objects in the same inheritance hierarchy in, but then you know what the base class is.
Evidently, your array is some special container you wrote or found somewhere. It isn't clear how it works or what the return type of array[] is. It obviously can't be A*, B*, or C*. Knowing this is necessary to figuring out how to deal with it. Some possibilities are a discriminated union or boost::any.Please do not read this signature.
|
|
|
|
|
Sorry for not being too clear. Actually, both B and C are derived from A and they both have their own derived classes.
std::map<int, a*=""> m;
class A { };
class B : A { };
class C : A { };
class BDerived: B { };
class CDerived: C { };
B* pBDerived = new BDerived();
m[key1] = pBDerived;
C* pCDerived = new CDerived();
m[key2] = pCDerived;
A* pA = m[key1];
The map m holds A*, B*, C*, BDerived*, CDerived* objects. I'm trying to figure out if the object(pA) in the map is derived from either B* or C*. I hope that's a little clearer.
|
|
|
|
|
OK, that gives me a different picture of what is going on.
It is, of course, preferable to try do things using polymorphism and not have to make this distinction.
Failing that, I believe this is what you are looking for:
{
class A { };
class B : public A { };
class C : public A { };
class BDerived: public B { };
class CDerived: public C { };
std::map<A*> m;
...
A* pA = m[ key1 ];
B* pB = dynamic_cast<B *>( pA );
C* pC = dynamic_cast<C *>( pA );
if ( pB )
{
...
}
else if ( pC )
{
...
}
else
{
...
}
} Please do not read this signature.
|
|
|
|
|
Yes, that is exactly what I'm looking for. Thanks!
|
|
|
|
|
In Actual scenario, we don't need the base class name usually.
So can u be clear with the need of doing so Величие не Бога может быть недооценена.
modified on Tuesday, March 16, 2010 1:06 AM
|
|
|
|
|
I'm at my wit's end trying to track down a crash problem that only one person is seeing, but he sees it on BOTH his computers. I can't reproduce it, even after installing the same OS he's running (XP SP3), and neither can any of my other beta testers.
I'm using XCrashReport to produce minidumps that he can send me when it crashes. It usually crashes on this line in InitInstance, which checks if there is a recently used file to load:
if (m_pRecentFileList->m_nSize > 0 && !m_pRecentFileList->m_arrNames[0].IsEmpty())
I have gone through the code in InitInstance line by line and I don't see any problems. Every global variable is initialized. Return codes are checked for every function call. I changed all my strcpy's to strncpy to make sure there aren't any overflows.
Weirder yet, when I compile the program - exact same code, line-for-line - in VC++ 6 rather than Visual Studio 2008 - he doesn't get the crash. SAME CODE!! The only difference is that with Visual Studio 2008 I link MFC in statically because I'm running Windows 7 (64-bit) and he doesn't have the DLLs on XP.
I installed XP SP3 on a computer and did not get the crash. Two other testers have XP SP3 and do not experience the crash. I asked him to use msconfig to disable Startup programs. He did, and it still crashed. I asked him to use msconfig to reboot into diagnostic mode. He did, and it still crashed. Doesn't that suggest it's my code and not a conflict with something on his system? But if it's such a bad bug, then why doesn't even one other person see it?
I don't know what to do at this point. I can't find it if I can't reproduce it. And not only can I not reproduce it, no one else who has run the beta can reproduce it. I'm tempted to ignore the problem on his system and move on, but what if I release the program and it starts crashing on 10% of systems?
How do I find this bug???
Any help would be greatly - hugely - appreciated. I've been working on this for a week, and I'm out of ideas.
|
|
|
|
|