Registry programming literacy (III)

Source: Internet
Author: User
3. Regqueryvalueex and regenumvalue
The above are all about how to write the registry, but in many cases, you must read the registry. Ah, let's see which APIs are there, such as 1, 2,... why are there so many? Forget it. Let's just say two. It should be enough. Let's talk about regqueryvalueex first. What does query mean? Don't worry. Let me first look up the dictionary, query, and query. The dictionary says "Suspect". It seems that it cannot be explained. Alas, I still don't want to check it. I knew I had installed Kingsoft quick translation. If you don't talk nonsense, you can simply say that you have used it. This function is to know the name of a data item and then access its value to see the Declaration:
Long regqueryvalueex (
Hkey,
Lptstr lpvaluename,
Lpdword lpreserved,
Lpdword lptype,
Lpbyte lpdata,
Lpdword lpcbdata
);
Hkey and lpvaluename are not mentioned. The first two parameters of regsetvalueex are the same. If you do not understand them, you can refer to the previous chapter :)

Lpreserved: I really can't stand it! It is a useless parameter and must be null.

Lptype, lpdata, and lpcbdata: the three parameters that follow regsetvalueex have the same meaning, except that the addresses of lptype and lpcbdata are required. Not much. Ask me if you don't know.

Return Value? Needless to say, the same is true.
Okay. Where is it? Oh, it should be regenumvalue. I understand this. Enum indicates enumeration, and this function is used to enumerate all values under a key. All right, let's get started and I'll talk about how it works.
Long regenumvalue (
Hkey,
DWORD dwindex,
Lptstr lpvaluename,
Lpdword lpcbvaluename,
Lpdword lpreserved,
Lpdword lptype,
Lpbyte lpdata,
Lpdword lpcbdata
);
There are no mistakes. There are so many parameters that we can't stand Ms anymore. Alas, no way. Let's check it one by one.
Hkey: no more. Same as above.

Dwindex: indicates that the index number starts from 0, 2... and all the values can be found.

Lpvaluename: The name of a value is saved here. It is obviously a string.

Lpcbvaluename: the length of lpvaluename. Do not forget to take the address.

Lpreserved: Another retained, null.

Lptype: similar to the dwtype of regsetvalueex, but the address is used to indicate the type of the value.

Lpdata, lpcbdata, return value: I am exhausted, not to mention, same as above.
It seems that I am not quite clear. Don't blame me. If you don't know, you can ask me. Well, let's take an example. The instance can best illustrate the problem (no one can tell ):
For (INT I = 0; dwres = 0; I ++)
{
Dword cbv = 32, CBD = 32;
Byte szdata [32];
Char szvalue [32];
Dwres = regenumvalue (HK, I, szvalue, & CBV, null, null, szdata, & CBD );
... // Write it by yourself
}
This chapter is written here.

4. Regdeletevalue and regdeletekey
It's too easy to say, but to be worthy of everyone, let's talk about it:
Long regdeletekey (hkey, lpctstr lpsubkey );
Long regdeletevalue (hkey, lpctstr lpvaluename );
That's simple. One deletion key and one deletion value. You don't have.

Postscript.
I have written so much without knowing it. Let's take a look at the table. It's time to go to bed. The level is limited. If you make a mistake, don't laugh. <^ _ ^>
Wait a moment. I can see how many APIs I have written: 1, 2, 3... 8. There are not a lot of them. If not, please give me some advice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.