2009-01-21

使用 RegEnumValue 要注意的地方

LONG RegEnumValue(
  HKEY hKey,              // handle to key to query
  DWORD dwIndex,          // index of value to query
  LPTSTR lpValueName,     // address of buffer for value string
  LPDWORD lpcbValueName,  // address for size of value buffer
  LPDWORD lpReserved,     // reserved
  LPDWORD lpType,         // address of buffer for type code
  LPBYTE lpData,          // address of buffer for value data
  LPDWORD lpcbData        // address for size of data buffer
);

返回值 ERROR_NO_MORE_ITEMS,表示都枚舉完了。
dwIndex 為索引,如果是枚舉并刪除的話,就一直為0就行了。
lpcbValueName 這個是ValueNameBuffer 的大小,這個地方要注意!!每次調用前設置成buffer大小,調用后都會設置成返回的ValueName實際的長度,所以這里需要在每次調用前都設置一下,@@ 暈死~,沒注意看MSDN。
lpcbData 同上。

//EOF

0 comments: