4 Replies - 680 Views - Last Post: 24 May 2016 - 11:09 AM Rate Topic: -----

#1 kenw232   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-September 15

SHShutDownDialog broken in .NET 4.5?

Posted 24 May 2016 - 01:42 AM

This works in .NET 3.5, but when I upgrade my project to .NET 4.5 it doesn't anymore. Anyone know why?

    class Program
    {
        [DllImport("shell32", EntryPoint = "#60")]
        public static extern int SHShutDownDialog(int p);

        [STAThread]
        static void Main(string[] args)
        {
            SHShutDownDialog(0);
        }
    }

Is This A Good Question/Topic? 0
  • +

Replies To: SHShutDownDialog broken in .NET 4.5?

#2 kenw232   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-September 15

Re: SHShutDownDialog broken in .NET 4.5?

Posted 24 May 2016 - 01:48 AM

I forgot to mention this is under Windows 10. Its fine under Windows 7 & 8, but Windows 10 must have changed something?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6216
  • View blog
  • Posts: 21,454
  • Joined: 05-May 12

Re: SHShutDownDialog broken in .NET 4.5?

Posted 24 May 2016 - 06:26 AM

Does the entry point exist on Windows 10? Why don't you call InitiateSystemShutdown() instead?

You made me look...
Attached Image

Looks like entry #60 does not exist on Windows 10.
Was This Post Helpful? 1
  • +
  • -

#4 kenw232   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-September 15

Re: SHShutDownDialog broken in .NET 4.5?

Posted 24 May 2016 - 10:12 AM

Does this mean Microsoft got rid of it in Windows 10 so its not possible anymore?

InitiateSystemShutdown() doesn't display a dialog box I think, not the same one anyway. Can anyone confirm?

View Postkenw232, on 24 May 2016 - 10:09 AM, said:

Does this mean Microsoft got rid of it in Windows 10 so its not possible anymore?


This can't be true, I had it working with .NET 3.5 So its a .NET 4.5 limitation now. Is this something that can be program around and found again? Maybe at a different entry point now in 4.5?
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6216
  • View blog
  • Posts: 21,454
  • Joined: 05-May 12

Re: SHShutDownDialog broken in .NET 4.5?

Posted 24 May 2016 - 11:09 AM

You'll have to read up on how Windows does SxS for its DLLs. Although you may be loading "shell32.dll" and trying to get an entry point into it, the OS starting at Win7 actually remaps things under the covers depending on how the manifest for your application is setup.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1