Shellexecute

Gsquad Messages postés 40 Date d'inscription vendredi 23 septembre 2005 Statut Membre Dernière intervention 10 mai 2006 - 10 mai 2006 à 12:08
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 - 10 mai 2006 à 17:40
Bon j'ai un souci avec shellexecute

j'ai lu presque tout les messages sur le sujet du forum mais je ne trouva pas mon erreur
j'ai bien déclaré ma function dans un module

Public declare function Shellexecute ...

ma constante Sw_shownormal est bien a 1

voici ma ligne
shellexecute(me.HWnd,"open","D:\a.pdf",vbnullstring, "D:", Sw_shownormal)

et il me dit
hWnd n'est pas un menbre de Form1 ???

j'ai du oublier un truc mais je ne vois pas quoi ???

ça fais deux jours que je me casse la tete dessus !!!

14 réponses

cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
10 mai 2006 à 12:38
0
Gsquad Messages postés 40 Date d'inscription vendredi 23 septembre 2005 Statut Membre Dernière intervention 10 mai 2006
10 mai 2006 à 12:44
j'ai bien regardé les différents sources et reponses du forum
j'ai verifié avec ce que j'ai ecrit mais pas de diff

et il me mets toujours

HWnd n'est pas un Membre de Form1

c'est pour ça que je ne comprend mon code est quasi identique a ceux qui marche !!!
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
10 mai 2006 à 13:00
Vb6 ou .net ?
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
10 mai 2006 à 13:08
oublie ce parametre, colles un 0 et voila....

Es-tu bien en VB6 ?
as tu bien mis cette ligne de code dans le code de ta Form ?

Renfield
Admin CodeS-SourceS - MVP Visual Basic
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Gsquad Messages postés 40 Date d'inscription vendredi 23 septembre 2005 Statut Membre Dernière intervention 10 mai 2006
10 mai 2006 à 13:35
je suis en .net
mais meme avec 0 ca plante plus mais ça marche pas !!! il me fait rien !!!
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
10 mai 2006 à 13:39
Un simple Process.Start("D:\a.pdf") ira
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
10 mai 2006 à 13:48
le réglement est pourtant clair
merci de préciser le langage utilisé !

résultat : la réponse vient plus tard, et tu est bloqué pendant un temps.

http://codyx.org/snippet_ouvrir-document-lancer-executable_25.aspx

Renfield
Admin CodeS-SourceS - MVP Visual Basic
0
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
10 mai 2006 à 17:17
Bonjour,

A mon avis : il faut lancer adobe et non ton fichier pdf qui lui doit être passé en argument

-- Pourquoi faire simple quand on peut faire compliquer --
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
10 mai 2006 à 17:30
Eldim, cela fonctionne pour un fichier (testé sous 2005 mais sous 2003 sa doit etre pareil je ne sais plus)
0
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
10 mai 2006 à 17:33
ah ... je ne pense pas...,
sinon je peux mettre mon code de shellexecute pour 2003 :

#Region " Constantes "



Public
Const SW_HIDE
As
Short = 0



Public
Const SW_SHOWNORMAL
As
Short = 1
' Restores Window if Minimized or



'Minimized



Public
Const SW_SHOWMINIMIZE
As
Short = 2



' Maximized



Public
Const SW_SHOWMAXIMIZE
As
Short = 3



'NoActivate



Public
Const SW_SHOWNOACTIVE
As
Short = 4


#
End
Region


#
Region " API "



Private
Declare
Function ShellExecute
Lib "shell32.dll"
Alias "ShellExecuteA" _


(
ByVal hwnd
As
Integer,
ByVal lpOperation
As
String,
ByVal lpFile
As
String, _



ByVal lpParameters
As
String,
ByVal lpDirectory
As
String,
ByVal nShowCmd
As
Integer) _



As
Integer



Private
Declare
Function FindExecutable
Lib "shell32.dll"
Alias "FindExecutableA" _


(
ByVal lpFile
As
String,
ByVal lpDirectory
As
String,
ByVal lpResult
As
String)
As
Integer


#
End
Region



Public
Const csExe$ = ".exe"



Public
Sub sbLanceFichier(
ByVal hWnd
As
Integer,
ByVal Fichier
As
String, _



Optional
ByVal bMax
As
Boolean =
False,
Optional
ByVal typAff
As
Short = SW_SHOWNORMAL, _



Optional
ByVal bWait
As
Boolean =
False)



Try



'sbVerifiFichier(Fichier)



Dim RetVal
As
Integer, D
As
String



Dim Ext
As
String



Try


Ext = System.IO.Path.GetExtension(Fichier$)



Catch



Try



Dim St
As Microsoft.VisualBasic.AppWinStyle



Select
Case typAff



Case SW_SHOWNORMAL


St = AppWinStyle.NormalFocus



Case SW_HIDE


St = AppWinStyle.Hide



Case SW_SHOWMAXIMIZE


St = AppWinStyle.MaximizedFocus



Case SW_SHOWMINIMIZE


St = AppWinStyle.MinimizedFocus



Case SW_SHOWNOACTIVE


St = AppWinStyle.NormalNoFocus



End
Select


Shell(Fichier, St,
True)



Exit
Sub



Catch



End
Try



End
Try



If Ext <> csExe
And Ext <> ""
Then


D = System.IO.Path.GetDirectoryName(Fichier)


modProcess.sbCheckLan(D)



Dim Rep
As
String, SH
As
Short = SW_SHOWNORMAL



If bMax
Then


SH = SW_SHOWMAXIMIZE



ElseIf typAff <> SW_SHOWNORMAL
Then


SH = typAff



End
If



Dim Exec
As
String =
New
String(Chr(0), 255)


RetVal = FindExecutable(Fichier, Rep, Exec)



If RetVal > 32
Or Trim$(Exec) <> ""
Then



If Rep
Is
Nothing
Then


Rep = Left(Fichier, 3)



End
If


Exec = Left(Exec, InStr(Exec, Chr(0)) - 1)



If
Not bWait
Then


ShellExecute(hWnd, "open", Exec, Fichier, _


Rep, SH)



Else



'If Trim$(Exec) <> "" AndAlso Trim$(Exec) <> Trim$(Fichier) Then



' Exec += " " & Fichier



'End If



'Exec = """" & Exec & """"



'Shell(Exec, SH, True)


modProcess.sbShell(Exec, Fichier, SH)



End
If



End
If



ElseIf Ext <> ""
Then


modProcess.sbCheckLan(Fichier)



'Shell(Fichier, AppWinStyle.NormalFocus)


sbShell(Fichier, , typAff)



Else



'Shell("explorer.exe /e," & Fichier, AppWinStyle.NormalFocus)


sbShell("explorer.exe", "/e,""" & Fichier & """", typAff)



End
If



Catch ex
As Exception


gMsg.sbMsgCr(ex.Message, "modShell.sbLanceFichier")



End
Try



End
Sub

-- Pourquoi faire simple quand on peut faire compliquer --
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
10 mai 2006 à 17:35
il ne faut pas lancer adobe.... sauf si tu souhaite, au final, laancer adobe ^^
acrobat reader n'est pas forcément le visualisateur de Pdf par defaut du User, et n'est peut etre pas installé...

en lancant le fichier pdf, on respecte les preferences du User

Renfield
Admin CodeS-SourceS - MVP Visual Basic
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
10 mai 2006 à 17:38
Je confirme sous 2003 et 2005
Process.Start("c:\tonfichier.xxx") ouvre bien le fichier 'tonfichier.xxx' avec le programme lui étant associé.
0
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
10 mai 2006 à 17:39
c'est pourquoi il faut utiliser un shellexecute et un findexecutable ducoup ça roule

-- Pourquoi faire simple quand on peut faire compliquer --
0
cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
10 mai 2006 à 17:40
ok willi bien vu

-- Pourquoi faire simple quand on peut faire compliquer --
0
Rejoignez-nous