Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. ShellExecute problem

ShellExecute problem

Scheduled Pinned Locked Moved Visual Basic
helpdatabasedebuggingjsonannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AccessDeveloper
    wrote on last edited by
    #1

    I created an access Lyric database. Then I added a table and a combo to hold song file data. Then, when the user selects a song and clicks play the code below gets executed. When I first did this it went well. WMPlayer opened up and played the song. Now it opens up the open dialog wanting me to select the file. It returns a 42. This is the first time I used this API command. Any help will be appreciated.

    Private Sub cmdPlay_Click()
    Const klShowApp As Long = 1
    Dim sPath As String, sFile As String
    Dim lReturn As Long

    ' cboTuneLU has the following columns
    ' 0 Version ID
    ' 1 MP3 File
    ' 2 MP3 Path

    On Error GoTo ERR\_cmdPlay\_Click
    
    sFile = ksQuote & Me.cboTuneLU.Column(1) & ksQuote
    sPath = ksQuote & Me.cboTuneLU.Column(2) & ksQuote
    lReturn = ShellExecute(Me.hWnd, "open", sPath, vbNullString, sFile, klShowApp)
    Stop ' returns 42
    

    EXIT_cmdPlay_Click:
    Exit Sub
    ERR_cmdPlay_Click:
    'Debug.Print CStr(Err) & " " & Err.Description
    ShowError "frmLyrics.cmdPlay_Click"
    Resume EXIT_cmdPlay_Click

    End Sub

    J 1 Reply Last reply
    0
    • A AccessDeveloper

      I created an access Lyric database. Then I added a table and a combo to hold song file data. Then, when the user selects a song and clicks play the code below gets executed. When I first did this it went well. WMPlayer opened up and played the song. Now it opens up the open dialog wanting me to select the file. It returns a 42. This is the first time I used this API command. Any help will be appreciated.

      Private Sub cmdPlay_Click()
      Const klShowApp As Long = 1
      Dim sPath As String, sFile As String
      Dim lReturn As Long

      ' cboTuneLU has the following columns
      ' 0 Version ID
      ' 1 MP3 File
      ' 2 MP3 Path

      On Error GoTo ERR\_cmdPlay\_Click
      
      sFile = ksQuote & Me.cboTuneLU.Column(1) & ksQuote
      sPath = ksQuote & Me.cboTuneLU.Column(2) & ksQuote
      lReturn = ShellExecute(Me.hWnd, "open", sPath, vbNullString, sFile, klShowApp)
      Stop ' returns 42
      

      EXIT_cmdPlay_Click:
      Exit Sub
      ERR_cmdPlay_Click:
      'Debug.Print CStr(Err) & " " & Err.Description
      ShowError "frmLyrics.cmdPlay_Click"
      Resume EXIT_cmdPlay_Click

      End Sub

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      What's the value of sPath and sFile? Those values may not be in the right format. You should probably just pass the file name, and let windows figure out what player to use. Like double clicking on the filename in the folder. https://social.msdn.microsoft.com/Forums/vstudio/en-US/a4de8224-cade-4fda-b304-06d21e970c28/how-to-play-a-mp4-file-using-window-media-player-through-shellexecute-command?forum=vclanguage[^]

      A 1 Reply Last reply
      0
      • J jkirkerx

        What's the value of sPath and sFile? Those values may not be in the right format. You should probably just pass the file name, and let windows figure out what player to use. Like double clicking on the filename in the folder. https://social.msdn.microsoft.com/Forums/vstudio/en-US/a4de8224-cade-4fda-b304-06d21e970c28/how-to-play-a-mp4-file-using-window-media-player-through-shellexecute-command?forum=vclanguage[^]

        A Offline
        A Offline
        AccessDeveloper
        wrote on last edited by
        #3

        The user actually selects the filespec (path & filename) from the open dialog box. I split the filespec into Path and filename and store each into their corresponding fields in a record. I know the path is correct because the open dialog opens to the correct folder. This was working great, but now It does this. I would sure like to find out what the return values of this API function mean. I tried every number fro 0 to 10 in the show parameter of the shellexecute API call. The record is define as: tblMP3 ------ MP3Seq autonum index MP3ID long MP3VerID integer MP3Path text MP3File text I wanted to be able to save more then one song file. The artist's version and a karaoke version. That's what the MP3VerID is for. The MP3ID field is the same as the autonum field in the lyrics table. I have had this program for a number of years. VB's Shell has been used all this time. But now on Win 7 I get a security message blocking me from using it. That's when I discovered ShellExecute. Any help will be appreciated Roger

        J 1 Reply Last reply
        0
        • A AccessDeveloper

          The user actually selects the filespec (path & filename) from the open dialog box. I split the filespec into Path and filename and store each into their corresponding fields in a record. I know the path is correct because the open dialog opens to the correct folder. This was working great, but now It does this. I would sure like to find out what the return values of this API function mean. I tried every number fro 0 to 10 in the show parameter of the shellexecute API call. The record is define as: tblMP3 ------ MP3Seq autonum index MP3ID long MP3VerID integer MP3Path text MP3File text I wanted to be able to save more then one song file. The artist's version and a karaoke version. That's what the MP3VerID is for. The MP3ID field is the same as the autonum field in the lyrics table. I have had this program for a number of years. VB's Shell has been used all this time. But now on Win 7 I get a security message blocking me from using it. That's when I discovered ShellExecute. Any help will be appreciated Roger

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          It's an exit code. usually 0 means all is good. 1 means error. But search for Windows Media Player Exit Codes. You should load Quicktime, set it as default player, and give it a test first, before you tear your hair out.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups