Newsgroup: it.comp.lang.visual-basic
Titolo: link lo an external .exe file (or .bat)

In want to do a kind of selection menu in Visula Basic (I have version 6.0)
and i need to use external .exe and .bat files. Someone can help ? (You can
answer english, french, or italian)
Thanx

 Comment ouvrir un fichier .txt dans le Bloc-notes ou bien wordpad, si on
ne sait si ni l'un ni l'autre (bloc-notes et wp) est installé sur la
machine????? Mon problème est plus, est-ce qu'il faut que je sache
absolument le chemin d'accès du bloc-notes ou du wordpad pour ouvrir mon
fichier dedans???? SI non, comment je fais????
pour ouvrir l'editeur de default du pc, quel qu'il soit et ou' il est, tu
peux modifier a ton but le code suivant
'en un bas:
Public Const SW_SHOWNORMAL = 1
Declare Function ShellExecute Lib "shell32" _
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
'dans le frm:
'(quand le folder change, tiens le path avec un backslash en un MyPath
publique):
Private Sub File1_DblClick()
On Error GoTo errman
Dim lRet As Long
lRet = ShellExecute(me.hwnd, vbNullString, _
mypath & file1.filename, vbNullString, "c:\", SW_SHOWNORMAL)
Exit Sub
errman: MsgBox Error
End Sub
ou bien:
Private Sub tb_ButtonClick(ByVal Button As ComctlLib.Button)
Dim iRet As Long, sUrl As String
Select Case Button.Key
Case "about":
sUrl = "
http://www.comune.modena.it/cittadini/apal/
"
iRet = ShellExecute(Me.hwnd, vbNullString, _
sUrl, vbNullString, "c:\", SW_SHOWNORMAL)
Case "exit": Unload Me
Case "mail":
sUrl = "mailto:
xd...@zelig.it
?subject=about e"
iRet = ShellExecute(Me.hwnd, vbNullString, _
sUrl, vbNullString, "c:\", SW_SHOWNORMAL)
Case "xday":
sUrl = "
http://members.xoom.it/xday/
"
iRet = ShellExecute(Me.hwnd, vbNullString, _
sUrl, vbNullString, "c:\", SW_SHOWNORMAL)
End Select
End Sub
-*-*-
or, if you want to call a program:
Public Sub RunShellExecute(sTopic As String, sFile As Variant, _
        sParams As Variant, sDirectory As Variant, nShowCmd As Long)
   Dim hWndDesk As Long
   Dim success As Long
   Const SE_ERR_NOASSOC = &H31
  'the desktop will be the default for error messages
   hWndDesk = GetDesktopWindow()
  'execute the passed operation
   success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory,
nShowCmd)
  'This is optional. Uncomment the three lines below to have the "Open
With.." dialog appear
  'when the ShellExecute API call fails
  'If success = SE_ERR_NOASSOC Then
  '   Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile,
vbNormalFocus)
  'End If
End Sub
Private Sub NetConnect()
    On Error GoTo errman
    If MsgBox("CONNETTERSI?" & vbCrLf & cboURL & txtURL & vbCrLf &
UCase(txtDescri), _
        vbYesNoCancel) <> vbYes Then Exit Sub
'    Dim lRet As Long
'    lRet = ShellExecute(Me.hwnd, vbNullString, cboURL & Trim(txtURL),
vbNullString, _
'        MyPath, SW_SHOWNORMAL)
    Dim sTopic As String, sFile As String, sPar As String, sDir As String
    sTopic = "Open"
    sFile = "C:\Programmi\Internet Explorer\IEXPLORE.EXE"
    sPar = cboURL & Trim(txtURL)
    sDir = 0&
    Call RunShellExecute(sTopic, sFile, sPar, sDir, SW_SHOWNORMAL)
Exit Sub
errman: MsgBox Error
End Sub
hth, pal
--
andrea palazzi
xday at libero dot it
free vb/sw: 
http://www.comune.modena.it/cittadini/apal/html/