Urgent : About SHGetValue() API used for Registry
-
Hi, How do I retrieve data in 5th parameter of this API. Since I dont know what will be the length of data n how will I allocate memory to this param??? Even if I declare array of maximum size it gives me error "234" i.e. "ERROR_MORE_DATA" Here is sample code... DWORD dwretrievedDataType = NULL; DWORD dwretrievedLenOfData = NULL; LPWSTR wzretrievedData = NULL; . . . // I have already given proper values for 1st 3 params dwretValue = SHGetValue(hkeyRoot, wzkeyPath, wzvalueOfKey, &dwretrievedDataType, wzretrievedData, &dwretrievedLenOfData); . . . PLz do let me know asap if anyone knows abt it... thanks n regards Supriya Tonape
-
Hi, How do I retrieve data in 5th parameter of this API. Since I dont know what will be the length of data n how will I allocate memory to this param??? Even if I declare array of maximum size it gives me error "234" i.e. "ERROR_MORE_DATA" Here is sample code... DWORD dwretrievedDataType = NULL; DWORD dwretrievedLenOfData = NULL; LPWSTR wzretrievedData = NULL; . . . // I have already given proper values for 1st 3 params dwretValue = SHGetValue(hkeyRoot, wzkeyPath, wzvalueOfKey, &dwretrievedDataType, wzretrievedData, &dwretrievedLenOfData); . . . PLz do let me know asap if anyone knows abt it... thanks n regards Supriya Tonape
Heelo. The last (sixth) parameter is supposed to be the allocated length of the buffer. You must set dwretrievedLenOfData to the size of wzretrievedData before the call to SHGetValue. Now you set it to NULL. BTW, if you want to zero out a DWORD, the use 0 instead of NULL. Kakan
-
Heelo. The last (sixth) parameter is supposed to be the allocated length of the buffer. You must set dwretrievedLenOfData to the size of wzretrievedData before the call to SHGetValue. Now you set it to NULL. BTW, if you want to zero out a DWORD, the use 0 instead of NULL. Kakan
Hi Kakan, I dont want to hard code any value, like size of 5th param... b4 giving this param as input to 'SHGetValue()' U need to allocate memory for 'dwretrievedData'..I did read abt the documentation of it in MSDN Thanks in ton for help coz I am done with my problem :) bye Supriya Tonape
-
Hi Kakan, I dont want to hard code any value, like size of 5th param... b4 giving this param as input to 'SHGetValue()' U need to allocate memory for 'dwretrievedData'..I did read abt the documentation of it in MSDN Thanks in ton for help coz I am done with my problem :) bye Supriya Tonape
Hello again. I'm pleased to be able to help you out. About the buffer size, at some time or another you will have to allocate the buffer for the return value, hardcoded or not... In general, the Windows functions that return buffers usually has a way to give the coder the size of buffer needed for a particular reply.: 1. Set the buffer pointer to NULL, and allocated buffer size to 0. 2. Call the function in question. 3. The function returns the number of bytes/chars needed for the (real) response. 4. Allocate that amount of memory för the buffer. 5. Call the function again, this time with a valid buffer address and the number of allocated bytes. 6. Obtain the result. But I'm not sure if this goes for SHGetValue, though. I haven't checked. But this principle goes for many Windows functions. Kakan.
-
Hello again. I'm pleased to be able to help you out. About the buffer size, at some time or another you will have to allocate the buffer for the return value, hardcoded or not... In general, the Windows functions that return buffers usually has a way to give the coder the size of buffer needed for a particular reply.: 1. Set the buffer pointer to NULL, and allocated buffer size to 0. 2. Call the function in question. 3. The function returns the number of bytes/chars needed for the (real) response. 4. Allocate that amount of memory för the buffer. 5. Call the function again, this time with a valid buffer address and the number of allocated bytes. 6. Obtain the result. But I'm not sure if this goes for SHGetValue, though. I haven't checked. But this principle goes for many Windows functions. Kakan.
Hi, No It doesnt work for it. Though it doesnt give any error but buffer size returned is the size of DWORD. Bye Supriya Tonape