Access 2007 VBA Programmer’s Reference phần 10 pps

120 456 0
Access 2007 VBA Programmer’s Reference phần 10 pps

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Return value Long Integer: Zero (ERROR_SUCCESS) on success. The function will return ERROR_MORE_DATA if the data passed to pvData is not large enough to hold the data retrieved in the value. All other values are the specific error code. RegLoadAppKey Description Loads a Registry hive from a file that was saved from the Registry or with RegSaveKey. Declaration Declare Function RegLoadAppKey Lib “advapi32.dll” Alias “RegLoadAppKeyW” _ (ByVal lpFile As String, _ ByRef phkResult As Long, _ ByVal samDesired As Long, _ ByVal dwOptions As Long, _ ByVal Reserved As Long) As Long Parameters lpFile — String: Name of the file that contains the Registry information. phkResult — Long Integer: Variable to receive the handle to the Registry key that is opened with RegLoadAppKey. samDesired — Long Integer: One or more KEY_ constants that com- bine to define the operations that are allowed for this key. You can find these constants at the end of this appendix. dwOptions — Long Integer: If set to REG_PROCESS_APPKEY, indicates that this hive can only be loaded by the calling process. Cannot be loaded by other processes if it is currently loaded. Reserved — Long Integer: Reserved for future use. Set to zero. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegLoadKey Description Creates a new subkey (whose information is loaded from a file that was created using the RegSaveKey function) under the specified key. Declaration Declare Function RegLoadKey Lib “advapi32.dll” _ Alias “RegLoadKeyA” ( _ ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal lpFile As String) As Long 993 Appendix I: Windows Registry Information Table continues on the next page 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 993 Parameters hKey — Long Integer: HKEY_LOCAL_MACHINE, HKEY_USERS, or the handle of a key returned by the RegConnectRegistry function. lpSubKey — String: Name of the new subkey to create. lpFile — String: Path and name of the file to load. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegLoadMUIString Description Reads the specified string from the specified key and subkey. Declaration Public Declare Function RegLoadMUIString Lib “advapi32.dll” Alias “RegLoadMUIStringW” _ (ByVal hKey As Long, _ ByVal pszValue As String, _ ByVal pszOutBuf As String, _ ByVal cbOutBuf As Long, _ ByRef pcbData As Long, _ ByVal Flags As Long, _ ByVal pszDirectory As String) As Long Parameters hKey — Long Integer: Handle to an open Registry key. pszValue — String: Name of the value for the key or subkey to retrieve. pszOutBuf — String: Buffer that will receive the string from the function. cbOutBuf — Long Integer: Length of pszOutBuff. pcbData — Long Integer: Receives the length of the data that is returned into pszOutBuff. Flags — Long Integer: When set to REG_MUI_STRING_TRUNCATE, indicates that the string that is returned is truncated to fit in pszOutBuf. pcbData must be set to NULL when this flag is set. pszDirectory — String: Path to a directory (optional). Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. 994 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 994 RegNotifyChangeKeyValue Description Provides the mechanism to be notified when a Registry key or any of its subkeys is changed. Declaration Declare Function RegNotifyChangeKeyValue _ Lib “advapi32.dll” ( _ ByVal hKey As Long, _ ByVal bWatchSubtree As Long, _ ByVal dwNotifyFilter As Long, _ ByVal hEvent As Long, _ ByVal fAsynchronus As Long) As Long Parameters hKey — Long Integer: The handle of the key to watch, or one of the hive constants listed earlier. lpWatchSubTree — Long Integer: Boolean flag that indicates whether to watch the subkeys for change. Zero: Do not watch subkeys. True (nonzero): Watch subkeys. dwNotifyFilter — Long Integer: One of the following constants: REG_NOTIFY_CHANGE_ATTRIBUTES (to detect changes to a key’s attrib- utes); REG_NOTIFY_CHANGE_LAST_SET (to detect changes to a key’s last modification time); REG_NOTIFY_CHANGE_NAME (to detect changes to a key’s name, or the creation or deletion of keys); REG_NOTIFY_CHANGE_SECURITY (to detect changes to a key’s security information). hEvent — Long Integer: A handle to an event. This parameter is ignored if fAsynchronus = False (zero). fAsynchronous — Long Integer: Boolean flag that indicates whether the function returns immediately when a change is detected. True (nonzero): The function returns immediately, but the event specified by hEvent is signaled when a change is detected. False (zero): The function does not return until a change is detected. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. Comment To use this function, you must understand how to detect and act upon system events, a topic which is beyond the scope of this book. RegOpenKeyEx Description Opens an existing key. This is a more sophisticated function than RegOpenKey, and is recommended for use on Win32. 995 Appendix I: Windows Registry Information Table continues on the next page 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 995 Declaration Declare Function RegOpenKeyEx Lib “advapi32.dll” _ Alias “RegOpenKeyExA” ( _ ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal ulOptions As Long, _ ByVal samDesired As Long, _ phkResult As Long) As Long Parameters hKey — Long Integer: Handle of the key to open, or one of the hive constants listed earlier. lpSubKey — String: Name of the key to open. ulOptions — Long Integer: A reserved parameter. Set it to zero. samDesired — Long Integer: One or more KEY_ constants that com- bine to define the operations that are allowed for this key. You can find these constants at the end of this appendix. phkResult — Long Integer: A variable that is loaded with a handle to the opened key. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegQueryInfoKey Description Retrieves information about an existing key. Declaration Declare Function RegQueryInfoKey _ Lib “advapi32.dll” _ Alias “RegQueryInfoKeyA” ( _ ByVal hKey As Long, _ ByVal lpClass As String, _ lpcbClass As Long, _ lpReserved As Long, _ lpcSubKeys As Long, _ lpcbMaxSubKeyLen As Long, _ lpcbMaxClassLen As Long, _ lpcValues As Long, _ lpcbMaxValueNameLen As Long, _ lpcbMaxValueLen As Long, _ lpcbSecurityDescriptor As Long, _ lpftLastWriteTime As FILETIME) As Long Parameters hKey — Long Integer: The handle of an open key, or one of the hive constants listed earlier. lpClass — String: A null-terminated variable that will be loaded with the class name for the key. This can be vbNullString. 996 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 996 lpcbClass — Long Integer: A variable that you load with the length of lpClass (including the terminating Null character). When the func- tion returns, this variable contains the number of characters actually loaded into lpClass. lpReserved — Long Integer: This is a reserved parameter. Set it to zero. lpcSubKeys — Long Integer: A variable that will be loaded with the number of subkeys under the selected key. lpcbMaxSubKeyLen — Long Integer: A variable that will be loaded with the length of the longest subkey under the selected key, excluding the terminating Null character. lpcbMaxClassLen — Long Integer: A variable that will be loaded with the length of the longest class name for the subkeys under the selected key, excluding the terminating Null character. lpcValues — Long Integer: A variable that will be loaded with the number of values for the selected key. lpcbMaxValueNameLen — Long Integer: A variable that will be loaded with the length of the longest value name for the subkeys under the selected key, excluding the terminating Null character. lpcbMaxValueLen — Long Integer: A variable that will be loaded with the buffer size required to hold the largest value data for this key. lpcbSecurityDescriptor — Long Integer: A variable that will be loaded with the length of the selected key’s Security Descriptor. When the function returns, this variable contains the number of bytes actually loaded into pSecurityDescriptor. lpftLastWriteTime — FILETIME: A user-defined Type that will con- tain the last time that the specified subkey was modified. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegQueryKeyFlags Description Retrieves key flags that are set for the specified Registry key. Requires Windows Vista or later. Declaration Private Declare Function RegQueryKeyFlags _ Lib “advapi32.dll” ( _ ByVal hKey As Long, _ ByVal dwAttribMask As Long, _ pdwAttribute As Long) As Long 997 Appendix I: Windows Registry Information Table continues on the next page 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 997 Parameters hKey — Long Integer: Handle of the open key, or one of the hive con- stants listed earlier. dwAttribMask — Long Integer: Combine one or more KEY_FLAG_ con- stants to specify which attribute values to query. You can find these con- stants at the end of this appendix. pdwAttribute — Long Integer: Returns the attribute mask for the specified key. Return Value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegQueryReflectionKey Description Determines whether Registry reflection is enabled for the specified key. Requires Windows XP Professional x64 Edition or Windows Vista or later. Declaration Declare Function RegQueryReflectionKey _ Lib “advapi32.dll” ( _ ByVal hBase As Long, _ bIsReflectionDisabled As Long) As Long Parameters hBase — Long Integer: Handle to the Registry key to query. bIsReflectionDisabled — Long Integer: A value that determines whether Registry reflection is enabled or disabled for the specified key. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegQueryValueEx Description Retrieves both the type and the value for the specified key. This is a more sophisticated function that RegQueryValue, and is recommended for use on Win32. Declaration Declare Function RegQueryValueEx _ Lib “advapi32.dll” _ Alias “RegQueryValueExA” ( _ ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal lpReserved As Long, _ lpType As Long, _ lpData As Any, _ lpcbData As Long) As Long 998 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 998 Parameters hKey — Long Integer: Handle of an open key, or one of the hive con- stants listed earlier. lpValueName — String: Name of the value to retrieve. lpReserved — Long Integer: A reserved parameter. Set it to zero. lpType — Long Integer: Key value type (from the constants listed ear- lier). lpData — Any: A buffer that is loaded with the data for the specified value. lpcbData — Long Integer: A variable that is loaded with the length of lpData. When the function returns, this variable contains the number of bytes actually loaded into lpData. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegReplaceKey Description Replaces a subkey with information contained in a file, and creates a backup of the original subkey. Declaration Declare Function RegReplaceKey _ Lib “advapi32.dll” _ Alias “RegReplaceKeyA” ( _ ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal lpNewFile As String, _ ByVal lpOldFile As String) As Long Parameters hKey — Long Integer: Handle of an open key, or one of the hive con- stants listed earlier. lpValueName — String: Name of the subkey to replace. This subkey must be directly under HKEY_LOCAL_MACHINE or HKEY_USERS. lpNewFile — String: Name of the file (created using RegSaveKey) that contains the information with which to replace the selected subkey. lpOldFile — String: Name of the file to which the existing subkey will be backed up. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. 999 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 999 RegRestoreKey Description Restores a subkey with information contained in a file. Declaration Declare Function RegRestoreKey _ Lib “advapi32.dll” _ Alias “RegRestoreKeyA” ( _ ByVal hKey As Long, _ ByVal lpFile As String, _ ByVal dwFlags As Long) As Long Parameters hKey — Long Integer: The handle of an open key to restore from disk, or one of the hive constants listed earlier. lpFile — String: Name of the file that contains the information to restore. dwFlags — Long Integer: Use zero for a regular restore. Use REG_WHOLE_HIVE_VOLATILE for a temporary restore (which is not saved when the system is restarted), in which case, hKey must point to HKEY_LOCAL_MACHINE or HKEY_USERS. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegSaveKey Description Saves a key and all its subkeys to a disk file. Declaration Declare Function RegSaveKey Lib “advapi32.dll” _ Alias “RegSaveKeyA” ( _ ByVal hKey As Long, _ ByVal lpFile As String, _ lpSecurityAttributes As SECURITY_ATTRIBUTES) _ As Long Parameters hKey — Long Integer: Handle of an open key, or one of the hive con- stants listed earlier. lpFile — String: Name of the file into which the key (and its subkeys) will be saved. lpSecurityAttributes — SECURITY_ATTRIBUTES: A user-defined Type that defines the security attributes for this key. Security attributes are quite a complex subject and most of their features only work on Windows NT. In any case, they are rarely used, so the examples provided at the end of this chapter re-declare this parameter ByVal SecurityAttributesas Long , and pass a Null (0&). For more information about security, refer to the Microsoft Win32 SDK. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. 1000 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 1000 RegSaveKeyEx Description Saves the specified key and its subkeys and values to a file in the speci- fied format. Declaration Private Declare Function RegSaveKeyEx _ Lib “advapi32.dll” _ Alias “RegSaveKeyExA” ( _ ByVal hKey As Long, _ ByVal lpFile As String, _ lpSecurityAttributes As SECURITY_ATTRIBUTES, _ ByVal Flags As Long) As Long Parameters hkey — Long Integer: Handle of an open key, or one of the hive con- stants listed earlier. lpFile — String: Name of the file into which the key (and its subkeys) will be saved. lpSecurityAttributes — SECURITY_ATTRIBUTES: A user-defined Type that defines the security attributes for this key. Security attributes are quite a complex subject and most of its features only work on Windows NT. In any case, they are rarely used, so the examples provided at the end of this chapter re-declare this parameter ByVal SecurityAttributes as Long, and pass a Null (0&). For more information about security, refer to the Microsoft Win32 SDK. Flags — Long Integer: The format used to save the key or hive. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegSetKeyFlags Description Sets or clears Registry key flags on the specified key. Requires Windows Vista or later. Declaration Private Declare Function RegSetKeyFlags _ Lib “advapi32.dll” ( _ ByVal hKey As Long, _ ByVal dwAttribMask As Long, _ ByVal dwAttribute As Long) As Long Parameters hKey — Long Integer: Handle of the open key, or one of the hive con- stants listed earlier. dwAttribMask — Long Integer: Combine one or more KEY_FLAG_ con- stants to specify which attribute values to set for the key. You can find these constants at the end of this appendix. dwAttribute — Long Integer: Combine one or more KEY_FLAG_ con- stants to set the value for the key. Pass zero to clear the specified attributes. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. 1001 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 1001 RegSetKeySecurity Description Sets the security information for the specified key. Declaration Declare Function RegSetKeySecurity _ Lib “advapi32.dll” ( _ ByVal hKey As Long, _ ByVal SecurityInformation As Long, _ pSecurityDescriptor As SECURITY_DESCRIPTOR) _ As Long Parameters hKey — Long Integer: Handle of a key, or one of the hive constants listed earlier. SecurityInformation — Long Integer: A flag that defines the secu- rity information to save. pSecurityDescriptor — SECURITY_DESCRIPTOR: A user-defined Type that contains the security information to save for the specified key. Return value Long Integer: Zero (ERROR_SUCCESS) on success. All other values are the specific error code. RegSetKeyValue Description Sets a value in the specified Registry key and subkey. Requires Windows Vista or later. Declaration ‘ String declaration of lpData Private Declare Function RegSetKeyValueString _ Lib “advapi32.dll” _ Alias “RegSetKeyValueA” ( _ ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal lpValueName As String, _ ByVal dwType As Long, _ ByVal lpData As String, _ ByVal cbData As Long) As Long ‘ Numeric declaration of lpData Private Declare Function RegSetKeyValueLong _ Lib “advapi32.dll” _ Alias “RegSetKeyValueA” ( _ ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal lpValueName As String, _ ByVal dwType As Long, _ lpData As Long, _ ByVal cbData As Long) As Long 1002 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 1002 [...]... data access pages, allowing distinct recordsource determination DAPs cannot be created in Access 2007 so this wizard is no longer needed Removed Page Combo Box Created a drop-down control on a data access page DAPs cannot be created in Access 2007 so this wizard is no longer needed Removed Page Command Button Created a command button control on a data access page DAPs cannot be created in Access 2007. .. REG_QWORD As Long = 11 100 5 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 100 6 Appendix I: Windows Registry Information Const REG_QWORD_LITTLE_ENDIAN As Long = 11 Const REG_SZ As Long = 1 ‘API return codes Const ERROR _ACCESS_ DENIED As Long = 5& Const ERROR_BADDB As Long = 100 9& Const ERROR_BADKEY As Long = 101 0& Const ERROR_CANTOPEN As Long = 101 1& Const ERROR_CANTREAD As Long = 101 2& Const Const Const... data access page DAPs cannot be created in Access 2007 so this wizard is no longer needed Removed Partial Replica Creates or modifies a partial replica Builds a replica that contains only a subset of the records that a full replica would have In Access 2007, this is used only by the MDB file format Unchanged Table continues on the next page 101 3 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 101 4... Access database to a Microsoft SQL Server database Unchanged User-Level Security In Access 2007, this is available only with the MDB file format Based on the existing database, the wizard creates a new, encoded database that controls user access and permissions It also leaves an unsecured backup copy of the database Unchanged 101 4 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 101 5 Appendix J: Access. .. continues on the next page 101 1 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 101 2 Appendix J: Access Wizards, Builders, and Managers Wizard Description Status Import Exchange/ Outlook Imports an Exchange or Outlook folder to a table in a Microsoft Access database Importing is improved Improved import Import HTML Imports HTML tables and lists from an Internet or intranet site into an Access table A great... button control on a form Enhanced to use embedded macros for the ACCDB format There have also been changes to some of the VBA commands to be in concert with the new controls such as the Ribbon instead of a menu 101 0 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 101 1 Appendix J: Access Wizards, Builders, and Managers Wizard Description Status Conflict Resolver Resolves conflicts between replicated... work right out of the box They are quick and easy to use, and they provide consistency There are no changes to the managers in Access 2007, so if you’ve been using the managers, they will be like old friends 101 5 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 101 6 Appendix J: Access Wizards, Builders, and Managers Manager Description Location Add-In In addition to installing and uninstalling wizards,... As Byte Sbz1 As Byte Control As Long Owner As Long Group As Long Sacl As ACL Dacl As ACL End Type 100 7 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 100 8 47033bapp10.qxd:WroxProgRef 3/30/07 12:30 AM Page 100 9 Access Wizards, Builders, and Managers Access provides many tools that do a lot of work for developers These tools not only save you time and prevent or minimize errors, but they are also a... wizards, builders, and managers in Access 2007 Because you might be looking for a familiar favorite, items are noted as having been added, enhanced or relocated Although there isn’t an official list, our best count is that Access 2007 includes 46 wizards, 9 builders, and 5 managers — that’s 60 tools designed to streamline and automate common processes for developers and users Access Wizards As you can tell... developers and users Access Wizards As you can tell from the extensive list of enhanced wizards, Access is more user-friendly and automated with each version The following table describes 57 wizards, including 11 that were replaced or removed from Access 2007 The status column indicates changes between Access 2003 and 2007 Although there is some overlap, the main difference between enhanced and improved is . ERROR _ACCESS_ DENIED As Long = 5& Const ERROR_BADDB As Long = 100 9& Const ERROR_BADKEY As Long = 101 0& Const ERROR_CANTOPEN As Long = 101 1& Const ERROR_CANTREAD As Long = 101 2& Const. changes to some of the VBA commands to be in concert with the new controls such as the Ribbon instead of a menu. 101 0 Appendix J: Access Wizards, Builders, and Managers 47033bapp10.qxd:WroxProgRef. ACL Dacl As ACL End Type 100 7 Appendix I: Windows Registry Information 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 100 7 47033bapp09.qxd:WroxProgRef 3/30/07 12:30 AM Page 100 8 Access Wizards, Builders, and

Ngày đăng: 09/08/2014, 12:22

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan