⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advapi32.java

📁 jnative java 调用动态库需要的包和dll
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	 *       	 The size should include the terminating null character. When the function returns, this variable contains the size of the class string that is stored in the buffer. The count returned does not include the terminating null character. If the buffer is not big enough, the function returns ERROR_MORE_DATA, and the variable contains the size of the string, in characters, without counting the terminating null character.
	 *       
	 *       	 If lpClass is NULL, lpcClass can be NULL.
	 *       
	 *       	 If the lpClass parameter is a valid address, but the lpcClass parameter is not, for example, it is NULL, then the function returns ERROR_INVALID_PARAMETER.
	 *       
	 *       	 Windows Me/98/95:  If the lpClass parameter is a valid address, but the lpcClass parameter is not, for example, it is NULL, then the function returns ERROR_SUCCESS instead of ERROR_INVALID_PARAMETER. To ensure compatibility with other platforms, verify that lpcClass is valid before calling the function.
	 *       
	 *       	 lpReserved
	 *       	 This parameter is reserved and must be NULL.
	 *       	 lpcSubKeys
	 *       	 [out] A pointer to a variable that receives the number of subkeys that are contained by the specified key. This parameter can be NULL.
	 *       	 lpcMaxSubKeyLen
	 *       	 [out] A pointer to a variable that receives the size of the key's subkey with the longest name, in characters, not including the terminating null character. This parameter can be NULL.
	 *       
	 *       	 Windows Me/98/95:  The size includes the terminating null character.
	 *       
	 *       	 lpcMaxClassLen
	 *       	 [out] A pointer to a variable that receives the size of the longest string that specifies a subkey class, in characters. The count returned does not include the terminating null character. This parameter can be NULL.
	 *       	 lpcValues
	 *       	 [out] A pointer to a variable that receives the number of values that are associated with the key. This parameter can be NULL.
	 *       	 lpcMaxValueNameLen
	 *       	 [out] A pointer to a variable that receives the size of the key's longest value name, in characters. The size does not include the terminating null character. This parameter can be NULL.
	 *       	 lpcMaxValueLen
	 *       	 [out] A pointer to a variable that receives the size of the longest data component among the key's values, in bytes. This parameter can be NULL.
	 *       	 lpcbSecurityDescriptor
	 *       	 [out] A pointer to a variable that receives the size of the key's security descriptor, in bytes. This parameter can be NULL.
	 *       	 lpftLastWriteTime
	 *       	 [out] A pointer to a FILETIME structure that receives the last write time. This parameter can be NULL.
	 *       
	 *       	 The function sets the members of the FILETIME structure to indicate the last time that the key or any of its value entries is modified.
	 *       
	 *       	 Windows Me/98/95:  The function sets the members of the FILETIME structure to 0 (zero), because the system does not keep track of registry key last write time information.
	 *       
	 *       	 Return Values
	 *       
	 *       	 If the function succeeds, the return value is ERROR_SUCCESS.
	 *       
	 *       	 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.
	 *       	
	 * </pre>
	 * 
	 * @throws NativeException
	 * @throws IllegalAccessException
	 */
	public static RegQueryKey RegQueryInfoKey(HKEY hKey, RegQueryKey lKey)
			throws NativeException, IllegalAccessException {
		if (lKey == null)
			lKey = new RegQueryKey(1024);

		if (nRegQueryInfoKey == null) {
			nRegQueryInfoKey = new JNative(DLL_NAME, "RegQueryInfoKeyA");
			nRegQueryInfoKey.setRetVal(Type.INT);
		}
		int cur = 0;
		nRegQueryInfoKey.setParameter(cur++, hKey.getValue());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpData());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcbData().getPointer());
		nRegQueryInfoKey.setParameter(cur++, NullPointer.NULL);
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcSubKeys().getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcMaxSubKeyLen()
				.getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcMaxClassLen()
				.getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcValues().getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcMaxValueNameLen()
				.getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcMaxValueLen()
				.getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpcbSecurityDescriptor()
				.getPointer());
		nRegQueryInfoKey.setParameter(cur++, lKey.getLpLastWriteTime()
				.getPointer());

		nRegQueryInfoKey.invoke();
		mLastErrorCode = nRegQueryInfoKey.getRetVal();
		lKey.setErrorCode(getLastErrorCode());
		return lKey;
	}

	/**
	 * <b>RegQueryValueEx</b>
	 * 
	 * <pre>
	 *     
	 *     	 Retrieves the type and data for the specified value name associated with an open registry key.
	 *     
	 *     	 To ensure that any string values (REG_SZ, REG_MULTI_SZ, and REG_EXPAND_SZ) returned are null-terminated, use the RegGetValue function.
	 *     
	 *     	 LONG RegQueryValueEx(
	 *     	 HKEY hKey,
	 *     	 LPCTSTR lpValueName,
	 *     	 LPDWORD lpReserved,
	 *     	 LPDWORD lpType,
	 *     	 LPBYTE lpData,
	 *     	 LPDWORD lpcbData
	 *     	 );
	 *     
	 *     	 Parameters
	 *     
	 *     	 hKey
	 *     	 [in] A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. For more information, see Registry Key Security and Access Rights.
	 *     
	 *     	 This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:
	 *     
	 *     	 HKEY_CLASSES_ROOT
	 *     	 HKEY_CURRENT_CONFIG
	 *     	 HKEY_CURRENT_USER
	 *     	 HKEY_LOCAL_MACHINE
	 *     	 HKEY_PERFORMANCE_DATA
	 *     	 HKEY_PERFORMANCE_NLSTEXT
	 *     	 HKEY_PERFORMANCE_TEXT
	 *     	 HKEY_USERS
	 *     
	 *     	 Windows Me/98/95:  This parameter can also be the following key:
	 *     
	 *     	 HKEY_DYN_DATA
	 *     
	 *     	 lpValueName
	 *     	 [in] The name of the registry value.
	 *     
	 *     	 If lpValueName is NULL or an empty string, &quot;&quot;, the function retrieves the type and data for the key's unnamed or default value, if any.
	 *     
	 *     	 For more information, see Registry Element Size Limits.
	 *     
	 *     	 Keys do not automatically have an unnamed or default value. Unnamed values can be of any type.
	 *     
	 *     	 Windows Me/98/95:  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 and Windows Me, the type of a key's default value is initially REG_SZ, but RegSetValueEx can specify a default value with a different type.
	 *     
	 *     	 lpReserved
	 *     	 This parameter is reserved and must be NULL.
	 *     	 lpType
	 *     	 [out] A pointer to a variable that receives a code indicating the type of data stored in the specified value. For a list of the possible type codes, see Registry Value Types. The lpType parameter can be NULL if the type code is not required.
	 *     	 lpData
	 *     	 [out] A pointer to a buffer that receives the value's data. This parameter can be NULL if the data is not required.
	 *     	 lpcbData
	 *     	 [in, out] A pointer to a variable that specifies the size of the buffer pointed to by the lpData parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpData.
	 *     
	 *     	 The lpcbData parameter can be NULL only if lpData is NULL.
	 *     
	 *     	 If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks.
	 *     
	 *     	 If the buffer specified by lpData parameter is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to by lpcbData. In this case, the contents of the lpData buffer are undefined.
	 *     
	 *     	 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 enables an application to determine the best way to allocate a buffer for the value's data.
	 *     
	 *     	 If hKey specifies HKEY_PERFORMANCE_DATA and the lpData buffer is not large enough to contain all of the returned data, RegQueryValueEx returns ERROR_MORE_DATA and the value returned through the lpcbData parameter is undefined. 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 succeeds, the return value is ERROR_SUCCESS.
	 *     
	 *     	 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
	 *     
	 *     	 An application typically calls RegEnumValue to determine the value names and then RegQueryValueEx to retrieve the data for the names.
	 *     
	 *     	 If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not have been stored with the proper null-terminating characters. Therefore, even if the function returns ERROR_SUCCESS, the application should ensure that the string is properly terminated before using it; otherwise, it may overwrite a buffer. (Note that REG_MULTI_SZ strings should have two null-terminating characters.)
	 *     
	 *     	 If the 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.
	 *     
	 *     	 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. Do not 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.
	 *     	 Example Code [C++]
	 *     
	 *     	 Ensure that you reinitialize the value pointed to by the lpcbData parameter each time you call this function. This is very important when you call this function in a loop, as in the following code example.
	 *     
	 *     	 #include &lt;windows.h&gt;
	 *     	 #include &lt;malloc.h&gt;
	 *     
	 *     	 #define TOTALBYTES    8192
	 *     	 #define BYTEINCREMENT 1024
	 *     
	 *     	 DWORD BufferSize = TOTALBYTES;
	 *     	 PPERF_DATA_BLOCK PerfData = NULL;
	 *     
	 *     	 while( RegQueryValueEx( HKEY_PERFORMANCE_DATA,
	 *     	 TEXT(&quot;Global&quot;),
	 *     	 NULL,
	 *     	 NULL,
	 *     	 (LPBYTE) PerfData,
	 *     	 &amp;BufferSize ) == ERROR_MORE_DATA )
	 *     	 {
	 *     	 // Get a buffer that is big enough.
	 *     
	 *     	 BufferSize += BYTEINCREMENT;
	 *     	 PerfData = (PPERF_DATA_BLOCK) realloc( PerfData, BufferSize );
	 *     	 }
	 * </pre>
	 * 
	 * @param hKey
	 * @param lpValueName
	 * @param lRegData
	 * @return
	 * @throws NativeException
	 * @throws IllegalAccessException
	 */

	public static RegData RegQueryValueEx(HKEY hKey, String lpValueName,
			RegData lRegData) throws NativeException, IllegalAccessException {
		if (lRegData == null) {
			lRegData = new RegData(1024);
		}
		if (nRegQueryValueEx == null) {
			nRegQueryValueEx = new JNative(DLL_NAME, "RegQueryValueExA");
			nRegQueryValueEx.setRetVal(Type.INT);
		}
		nRegQueryValueEx.setParameter(0, hKey.getValue());
		nRegQueryValueEx.setParameter(1, Type.STRING, lpValueName);
		nRegQueryValueEx.setParameter(2, NullPointer.NULL);
		nRegQueryValueEx.setParameter(3, lRegData.getLpType().getPointer());
		nRegQueryValueEx.setParameter(4, lRegData.getLpData());
		nRegQueryValueEx.setParameter(5, lRegData.getLpcbData().getPointer());
		nRegQueryValueEx.invoke();
		mLastErrorCode = nRegQueryValueEx.getRetVal();
		lRegData.setErrorCode(getLastErrorCode());

		return lRegData;
	}

	/**
	 * 
	 * <b>RegGetValue</b>
	 * 
	 * <pre>
	 *     
	 *     	 Retrieves the type and data for the specified registry value.
	 *     
	 *     	 LONG RegGetValue(
	 *     	 HKEY hkey,
	 *     	 LPCTSTR lpSubKey,
	 *     	 LPCTSTR lpValue,
	 *     	 DWORD dwFlags,
	 *     	 LPDWORD pdwType,
	 *     	 PVOID pvData,
	 *     	 LPDWORD pcbData
	 *     	 );
	 *     
	 *     	 Parameters
	 *     
	 *     	 hkey
	 *     	 [in] A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. For more information, see Registry Key Security and Access Rights.
	 *     
	 *     	 This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:
	 *     
	 *     	 HKEY_CLASSES_ROOT
	 *     	 HKEY_CURRENT_CONFIG
	 *     	 HKEY_CURRENT_USER
	 *     	 HKEY_LOCAL_MACHINE
	 *     	 HKEY_PERFORMANCE_DATA
	 *     	 HKEY_PERFORMANCE_NLSTEXT
	 *     	 HKEY_PERFORMANCE_TEXT
	 *     	 HKEY_USERS
	 *     
	 *     	 lpSubKey
	 *     	 [in] The name of the registry key. This key must be a subkey of the key specified by the hkey parameter.
	 *     
	 *     	 Key names are not case sensitive.
	 *     	 lpValue
	 *     	 [in] The name of the registry value.
	 *     
	 *     	 If this parameter is NULL or an empty string, &quot;&quot;, the function retrieves the type and data for the key's unnamed or default value, if any.
	 *     
	 *     	 For more information, see Registry Element Size Limits.
	 *     
	 *     	 Keys do not automatically have an unnamed or default value. Unnamed values can be of any type.
	 *     	 dwFlags
	 *     	 [in] The flags that restrict the data type of value to be queried. If the data type of the value does not meet this criteria, the function fails. This parameter can be one or more of the following values.
	 *     	 Value 	Meaning
	 *     	 RRF_RT_ANY
	 *     	 0x0000ffff 	No type restriction.
	 *     	 RRF_RT_DWORD
	 *     	 0x00000018 	Restrict type to 32-bit RRF_RT_REG_BINARY | RRF_RT_REG_DWORD.
	 *     	 RRF_RT_QWORD
	 *     	 0x00000048 	Restrict type to 64-bit RRF_RT_REG_BINARY | RRF_RT_REG_DWORD.
	 *     	 RRF_RT_REG_BINARY
	 *     	 0x00000008 	Restrict type to REG_BINARY.
	 *     	 RRF_RT_REG_DWORD
	 *     	 0x00000010 	Restrict type to REG_DWORD.
	 *     	 RRF_RT_REG_EXPAND_SZ
	 *     	 0x00000004 	Restrict type to REG_EXPAND_SZ.
	 *     	 RRF_RT_REG_MULTI_SZ
	 *     	 0x00000020 	Restrict type to REG_MULTI_SZ.
	 *     	 RRF_RT_REG_NONE
	 *     	 0x00000001 	Restrict type to REG_NONE.
	 *     	 RRF_RT_REG_QWORD
	 *     	 0x00000040 	Restrict type to REG_QWORD.
	 *     	 RRF_RT_REG_SZ

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -