Bonjour a tous, J'ai un souci avec une macro qui plante LO à chaque éxecution Je suis sous Windows 7 avec une version LO 4.0.2
Voici le code qui me permet de récupérer le nom du PC par accès à la base de registre. 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 Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" _ (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal lpReserved As Long, _ lpType As Long, _ lpData As String, _ lpcbData As Long) As Long Declare Function RegQueryValueString Lib "advapi32.dll" Alias "RegQueryValueExA" _ (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal dwReserved As Long, _ lpType As Long, _ ByVal lpData As String, _ lpcbData As Long) As Long Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" _ (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal lpReserved As Long, _ lpType As Long, _ ByVal lpData As Long, _ lpcbData As Long) As Long Declare Function RegCloseKeyA Lib "advapi32.dll" Alias "RegCloseKey" _ (ByVal hKey As Long) As Long sub Main Dim NomPC as string Const HKLM = &H80000002 Dim hKey as Long Dim lType as Long Dim cch as Long Dim RetourBR as Long Dim RetourBR1 as Long Dim RetourBR2 as Long Dim RetourBR3 as Long RetourBR = RegOpenKeyEx(HKLM,"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", 0, &H20019, hKey) RetourBR1 = RegQueryValueExNULL(hKey, "ComputerName", 0&, lType, 0&, cch) RetourBR2 = RegQueryValueString(hKey, "ComputerName", 0&, lType, NomPC, cch) RetourBR3 = RegCloseKeyA(hKey) print NomPC End Sub Ce code fonctionne correctement mais plante systèmatiquement LO. Après pas mal d'essais je me suis apperçu que c'est la ligne suivante qui fait planter LO RetourBR2 = RegQueryValueString(hKey, "ComputerName", 0&, lType, NomPC, cch) Merci pour toute aide car là je sèche Sincères Salutations F. SEGUIN -- Envoyez un mail à [email protected] pour savoir comment vous désinscrire Les archives de la liste sont disponibles à http://listarchives.libreoffice.org/fr/users/ Tous les messages envoyés sur cette liste seront archivés publiquement et ne pourront pas être supprimés
