Results 1 to 6 of 6

Thread: [RESOLVED] Shellexecute not working in Windows 10

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    577

    Resolved [RESOLVED] Shellexecute not working in Windows 10

    I have now installed the release version of Windows 10 and can no longer use Shellexecute. Even a simple statement such as;

    Code:
    Option Explicit
    
    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
    
    
    Private Sub Form_Load()
        Dim r As Long
        r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
        MsgBox r
    End Sub
    doesn't work and it does not get to the msgbox. Any ideas?

  2. #2
    Addicted Member Wolfgang Enzinger's Avatar
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    152

    Re: Shellexecute not working in Windows 10

    Quote Originally Posted by Steve Grant View Post
    Code:
    r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
    Probably unrelated, but are you aware that in params lpParameters and lpDirectory, you are effectively passing "0" instead of ""?

    Wolfgang

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    577

    Re: Shellexecute not working in Windows 10

    Thanks Wolfgang. I copied the declaration from my code but wrote the call by hand here. As you say it should be VBNullstring or "".

    However the answer turned out to be unexpected. I have been running the IDE in Vista SP2 compatibility mode so that drawing controls etc was fairly speedy. Reverting back to no compatibility has resolved the problem.

    I assume therefore that if I had got to the point of compiling, then all would have been well.

    Steve.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,802

    Re: [RESOLVED] Shellexecute not working in Windows 10

    Vista SP2 compatibility mode shouldn't have anything to do with drawing cotrols in the IDE and it is hard to imagine any reason to use it. But I suppose it could alter the behavior of Shell32 calls.

    The appcompat fix for the IDE was called "Disable desktop composition" or something similar in later versions of Windows. You don't need or want any of the "OS Mode" fixes.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    577

    Re: [RESOLVED] Shellexecute not working in Windows 10

    Hi Dil, you are usually right but it is what it is. Drawing controls is sluggish without compat. Whereas with Vista SP2 you get a nice red square around the controls while drawing and yet the forms etc still look like Win 10 when run. I attach a picture of the available settings, which are currently set as I read somewhere else on the Net when trying to sort out my ShellExecute problem. What do you think was going on there?

    Steve.Attachment 129117

  6. #6
    Fanatic Member
    Join Date
    Jan 2015
    Posts
    534

    Re: [RESOLVED] Shellexecute not working in Windows 10

    Since my migration to Windows 10, I had the same problem at design time.
    The solution is to launch 2 times the ShellExecute.
    Ans it will work.

    Maybe some kind of delay with Vista SP2 compatibility

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