CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: ShellExecute

  1. #1
    Join Date
    May 1999
    Location
    Mid-West
    Posts
    50

    ShellExecute

    I know someone has a good ShellExecute handler for VB. Can i have a copy of the code? THanks




  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: ShellExecute

    The regular "Shell" command won't open files, just execute them. To open files with Word, Excel,
    Notepad - whatever, use this API - ShellExecute:



    Public 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

    Public Const SW_SHOWNORMAL = 1
    Dim iRetVal as Long

    iRetVal = ShellExecute(Me.hwnd, "open", "C:\bootlog.txt", vbNullString, "c:\", SW_SHOWNORMAL)


    This will open notepad and have notepad open the bootlog.txt file (if it exists).


    "open" to open or execute
    "print"
    "explore"

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 1999
    Location
    Mid-West
    Posts
    50

    Re: ShellExecute

    Actually i'm executing a batch file. So instead of open do i use run?


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: ShellExecute

    I beleive it must be 'open'

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured