----------------------------------------------- DECLARE AND WIN32API January 2024 ----------------------------------------------- CCB 1. THE DECLARE STATEMENT SYNTAX (from dv_foxhelp9.chm): DECLARE [cFunctionType] FunctionName IN LibraryName [AS AliasName] [cParamType1 [@] ParamName1, cParamType2 [@] ParamName2, ...] IN LibraryName Specifies the name of the external shared library containing the function specified with FunctionName. If you specify WIN32API for the LibraryName, Visual FoxPro searches for the 32-bit Windows .dll function in: 1, Kernel32.dll, 2, Gdi32.dll, 3, User32.dll, 4, Mpr.dll, 5, and Advapi32.dll. 2. REFERENCE CODE: There is a small problem, in fact, Visual FoxPro 9.0 (and before) searches for the 32-bit Windows .dll function in: 1, User32.dll, 2, Gdi32.dll, 3, Kernel32.dll, 4, Advapi32.dll, 5, and Mpr.dll. In VFP 9.0 (and before), usually, there is no windows api function in 2 (or more) .dlls, so this is not a big problem. In VFP Advanced (x64), there are some windows api functions in 2 (or more) .dlls. For example, there is a RegOpenKeyExA function in advapi32.dll, and there is a RegOpenKeyExA function in kernel32.dll. Usually, we want to call the RegOpenKeyExA function in advapi32.dll, not in kernel32.dll. So VFP Advanced (x64) has changed it to: Visual FoxPro Advanced searches for the 64-bit Windows .dll function in: 1, Advapi32.dll, 2, User32.dll, 3, Gdi32.dll, 4, Kernel32.dll, 5, and Mpr.dll. 3. REFERENCE WINDOWS APIS: The following windows api functions (Reg*) both in advapi32.dll and kernel32.dll: RegCloseKey RegCreateKeyExA RegCreateKeyExW RegDeleteKeyExA RegDeleteKeyExW RegDeleteTreeA RegDeleteTreeW RegDeleteValueA RegDeleteValueW RegDisablePredefinedCacheEx RegEnumKeyExA RegEnumKeyExW RegEnumValueA RegEnumValueW RegFlushKey RegGetKeySecurity RegGetValueA RegGetValueW RegLoadKeyA RegLoadKeyW RegLoadMUIStringA RegLoadMUIStringW RegNotifyChangeKeyValue RegOpenCurrentUser RegOpenKeyExA RegOpenKeyExW RegOpenUserClassesRoot RegQueryInfoKeyA RegQueryInfoKeyW RegQueryValueExA RegQueryValueExW RegRestoreKeyA RegRestoreKeyW RegSaveKeyExA RegSaveKeyExW RegSetKeySecurity RegSetValueExA RegSetValueExW RegUnLoadKeyA RegUnLoadKeyW Usually, these windows api functions in advapi32.dll will jump to the same name windows api functions in kernel32.dll. In other words, these windows api functions in advapi32.dll is the same as these windows api functions in kernel32.dll. But, it is not always same. For example, the sprintf function in ntdll.dll is not the same as the sprintf function in msvcrt.dll. In fact, the sprintf function in ntdll.dll is simpler, it does not supports some format-control strings such as %f. 4. OTHER: For reference only, there is no guarantees. Any questions or suggestions, please send me an email at ccb2000@163.com. |