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 à users+help@fr.libreoffice.org 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
Context
- [fr-users] MACRO Plantage à l'éxecution · François SEGUIN
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.