下面这段代码有什么问题吗?为什么输出的是一堆烫? |
|
60分 |
http://www.programlife.net/why-output-tang-at-debug-in-vc.html
|
http://www.programlife.net/why-output-tang-at-debug-in-vc.html
|
|
我想问一下,为什么在调用了RegQueryValueEx(hKey, “url1”, NULL, &lpType, (LPBYTE)time, &timeSize);之后,time仍然没有被赋值为“url1”的二进制数据,怎么才能给time赋值呢?
|
|
Registry Functions
The following functions are used with the registry: |
|
RegQueryValueEx
The RegQueryValueEx function retrieves the type and data for a specified value name associated with an open registry key. LONG RegQueryValueEx( lpValueName Windows 95 and Windows 98: Every key has a default value that initially does not contain data. On Windows 95, the default value type is always REG_SZ. On Windows 98, the type of a key””s default value is initially REG_SZ, but RegSetValueEx can specify a default value with a different type. Windows NT: Keys do not automatically have an unnamed or default value. Unnamed values can be of any type. lpReserved Windows NT, Windows 95, and Windows 98 are designed to run on little-endian computer architectures. A user may connect to computers that have big-endian architectures, such as some UNIX systems. The lpType parameter can be NULL if the type is not required. lpData The lpcbData parameter can be NULL only if lpData is NULL. If the buffer specified by lpData parameter is not large enough to hold the data, the function returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcbData. If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcbData. This lets an application determine the best way to allocate a buffer for the value””s data. Window NT: If hKey specifies HKEY_PERFORMANCE_DATA and the lpData buffer is too small, RegQueryValueEx returns ERROR_MORE_DATA but lpcbData does not return the required buffer size. This is because the size of the performance data can change from one call to the next. In this case, you must increase the buffer size and call RegQueryValueEx again passing the updated buffer size in the lpcbData parameter. Repeat this until the function succeeds. You need to maintain a separate variable to keep track of the buffer size, because the value returned by lpcbData is unpredictable. Return Values If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error. Remarks If the value data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, and the ANSI version of this function is used (either by explicitly calling RegQueryValueExA or by not defining UNICODE before including the WINDOWS.H file), this function converts the stored Unicode string to an ANSI string before copying it to the buffer pointed to by lpData. Window NT: When calling the RegQueryValueEx function with hKey set to the HKEY_PERFORMANCE_DATA handle and a value string of a specified object, the returned data structure sometimes has unrequested objects. Don””t be surprised; this is normal behavior. When calling the RegQueryValueEx function, you should always expect to walk the returned data structure to look for the requested object. QuickInfo See Also
|
|
40分 |
BYTE time[64];没初始化要设置的值。看2楼的解释
|
嗯嗯,谢了,这个问题我清楚了,可是为什么调用RegQueryValueEx函数后time仍未被赋值呢?
|
|
判断好每个函数返回值, 看错误原因.
|