OVH Cloud OVH Cloud

Suppression d'une ligne

2 réponses
Avatar
jp
J'utilise un fichier ini et j'arrive a ecrire ou modifier les lignes
parametres, mais je ne sais pas supprimer une ligne parametre.


Je souhaite le faire directement sans avoir a lire le fichier et le
reecrire.

Auriez vous une idées


merci

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As
String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As
Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

2 réponses

Avatar
François Picalausa
Bonjour/soir,

Voici ce qu'ile st indiqué dans la documentation de
WritePrivateProfileString :
lpKeyName [...] If this parameter is NULL, the entire section, including all
entries within the section, is deleted.

lpString [...] If this parameter is NULL, the key pointed to by the
lpKeyName parameter is deleted.

Exemple d'utilisation:

Sub RemoveIniKey(strFile As String, strSection As String, strKey As String)
WritePrivateProfileString strSection, strKey, vbNullString, strFile
End Sub

Sub RemoveIniSection(strFile As String, strSection As String)
WritePrivateProfileString strSection, vbNullString, vbNullString,
strFile
End Sub

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com


"jp" a écrit dans le message de
news:ems$
J'utilise un fichier ini et j'arrive a ecrire ou modifier les lignes
parametres, mais je ne sais pas supprimer une ligne parametre.


Je souhaite le faire directement sans avoir a lire le fichier et le
reecrire.

Auriez vous une idées


merci

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As
String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32"
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As
String, ByVal lpKeyName As
Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Avatar
jp
C'est super,

Je te remercie beaucoup

J.Philippe...

"François Picalausa" a écrit dans le message de
news:
Bonjour/soir,

Voici ce qu'ile st indiqué dans la documentation de
WritePrivateProfileString :
lpKeyName [...] If this parameter is NULL, the entire section, including


all
entries within the section, is deleted.

lpString [...] If this parameter is NULL, the key pointed to by the
lpKeyName parameter is deleted.

Exemple d'utilisation:

Sub RemoveIniKey(strFile As String, strSection As String, strKey As


String)
WritePrivateProfileString strSection, strKey, vbNullString, strFile
End Sub

Sub RemoveIniSection(strFile As String, strSection As String)
WritePrivateProfileString strSection, vbNullString, vbNullString,
strFile
End Sub

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com


"jp" a écrit dans le message de
news:ems$
> J'utilise un fichier ini et j'arrive a ecrire ou modifier les lignes
> parametres, mais je ne sais pas supprimer une ligne parametre.
>
>
> Je souhaite le faire directement sans avoir a lire le fichier et le
> reecrire.
>
> Auriez vous une idées
>
>
> merci
>
> Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
> "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
> lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As
> String, ByVal nSize As Long, ByVal lpFileName As String) As Long
>
> Private Declare Function WritePrivateProfileString Lib "kernel32"
> Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As
> String, ByVal lpKeyName As
> Any, ByVal lpString As Any, ByVal lpFileName As String) As Long