[VB6] ShellExecute

Résolu
cs_JeffC1977 Messages postés 928 Date d'inscription vendredi 10 novembre 2000 Statut Membre Dernière intervention 23 septembre 2023 - 14 sept. 2005 à 17:51
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 - 14 sept. 2005 à 19:40
Salut....


Je me suis fais un programme pour ouvrir des fichiers (bon je ne sais pas quel autre mot utilisé pour dire Ouvrir un Fichier... hum exécuter un fichier enfin)

Je rentre dans un textbox le texte suivant 32399 et le programme exécute le fichier 32399.dgn..

Voici le code que j'utilise...
AU DÉMARAGE
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Dans le cmdOuvrir
Fichier1 = ShellExecute(Me.hWnd, "open", "M:\Vision97\PLAN" & strcontrat & ".dgn", vbNullString, "", SW_SHOWNORMAL)

Jusqu'ici ca va tres bien.... Ca exécute le fichier et MicroStation s'ouvre avec le fichier correspondant au texbox.

Le problème....

Quand j'execute Microstation (sur mon bureau je ne parle pas de code VB), je me suis créé un racourcis sur le bureau et j'ai modifier la Cible (Bouton droit de souris sur l'icîone Propriété Onglet Raccouri)
J'ai mis comme cible C:\WIN32APP\ustation\ustation.exe -wdodbc -wuvision

Comment est-il possible de coder en VB6, de prendre ce racroucis pour éxécuter le fichier que je veux exécuter à partir de mon programme VB

Le bug c'est que si j'inscrit 32399 (Mon programme exécutera le fichier 32399.dgn mais avec ce lien C:\WIN32APP\ustation\ustation.exe

Il ne prend pas en compte c'est 2 éléments (-wdodbc -wuvision)
A voir également:

5 réponses

cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 20
14 sept. 2005 à 18:38
Salut, il faut coder :

ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", "M:\Vision97\PLAN" & strcontrat & ".dgn -wdodbc -wuvision", "", SW_SHOWNORMAL)

ou

ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\PLAN" & strcontrat & ".dgn", "", SW_SHOWNORMAL)

Les paramètres à passer à l'appli doivent se trouver à la position "lpParameters ". Il faut juste savoir dans quel ordre il faut les passer.

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
3
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 20
14 sept. 2005 à 19:40
Alors, je dirais :

If Dir("M:\Vision97\PLAN" & strcontrat & ".dgn") <> "" Then
Fichier1 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\PLAN" & strcontrat & ".dgn", "", SW_SHOWNORMAL)
ElseIf Dir("M:\Vision97\PLAN_2004" & strcontrat & ".dgn") <> "" Then
Fichier2 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\PLAN_2004" & strcontrat & ".dgn", "", SW_SHOWNORMAL)
ElseIf Dir("M:\Vision97\ARCHIVES_PLAN" & strcontrat & ".dgn") <> "" Then
Fichier3 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\ARCHIVES_PLAN" & strcontrat & ".dgn", "", SW_SHOWNORMAL)
End If

Il y a sans doute plus élégant mais si ça peut te dépanner.... pour l'instant.

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
3
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 129
14 sept. 2005 à 18:08
Essaye comme ceci :



Fichier1 = ShellExecute(Me.hWnd, "open", "M:\Vision97\PLAN" &
strcontrat & ".dgn -wdodbc -wuvision", vbNullString, "",
SW_SHOWNORMAL)
Ou comme ceci :


Fichier1 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe M:\Vision97\PLAN" &
strcontrat & ".dgn -wdodbc -wuvision", vbNullString, "",
SW_SHOWNORMAL)

_____________________________________________________________________
DarK Sidious

Un API Viewer (pour le VB, VB.NET, C, C# et Delphi) tout en français : www.ProgOtoP.com/popapi/
0
cs_JeffC1977 Messages postés 928 Date d'inscription vendredi 10 novembre 2000 Statut Membre Dernière intervention 23 septembre 2023 4
14 sept. 2005 à 19:05
Salut... meric pour la réponse...

J'ai juste un problème que je n'avais pas mentionné dans mon premier message....

Le Fichier (fichier que j'inscrit dans le textbox) peut se retrouver qu'une fois dans trois répertoire... Donc j'ai mis le code comme cela...

Fichier1 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\PLAN" & strcontrat & ".dgn", "", SW_SHOWNORMAL)

Fichier2 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\PLAN_2004" & strcontrat & ".dgn", "", SW_SHOWNORMAL)

Fichier3 = ShellExecute(Me.hWnd, "open", "C:\WIN32APP\ustation\ustation.exe", " -wdodbc -wuvision M:\Vision97\ARCHIVES_PLAN" & strcontrat & ".dgn", "", SW_SHOWNORMAL)



Donc j'ai un problème.... À l'exécution du programme (VB) toutes mes variables sont = à 42 (Fichier1, Fichier2 et Fichier3) et donc j'ai trois MicroStation qui s'éxeécute.. mais je veux seulement lui dire d'exécuter qu'une fois MicroStation et d'ouvrir la bon fichier....

Exist-il un facon pour régler mon problème ou bien je code quelque chose pour lui dire Si le fichier existe alors ouvre MicroStation ????

Merci d'avance
0

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

Posez votre question
PCPT Messages postés 13278 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 48
14 sept. 2005 à 19:18
salut,
dans ton Form_Load (ou ton Sub Main) : If App.PrevInstance Then End

PCPT
0
Rejoignez-nous