Migration VBA de 32 en 64 bits pour Excel Access Outlook Word Macro

Le code VBA qui a été développé sur une installation Windows 32 bits peut ne pas fonctionner s’il s’exécute sur une version 64 bits. Nous allons vous donner les éléments pour modifier le code et pour faire fonctionner le programme à la fois sur 32 et 64 bits.

Comment savoir quelle version de Windows est sur mon ordinateur ?

Pour déterminer si votre ordinateur exécute une version de Windows en 32 ou 64 bits, veuillez appliquer ce qui suit :

Cliquez sur le bouton Démarrer (logo Windows en bas à gauche de votre écran)logo-windows

Cliquez ensuite sur Paramètres / Système / à propos de

Vous avez l’information du système d’exploitation à la rubrique Type de système : systeme-exploitation-windows-32-64-bit

Comment migrer un fichier Excel Access de 32 en 64 bits

Vous nous confiez votre fichier et/ou base de données pour effectuer la modification. Vous réglez à la fin de la prestation quand vous avez validé le fonctionnement de vos fichiers.

Contacter nos spécialistes Excel VBA Access

Nous sommes à votre disposition pour toutes questions ou pour vous adresser une proposition commerciale pour votre projet.

Pourquoi le code Visual Basic fonctionne en 32 bit et non en 64 bits ?

Certains codes font appels à des bibliothèques qui permettent d’échanger avec le système d’exploitation de l’ordinateur, de gérer les fenêtres, les contrôles, le registre Windows … Dans ces cas là, votre programme VBA fait appel à des fichiers DLL. Pour utiliser ces fonctionnalités dans le VBA, l’appel des APIS s’effectue via l’instruction Declare.

Si vous utilisez un système sous 64 bits, les commandes Declare ne sont pas compilées dans VBA 64 bits si elles n’ont pas été identifiées comme sûres pour 64 bits à l’aide de l’ attribut PtrSafe .

Sans la mention PtrSafe, la présence de l’ instruction Declare dans un système 64 bits provoque une erreur de compilation.

Pour que le code fonctionne pour toutes les versions d’Office, il faut utiliser une combinaison des constantes conditionnelles du compilateur : VBA7 et Win64.

VBA7 détermine si le code s’exécute dans la version 7 de l’éditeur VB (version VBA livrée dans Office 2010+).

Win64 détermine quelle version (32 bits ou 64 bits) d’Office est en cours d’exécution.

#If VBA7 Then
‘le code fonctionne sous VBA7 (2010 ou suivante).
#If Win64 Then
‘Le code fonctionne sous version 64 bit de Microsoft
#Else
‘Le code fonctionne sous version 32 bit de Microsoft
#End If

#Else
‘Le code fonctionne sous VBA6 (2007 or antérieure).
#End If

En pratique le code s’écrira de la manière suivante :

#If VBA7=1 and Win64=1 Then
Declare PtrSafe Function GetSystemMenu Lib “user32” (ByVal hwnd As Long, ByVal bRevert As Long) As Long
#Else
Declare Function GetSystemMenu Lib “user32” (ByVal hwnd As Long, ByVal bRevert As Long) As Long
#End If

Comment passer de Excel 32 bits à 64 bits ?

En fonction du code qui a été utilisé pour automatiser les fichiers, le passage de 32 en 64 bit peut se faire avec plus ou moins de difficulté.

Si la programmation n’utilise pas l’appel d’API, aucune action ne sera requise sinon, il faudra modifier les déclarations de fonction comme présenter dans la suite de l’article.

Si vous rencontrez des difficultés à migrer vos fichiers, nous sommes à votre disposition pour vous accompagner, veuillez nous contacter.

Nous pouvons vous accompagner à gérer le changement via une formation VBA.

Erreurs lors du passage de 32 en 64 bits avec le VBA Excel Access

Les erreurs rencontrées lors de l’utilisation d’un fichier conçu pour 32 bit qui est utilisé sur une version de windows 64 bit sont les suivantes :

  • Dans l’éditeur Visual Bacic des lignes en en-tête de module apparaissent en rouge
  • Dans Access : des # apparaissent à la place de date
  • Une partie du code ne fonctionne pas

Compatibilité des codes VBA 32 et 64 bits et migration

Pour chaque déclaration de fonction en 32 bit la conversion en 64 bits est présentée dans les lignes suivantes. Ces codes sont à intégrer dans la formule conditionnelle qui teste la version de Microsoft (présentée ci-dessous). Cette condition est à placer en tête de module VBA, pour que le code soit compatible pour les 2 versions.

Cette modification de code assurera la compatibilité 32 bit et 64 bit.

Pour trouver la ligne dont vous avez besoin, tapez CTRL+F puis taper le nom de la fonction.

Declare PtrSafe Function CallNextHookEx Lib “user32” (ByVal hHook As LongPtr, ByVal ncode As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr

Declare Function CallNextHookEx Lib “user32” (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long

Declare PtrSafe Function GetModuleHandle Lib “kernel32” Alias “GetModuleHandleA” (ByVal lpModuleName As String) As LongPtr

Declare Function GetModuleHandle Lib “kernel32” Alias  “GetModuleHandleA” (ByVal lpModuleName As String) As Long

Declare PtrSafe Function SetWindowsHookEx Lib “user32” Alias “SetWindowsHookExA” (ByVal idHook As Long, ByVal lpfn As LongPtr, ByVal hmod As LongPtr, ByVal dwThreadId As Long) As LongPtr

Declare Function SetWindowsHookEx Lib “user32” Alias “SetWindowsHookExA” (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long

Declare PtrSafe Function UnhookWindowsHookEx Lib “user32” (ByVal hHook As LongPtr) As Long

Declare Function UnhookWindowsHookEx Lib “user32” (ByVal hHook As Long) As Long

Declare PtrSafe Function SendDlgItemMessage Lib “user32” Alias “SendDlgItemMessageA” (ByVal hDlg As LongPtr, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr

Declare Function SendDlgItemMessage Lib “user32” Alias “SendDlgItemMessageA” (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare PtrSafe Function GetClassName Lib “user32” Alias “GetClassNameA” (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Declare Function GetClassName Lib “user32” Alias “GetClassNameA” (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Declare PtrSafe Function GetCurrentThreadId Lib “kernel32” () As Long

Declare Function GetCurrentThreadId Lib “kernel32” () As Long

Declare PtrSafe Function ShellExecute Lib “shell32.dll” Alias “ShellExecuteA” (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr

Declare Function ShellExecute Lib “shell32.dll” Alias “ShellExecuteA” (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Declare PtrSafe Function SHGetPathFromIDList Lib “shell32.dll” Alias “SHGetPathFromIDListA” (ByVal pidl As LongPtr, ByVal pszPath As String) As Boolean

Declare Function SHGetPathFromIDList Lib “shell32.dll” Alias “SHGetPathFromIDListA” (ByVal pidl As Long, ByVal pszPath As String) As Boolean

Declare PtrSafe Function SHBrowseForFolder Lib “shell32.dll” Alias “SHBrowseForFolderA” (lpBrowseInfo As BROWSEINFO) As LongPtr

Declare Function SHBrowseForFolder Lib “shell32.dll” Alias “SHBrowseForFolderA” (lpBrowseInfo As BROWSEINFO) As Long

Declare PtrSafe Function OpenClipboard Lib “user32” (ByVal hwnd As LongPtr) As Long

Declare Function OpenClipboard Lib “user32” (ByVal hwnd As Long) As Long

Declare PtrSafe Function CloseClipboard Lib “user32” () As Long

Declare Function CloseClipboard Lib “user32” () As Long

Declare PtrSafe Function EmptyClipboard Lib “user32” () As Long

Declare Function EmptyClipboard Lib “user32” () As Long

Declare PtrSafe Function VirtualAlloc Lib “kernel32” (ByVal Address As LongPtr, ByVal Size As LongPtr, ByVal AllocationType As Long, ByVal Protect As LongPtr) As LongPtr

Declare Function VirtualAlloc Lib “kernel32” (ByVal Address As Long, ByVal Size As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long

Declare PtrSafe Function GetModuleHandleA Lib “kernel32” (ByVal ProcName As String) As Long

Declare Function GetModuleHandleA Lib “kernel32” (ByVal ProcName As String) As Long

#If VBA7 Then

Declare PtrSafe Function GetOpenFileName Lib “comdlg32.dll” Alias “GetOpenFileNameA (pOpenfilename As OPENFILENAME) As Long

Type OPENFILENAME

lStructSize As Long

hwndOwner As LongPtr

hInstance As LongPtr

lpstrFilter As String

lpstrCustomFilter As String

nMaxCustFilter As Long

nFilterIndex As Long

lpstrFile As String

nMaxFile As Long

lpstrFileTitle As String

nMaxFileTitle As Long

lpstrInitialDir As String

lpstrTitle As String

flags As Long

nFileOffset As Integer

nFileExtension As Integer

lpstrDefExt As String

lCustData As LongPtr

lpfnHook As LongPtr

lpTemplateName As String

End Type

#Else

Declare Function GetOpenFileName Lib “comdlg32.dll” Alias “GetOpenFileNameA” (pOpenfilename As OPENFILENAME) As Long

Type OPENFILENAME

lStructSize As Long

hwndOwner As Long

hInstance As Long

lpstrFilter As String

lpstrCustomFilter As String

nMaxCustFilter As Long

nFilterIndex As Long

lpstrFile As String

nMaxFile As Long

lpstrFileTitle As String

nMaxFileTitle As Long

lpstrInitialDir As String

lpstrTitle As String

flags As Long

nFileOffset As Integer

nFileExtension As Integer

lpstrDefExt As String

lCustData As Long

lpfnHook As Long

lpTemplateName As String

End Type

#End If

Declare PtrSafe Function GetSaveFileName Lib “comdlg32.dll” Alias “GetSaveFileNameA” (pOpenfilename As OPENFILENAME) As Long

Declare Function GetSaveFileName Lib “comdlg32.dll” Alias “GetSaveFileNameA” (pOpenfilename As OPENFILENAME) As Long

Declare PtrSafe Function GetSystemMetrics Lib “USER32” (ByVal nIndex As Long) As Long

Declare Function GetSystemMetrics Lib “USER32” (ByVal nIndex As Long) As Long

Declare PtrSafe Function aht_apiGetOpenFileName Lib “comdlg32.dll” Alias “GetOpenFileNameA” (OFN As tagOPENFILENAME) As Boolean

Declare Function aht_apiGetOpenFileName Lib “comdlg32.dll” Alias “GetOpenFileNameA” (OFN As tagOPENFILENAME) As Boolean

Declare PtrSafe Function apiGetLocaleInfo Lib “kernel32” Alias “GetLocaleInfoA” (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

Declare Function apiGetLocaleInfo Lib “kernel32” Alias “GetLocaleInfoA” (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

Declare PtrSafe Function LoadLibraryRegister Lib “kernel32” Alias “LoadLibraryA” (ByVal lpLibFileName$) As Long

Declare Function LoadLibraryRegister Lib “kernel32” Alias “LoadLibraryA” (ByVal lpLibFileName$) As Long

Declare PtrSafe Function SetDllDirectoryA Lib “kernel32” (ByVal lpPathName As String) As Long

Declare Function SetDllDirectoryA Lib “kernel32” (ByVal lpPathName As String) As Long

Declare PtrSafe Function GetProcAddressRegister Lib “kernel32” Alias “GetProcAddress” (ByVal hModule&, ByVal lpProcName$) As Long

Declare Function GetProcAddressRegister Lib “kernel32” Alias “GetProcAddress” (ByVal hModule&, ByVal lpProcName$) As Long

Declare PtrSafe Function CreateThreadForRegister Lib “kernel32” Alias  “CreateThread” (lpThreadAttributes As Any, ByVal dwStackSize&, ByVal lpStartAddress&,  ByVal lpparameter&, ByVal dwCreationFlags&, ThreadID&) As Long

Declare Function CreateThreadForRegister Lib “kernel32” Alias  “CreateThread” (lpThreadAttributes As Any, ByVal dwStackSize&, ByVal lpStartAddress&, ByVal lpparameter&, ByVal dwCreationFlags&, ThreadID&) As Long

Declare PtrSafe Function DeleteUrlCacheEntry Lib “Wininet.dll” Alias “DeleteUrlCacheEntryA” ( ByVal lpszUrlName As String) As Long

Declare Function DeleteUrlCacheEntry Lib “Wininet.dll” Alias “DeleteUrlCacheEntryA” ( ByVal lpszUrlName As String ) As Long

Declare PtrSafe Sub Sleep Lib “kernel32” (ByVal dwMilliseconds As LongPtr)

Declare Sub Sleep Lib “kernel32” (ByVal dwMilliseconds As Long)

#If VBA7 Then
#If Win64 Then
Declare PtrSafe Function SetWindowLongPtr Lib “USER32” Alias “SetWindowLongPtrA” (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#Else
Declare Function SetWindowLongPtr Lib “USER32” Alias “SetWindowLongA” (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#End If
#Else
Declare Function SetWindowLong Lib “USER32” Alias “SetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
#End If

#If VBA7 Then
#If Win64 Then
Declare PtrSafe Function GetWindowLongPtr Lib “USER32” Alias “GetWindowLongPtrA” (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
#Else
Declare PtrSafe Function GetWindowLongPtr Lib “USER32” Alias “GetWindowLongA” (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
#End If
#Else
Declare Function GetWindowLong Lib “USER32” Alias “GetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long) As Long
#End If

Declare PtrSafe Function SetWindowPos Lib “user32” (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Declare Function SetWindowPos Lib “user32” (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

#If VBA7 Then
#If Win64 Then
Declare PtrSafe Function GetWindowLongPtr Lib “user32” Alias “GetWindowLongPtrA” (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
#Else
Declare PtrSafe Function GetWindowLongPtr Lib “user32” Alias “GetWindowLongA” (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
#End If
#Else
Declare Function GetWindowLong Lib “USER32” Alias “GetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long) As Long
#End If

Declare PtrSafe Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

Declare Function FindWindow Lib “user32” Alias “FindWindowA” ( ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare PtrSafe Function SetWindowsHookEx Lib “user32” Alias “SetWindowsHookExA” (ByVal idHook As Long, ByVal lpfn As LongPtr, ByVal hmod As LongPtr, ByVal dwThreadId As Long) As LongPtr

Declare Function SetWindowsHookEx Lib “user32” Alias “SetWindowsHookExA” ( ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long

Declare PtrSafe Function CallNextHookEx Lib “user32” (ByVal hHook As LongPtr, ByVal ncode As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr

Declare Function CallNextHookEx Lib “user32” ( ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long

Declare PtrSafe Function UnhookWindowsHookEx Lib “user32” (ByVal hHook As LongPtr) As Long

Declare Function UnhookWindowsHookEx Lib “user32” ( ByVal hHook As Long) As Long

Declare PtrSafe Function PostMessage Lib “user32.dll” Alias “PostMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function PostMessage Lib “user32.dll” Alias “PostMessageA” ( ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare PtrSafe Function WindowFromPoint Lib “user32” (ByVal xPoint As Long, ByVal yPoint As Long) As Long

Declare Function WindowFromPoint Lib “user32” ( ByVal xPoint As Long, ByVal yPoint As Long) As Long

Declare PtrSafe Function ReadFile Lib “kernel32” ( ByVal hFile As LongPtr, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As OVERLAPPED ) As Long

Declare Function ReadFile Lib “kernel32” ( ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any ) As Long

Declare PtrSafe Function CommDlgExtendedError Lib “comdlg32.dll” () As LongLong

Declare Function CommDlgExtendedError Lib “comdlg32” () As Long

Declare PtrSafe Function GetDeviceCaps Lib “gdi32” (ByVal hDC As LongPtr, ByVal Index As Long) As Long

Declare Function GetDeviceCaps Lib “Gdi32” (ByVal hDC As Long, ByVal Index As Long) As Long

Declare PtrSafe Sub CopyMemory Lib “kernel32.dll” Alias “RtlMoveMemory” (ByRef xDest As Any, ByRef xSource As Any, ByVal nbytes As LongPtr)

Declare Sub CopyMemory Lib “kernel32.dll” Alias “RtlMoveMemory” (ByRef xDest As Any, ByRef xSource As Any, ByVal nbytes As Long)

Declare PtrSafe Function fnGetComputerName Lib “kernel32” Alias “GetComputerNameA” (ByVal lpBuffer As String, nSize As Long) As Long

Declare Function fnGetComputerName Lib “kernel32” Alias “GetComputerNameA” (ByVal lpBuffer As String, nSize As Long) As Long

Declare PtrSafe Function GetComputerNameEx Lib “kernel32” Alias “GetComputerNameExA” (ByVal NameType As Long, ByVal lpBuffer As String, nSize As Long) As Long

Declare Function GetComputerNameEx Lib “kernel32” Alias “GetComputerNameExA” (ByVal NameType As Long, ByVal lpBuffer As String, nSize As Long) As Long

Declare PtrSafe Function GetLastError Lib “kernel32” () As Long

Declare Function GetLastError Lib “kernel32” () As Long

Declare PtrSafe Function GetSystemDefaultLangID Lib “kernel32” () As Integer

Declare Function GetSystemDefaultLangID Lib “kernel32” () As Integer

Declare PtrSafe Sub GetSystemTime Lib “kernel32” (ByRef lpSystemTime As SYSTEMTIME)

Declare Sub GetSystemTime Lib “kernel32” (lpSystemTime As SYSTEMTIME)

Declare PtrSafe Function GetTimeZoneInformation Lib “kernel32” (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Declare Function GetTimeZoneInformation Lib “kernel32” (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Declare PtrSafe Function GetVersionEx Lib “kernel32” Alias “GetVersionExA” (lpVersionInformation As OSVERSIONINFO) As Long

Declare Function GetVersionEx Lib “kernel32” Alias “GetVersionExA” (lpVersionInformation As OSVERSIONINFO) As Long

Declare PtrSafe Function QueryPerformanceCounter Lib “kernel32” (X As Currency) As Boolean

Declare Function QueryPerformanceCounter Lib “Kernel32” (X As Currency) As Boolean

Declare PtrSafe Function QueryPerformanceFrequency Lib “kernel32” (X As Currency) As Boolean

Declare Function QueryPerformanceFrequency Lib “Kernel32” (X As Currency) As Boolean

Declare PtrSafe Function VerLanguageName Lib “kernel32” Alias “VerLanguageNameA” (ByVal wLang As Long, ByVal szLang As String, ByVal nSize As Long) As Long

Declare Function VerLanguageName Lib “kernel32” Alias “VerLanguageNameA” (ByVal wLang As Long, ByVal szLang As String, ByVal nSize As Long) As Long

Declare PtrSafe Function WNetGetUser Lib “mpr.dll” Alias “WNetGetUserA” (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

Declare Function WNetGetUser Lib “Mpr” Alias “WNetGetUserA” (ByVal lpName As Any, ByVal lpUserName As String, lpnLength As Long) As Long

Declare PtrSafe Function Shell_NotifyIcon Lib “shell32” Alias “Shell_NotifyIconA” (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Declare Function Shell_NotifyIcon Lib “shell32” Alias “Shell_NotifyIconA” (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

#If VBA7 Then

Declare PtrSafe Function SHGetSpecialFolderLocation Lib _

“shell32.dll” (ByVal hwndOwner As LongPtr, ByVal nFolder As Long, _

pidl As ITEMIDLIST) As LongPtr

Type SHITEMID

cb As LongPtr

abID As Byte

End Type

#Else

Declare Function SHGetSpecialFolderLocation Lib _

“shell32.dll” (ByVal hwndOwner As Long, ByVal nFolder As Long, _

pidl As ITEMIDLIST) As Long

Type SHITEMID

cb As Long

abID As Byte

End Type

#End If

Type ITEMIDLIST

mkid As SHITEMID

End Type

Declare PtrSafe Function CreateIcon Lib “user32” (ByVal hInstance As LongPtr, ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Byte, ByVal nBitsPixel As Byte, lpANDbits As Byte, lpXORbits As Byte) As LongPtr

Declare Function CreateIcon Lib “user32” (ByVal hInstance As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Byte, ByVal nBitsPixel As Byte, lpANDbits As Byte, lpXORbits As Byte) As Long

Declare PtrSafe Function DestroyIcon Lib “user32” (ByVal hIcon As LongPtr) As Long

Declare Function DestroyIcon Lib “user32” (ByVal hIcon As Long) As Long

Declare PtrSafe Function DispatchMessage Lib “user32” Alias “DispatchMessageA” (lpMsg As MSG) As LongPtr

Declare Function DispatchMessage Lib “user32” Alias “DispatchMessageA” (lpMsg As MSG) As Long

Declare PtrSafe Function GetDC Lib “user32” (ByVal hwnd As LongPtr) As LongPtr

Declare Function GetDC Lib “user32” (ByVal hwnd As Long) As Long

Declare PtrSafe Function PeekMessage Lib “user32” Alias “PeekMessageA” (lpMsg As MSG, ByVal hwnd As LongPtr, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long

Declare Function PeekMessage Lib “user32” Alias “PeekMessageA” (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long

Declare PtrSafe Function ReleaseDC Lib “user32.dll” (ByVal hwnd As LongPtr, ByVal hDC As LongPtr) As Long

Declare Function ReleaseDC Lib “user32” (ByVal hwnd As Long, ByVal hDC As Long) As Long

Declare PtrSafe Function SetForegroundWindow Lib “user32.dll” (ByVal hwnd As LongPtr) As LongPtr

Declare Function SetForegroundWindow Lib “user32” (ByVal hwnd As Long) As Long

Declare PtrSafe Function TranslateMessage Lib “user32” (lpMsg As MSG) As Long

Declare Function TranslateMessage Lib “user32” (lpMsg As MSG) As Long

Declare PtrSafe Function bind Lib “ws2_32.dll” (ByVal hSocket As LongPtr, ByRef Name As SOCK_ADDR, ByVal NameLen As Long) As Long

Declare Function bind Lib “wsock32” (ByVal sock As Long, addr As SOCK_ADDR, ByVal namelen As Long) As Long

Declare PtrSafe Function closesocket Lib “ws2_32.dll” (ByVal hSocket As LongPtr) As Long

Declare Function closesocket Lib “wsock32” (ByVal sock As Long) As Long

Declare PtrSafe Function connect Lib “ws2_32.dll” (ByVal hSocket As LongPtr, ByRef Name As SOCK_ADDR, ByVal NameLen As Long) As Long

Declare Function connect Lib “wsock32” (ByVal sock As Long, Name As SOCK_ADDR, ByVal namelen As Integer) As Long

Declare PtrSafe Function gethostbyname Lib “ws2_32.dll” (ByVal Name As String) As LongPtr

Declare Function gethostbyname Lib “wsock32” (ByVal hostName As String) As Long

Declare PtrSafe Function htons Lib “ws2_32.dll” (ByVal hostshort As Integer) As Integer

Declare Function htons Lib “wsock32” (ByVal hostshort As Integer) As Integer

Declare PtrSafe Function inet_addr Lib “ws2_32.dll” (ByVal IpAddress As String) As Long

Declare Function inet_addr Lib “wsock32” (ByVal cp As String) As Long

Declare PtrSafe Function ioctlsocket Lib “wsock32.dll” (ByVal s As Long, ByVal cmd As Long, argp As LongPtr) As Long

Declare Function ioctlsocket Lib “wsock32” (ByVal sock As Long, ByVal cmd As Long, argp As Long) As Long

Declare PtrSafe Function listen Lib “ws2_32.dll” (ByVal hSocket As LongPtr, ByVal BackLog As Long) As Long

Declare Function listen Lib “wsock32” (ByVal sock As Long, ByVal backlog As Integer) As Integer

Declare PtrSafe Function recv Lib “ws2_32.dll” (ByVal hSocket As LongPtr, ByRef buffer As Any, ByVal BufferLength As Long, ByVal flags As Long) As Long

Declare Function recv Lib “wsock32” (ByVal sock As Long, buffer As Any, ByVal Length As Long, ByVal flags As Long) As Long

Declare PtrSafe Function send Lib “ws2_32.dll” (ByVal hSocket As LongPtr, ByRef buffer As Any, ByVal BufferLength As Long, ByVal flags As Long) As Long

Declare Function send Lib “wsock32” (ByVal sock As Long, buffer As Any, ByVal Length As Long, ByVal flags As Long) As Long

Declare PtrSafe Function socket Lib “ws2_32.dll” (ByVal AddressFamily As Long, ByVal SocketType As Long, ByVal Protocol As Long) As LongPtr

Declare Function socket Lib “wsock32” (ByVal afinet As Integer, ByVal socktype As Integer, ByVal protocol As Integer) As Long

Declare PtrSafe Function WSAAsyncSelect Lib “wsock32” (ByVal sock As Long, ByVal hwnd As Long, ByVal wMsg As Integer, ByVal lEvent As Long) As Integer

Declare Function WSAAsyncSelect Lib “wsock32” (ByVal sock As Long, ByVal hwnd As Long, ByVal wMsg As Integer, ByVal lEvent As Long) As Integer

Declare PtrSafe Function WSACleanup Lib “ws2_32.dll” () As Long

Declare Function WSACleanup Lib “wsock32” () As Long

Declare PtrSafe Function WSAStartup Lib “ws2_32.dll” (ByVal wVersionRequested As Integer, ByRef lpWSAData As WSA_DATA) As Long

Declare Function WSAStartup Lib “wsock32” (ByVal wVersionRequired As Integer, wsData As WSA_DATA) As Long

Declare PtrSafe Function WSSelect Lib “wsock32” Alias “select” (ByVal nfds As Long, readfds As FD_SET, writefds As FD_SET, exceptfds As FD_SET, timeout As timeval) As Long

Declare Function WSSelect Lib “wsock32” Alias “select” (ByVal nfds As Long, readfds As fd_set, writefds As fd_set, exceptfds As fd_set, timeout As timeval) As Long

Declare PtrSafe Function CloseClipboard Lib “User32” () As LongPtr

Declare Function CloseClipboard Lib “User32” () As Long

#If VBA7 Then
Declare PtrSafe Function DrawMenuBar Lib “user32” (ByVal hWnd As LongPtr) As Long
#Else
Declare Function DrawMenuBar Lib “user32” (ByVal hWnd As Long) As Long
#End If

Declare PtrSafe Function FindWindow Lib “USER32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String)As LongPtr

Declare Function FindWindow Lib “USER32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare PtrSafe Function FindWindowEx Lib “USER32” Alias “FindWindowExA” (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr

Declare Function FindWindowEx Lib “USER32” Alias “FindWindowExA” (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Declare PtrSafe Function GdipCreateBitmapFromFile Lib “GDIPlus” (ByVal filename As LongPtr, bitmap As LongPtr) As LongPtr

Declare Function GdipCreateBitmapFromFile Lib “GDIPlus” (ByVal filename As Long, bitmap As Long) As Long

Declare PtrSafe Function GdipCreateHBITMAPFromBitmap Lib “GDIPlus” (ByVal bitmap As LongPtr, hbmReturn As LongPtr, ByValbackground As Long) As LongPtr

Declare Function GdipCreateHBITMAPFromBitmap Lib “GDIPlus” (ByVal bitmap As Long, hbmReturn As Long, ByVal background As Long) As Long

Declare PtrSafe Function GdipDisposeImage Lib “GDIPlus” (ByVal image As LongPtr) As LongPtr

Declare Function GdipDisposeImage Lib “GDIPlus” (ByVal image As Long) As Long

Declare PtrSafe Function GdiplusShutdown Lib “GDIPlus” (ByVal token As LongPtr) As LongPtr

Declare Function GdiplusShutdown Lib “GDIPlus” (ByVal token As Long) As Long

Declare PtrSafe Function GetClassName Lib “USER32” Alias “GetClassNameA” (ByVal hWnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As LongPtr) As Long

Declare Function GetClassName Lib “USER32” Alias “GetClassNameA” (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Declare PtrSafe Function GetDiskFreeSpaceEx Lib “kernel32” Alias “GetDiskFreeSpaceExA” (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As LongPtr

Declare Function GetDiskFreeSpaceEx Lib “kernel32” Alias “GetDiskFreeSpaceExA” (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long

#If VBA7 Then
Type SHFILEOPSTRUCT
hWnd As LongPtr
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Longptr
sProgress As String
End Type
Declare PtrSafe Function SHFileOperation Lib “shell32.dll” Alias “SHFileOperationA” (lpFileOp As SHFILEOPSTRUCT) As LongPtr
#Else
Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Declare Function SHFileOperation Lib “shell32.dll” Alias “SHFileOperationA” (lpFileOp As SHFILEOPSTRUCT) As Long
#End If

Declare PtrSafe Function GetDesktopWindow Lib “USER32” () As LongPtr

Declare Function GetDesktopWindow Lib “USER32” () As Long

Declare PtrSafe Function GetDriveType Lib “kernel32” Alias “GetDriveTypeA” (ByVal sDrive As String) As LongPtr

Declare Function GetDriveType Lib “kernel32” Alias “GetDriveTypeA” (ByVal sDrive As String) As Long

Declare PtrSafe Function GetExitCodeProcess Lib “kernel32” (ByVal hProcess As LongPtr, lpExitCode As Long) As Long

Declare Function GetExitCodeProcess Lib “kernel32” (ByVal hProcess As Long, lpExitCode As Long) As Long

Declare PtrSafe Function GetForegroundWindow Lib “user32.dll” () As LongPtr

Declare Function GetForegroundWindow Lib “user32.dll” () As Long

Declare PtrSafe Function getFrequency Lib “kernel32” Alias “QueryPerformanceFrequency” (cyFrequency As Currency) As Long

Declare Function getFrequency Lib “kernel32” Alias “QueryPerformanceFrequency” (cyFrequency As Currency) As Long

Declare PtrSafe Function GetKeyState Lib “USER32” (ByVal vKey As Long) As Integer

Declare Function GetKeyState Lib “USER32” (ByVal vKey As Long) As Integer

#If VBA7 Then
Type LASTINPUTINFO
cbSize As LongPtr
dwTime As LongPtr
End Type
Declare PtrSafe Sub GetLastInputInfo Lib “USER32” (ByRef plii As LASTINPUTINFO)
#Else
Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Declare Sub GetLastInputInfo Lib “USER32” (ByRef plii As LASTINPUTINFO)
#End If

Declare PtrSafe Function GetTempPath Lib “kernel32” Alias “GetTempPathA” (ByVal nBufferLength As longptr, ByVal lpbuffer As String) As Long

Declare Function GetTempPath Lib “kernel32” Alias “GetTempPathA” (ByVal nBufferLength As Long, ByVal lpbuffer As String) As Long

Declare PtrSafe Function getTickCount Lib “kernel32” Alias “QueryPerformanceCounter” (cyTickCount As Currency) As Long

Declare Function getTickCount Lib “kernel32” Alias “QueryPerformanceCounter” (cyTickCount As Currency) As Long

Declare PtrSafe Function timeGetTime Lib “winmm.dll” () As Long

Declare Function timeGetTime Lib “winmm.dll” () As Long

Declare PtrSafe Function GetWindow Lib “USER32” (ByVal hWnd As LongPtr, ByVal wCmd As Long) As LongPtr

Declare Function GetWindow Lib “USER32” (ByVal hWnd As Long, ByVal wCmd As Long) As Long

Declare PtrSafe Function SetActiveWindow Lib “user32.dll” (ByVal hWnd As LongPtr) As LongPtr

Declare Function SetActiveWindow Lib “user32.dll” (ByVal hWnd As Long) As Long

Declare PtrSafe Function GetWindowsDirectory& Lib “kernel32” Alias  “GetWindowsDirectoryA” (ByVal lpbuffer As String, ByVal nSize As LongPtr)

Declare Function GetWindowsDirectory& Lib “kernel32” Alias “GetWindowsDirectoryA” (ByVal lpbuffer As String, ByVal nSize As Long)

Declare PtrSafe Function GetWindowText Lib “USER32” Alias “GetWindowTextA” (ByVal hWnd As LongPtr, ByVal lpString As String, ByVal cch As LongPtr) As Long

Declare Function GetWindowText Lib “USER32” Alias “GetWindowTextA” (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Declare PtrSafe Function SetCurrentDirectoryA Lib “kernel32” (ByVal lpPathName As String) As Long

Declare Function SetCurrentDirectoryA Lib “kernel32” (ByVal lpPathName As String) As Long

Declare Function GlobalAlloc Lib “kernel32” (ByVal wFlags As Long, ByVal dwBytes As Long) As Long

Declare PtrSafe Function GlobalAlloc Lib “kernel32” (ByVal wFlags As LongPtr, ByVal dwBytes As LongPtr) As LongPtr

Declare Function GlobalLock Lib “kernel32” (ByVal hMem As Long) As Long

Declare PtrSafe Function GlobalLock Lib “kernel32” (ByVal hMem As LongPtr) As LongPtr

Declare PtrSafe Function InternetGetConnectedState Lib “wininet.dll” (lpdwFlags As LongPtr, ByVal dwReserved As long) As Boolean

Declare Function InternetGetConnectedState Lib “wininet.dll” (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean

Declare PtrSafe Function IsCharAlphaNumericA Lib “USER32” (ByVal byChar As Byte) As Long

Declare Function IsCharAlphaNumericA Lib “USER32” (ByVal byChar As Byte) As Long

Declare Function lstrcpy Lib “kernel32” (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long

Declare PtrSafe Function lstrcpy Lib “kernel32” (ByVal lpString1 As Any, ByVal lpString2 As Any) As LongPtr

Declare PtrSafe Sub mouse_event Lib “user32” (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As LongPtr)

Declare Sub mouse_event Lib “user32” (ByVal dwFlags As Long, ByVal dx As Long,  ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Declare Function SetClipboardData Lib “User32” (ByVal wFormat As Long, ByVal hMem As Long) As Long

Declare PtrSafe Function SetClipboardData Lib “User32” (ByVal wFormat As LongPtr, ByVal hMem As LongPtr) As LongPtr

#If VBA7 Then

Declare PtrSafe Function OleCreatePictureIndirect Lib “oleaut32.dll” (PicDesc As PICTDESC, RefIID As GUID, ByValfPictureOwnsHandle As LongPtr, IPic As IPicture) As LongPtr

Type PICTDESC
Size As Long
Type As Long
hPic As LongPtr
hPal As LongPtr
End Type

#Else

Declare Function OleCreatePictureIndirect Lib “oleaut32.dll” (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle AsLong, IPic As IPicture) As Long

Type PICTDESC
Size As Long
Type As Long
hPic As Long
hPal As Long
End Type

#End If

Declare PtrSafe Function OpenProcess Lib “kernel32” (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPtr

Declare Function OpenProcess Lib “kernel32” (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Declare PtrSafe Function SendMessageA Lib “user32” (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr

Declare Function SendMessageA Lib “user32” (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

#If VBA7 Then
Type BROWSEINFO
hOwner As LongPtr
pidlRoot As LongPtr
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As LongPtr
lParam As LongPtr
iImage As Long
End Type

Declare PtrSafe Function SHBrowseForFolder Lib “shell32.dll” Alias “SHBrowseForFolderA” (lpBrowseInfo As BROWSEINFO) As LongPtr
#Else
Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Declare Function SHBrowseForFolder Lib “shell32.dll” Alias “SHBrowseForFolderA” (lpBrowseInfo As BROWSEINFO) As Long
#End If

Declare PtrSafe Function timeGetTime Lib “winmm.dll” () As Long

Declare Function timeGetTime Lib “winmm.dll” () As Long

Declare Function URLDownloadToFile Lib “urlmon” Alias “URLDownloadToFileA” (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Declare PtrSafe Function URLDownloadToFile Lib “urlmon” Alias “URLDownloadToFileA” (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Declare PtrSafe Function WSAGetLastError Lib “ws2_32.dll” () As Long

Declare Function WSAGetLastError Lib “wsock32” () As Long

Declare PtrSafe Function LoadCursor Lib “user32” Alias “LoadCursorA” (ByVal hInstance As LongPtr, ByVal lpCursorName As Long) As Long

Declare Function LoadCursor Lib “user32” Alias “LoadCursorA” (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

Declare PtrSafe Function SetCursor Lib “user32” (ByVal hCursor As Long) As Long

Declare Function SetCursor Lib “user32” (ByVal hCursor As Long) As Long

S’abonner
Notification pour
guest

0 Commentaires
Commentaires en ligne
Afficher tous les commentaires