OVH Cloud OVH Cloud

pb avec le type string

1 réponse
Avatar
Titeuf
j'ai mes deux fonctions suivantes
regardez la ligne debug.print normalement il doit me retourner le contenu de
sDesktop et "dfdfgdfg"
mais il ne me retourne que le contenu de sDesktop
que j'essais d'afficher dans le debug ou autre comme msgbox ou caption je
n'ai à chaque fois que sDesktop il ne prend pas la suite !
pourquoi la chaine qui suit sDesktop est zapée ?
merci


Public Sub MakeShortcut(sTarget As String, sNameShortcut As String,
sIconLocation As String, sArgument As String)

Dim WshShell As New WshShell
Dim oShellLink As WshShortcut
Dim sDesktop As String

sDesktop = SysFolder(0) 'chemin du bureau

debug.print sDesktop & "dfdfgdfg"

Set oShellLink = WshShell.CreateShortcut(sDesktop & "\" & sNameShortcut
& ".lnk") 'créer instance

With oShellLink
.TargetPath = sTarget
.WindowStyle = 1
.IconLocation = sIconLocation
.Arguments = sArgument
.Save
End With

'détruit les objets
Set WshShell = Nothing
Set oShellLink = Nothing

End Sub

Public Function SysFolder(iFolder As Integer) As String

'Fonction retournant le chemin des dossiers systèmes

If iFolder = 0 Then 'bureau
SysFolder = GetRegistryValue(HKCU,
"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders",
"Desktop")
End If

End Function

1 réponse

Avatar
ng
Salut,

Peut être que ta chaine sDesktop est terminée par un caractère null, ce qui
stoppe l'interprétation de la chaine.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



Titeuf a écrit :

j'ai mes deux fonctions suivantes
regardez la ligne debug.print normalement il doit me retourner le
contenu de sDesktop et "dfdfgdfg"
mais il ne me retourne que le contenu de sDesktop
que j'essais d'afficher dans le debug ou autre comme msgbox ou
caption je n'ai à chaque fois que sDesktop il ne prend pas la suite !
pourquoi la chaine qui suit sDesktop est zapée ?
merci


Public Sub MakeShortcut(sTarget As String, sNameShortcut As String,
sIconLocation As String, sArgument As String)

Dim WshShell As New WshShell
Dim oShellLink As WshShortcut
Dim sDesktop As String

sDesktop = SysFolder(0) 'chemin du bureau

debug.print sDesktop & "dfdfgdfg"

Set oShellLink = WshShell.CreateShortcut(sDesktop & "" &
sNameShortcut & ".lnk") 'créer instance

With oShellLink
.TargetPath = sTarget
.WindowStyle = 1
.IconLocation = sIconLocation
.Arguments = sArgument
.Save
End With

'détruit les objets
Set WshShell = Nothing
Set oShellLink = Nothing

End Sub

Public Function SysFolder(iFolder As Integer) As String

'Fonction retournant le chemin des dossiers systèmes

If iFolder = 0 Then 'bureau
SysFolder = GetRegistryValue(HKCU,
"SoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell
Folders", "Desktop")
End If

End Function