Skip to content

Commit

Permalink
VS2019, .Net 4.8, 64 bit, don't let the PC sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
dheijl committed Aug 4, 2020
1 parent 0b581eb commit 5091987
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 45 deletions.
16 changes: 11 additions & 5 deletions SWYH Installer.iss
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Stream What You Hear (SWYH)"
#define MyAppVersion "1.5"
#define MyAppPublisher "Sebastien.warin.fr"
#define MyAppURL "http://www.streamwhatyouhear.com"
#define MyAppExeName "SWYH.exe"

; Updated by the build server
#define ShortVersion "1.0"
#define FullVersion "1.0-dev"
#define FullVersion "1.5.217.1"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5FBEA9D3-668E-4B88-BF6C-E1BCF441ECFD}
AppName={#MyAppName}
AppVersion={#ShortVersion}
AppVerName={#MyAppName} {#FullVersion}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
Expand All @@ -24,6 +29,7 @@ OutputBaseFilename=SWYH_{#FullVersion}
SetupIconFile=SWYH\Resources\Icons\swyh128.ico
Compression=lzma
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Expand Down
13 changes: 8 additions & 5 deletions SWYH.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
# Visual Studio Version 16
VisualStudioVersion = 16.0.29403.142
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SWYH", "SWYH\SWYH.csproj", "{9F7F5728-3DC1-4FA2-8D4B-F91AA3ABA754}"
EndProject
Expand Down Expand Up @@ -63,8 +63,8 @@ Global
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|Any CPU.Build.0 = Release|Any CPU
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|x64.ActiveCfg = Release|x64
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|x64.Build.0 = Release|x64
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|x64.ActiveCfg = Release|Any CPU
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|x64.Build.0 = Release|Any CPU
{584ED187-8F2A-4B58-A266-85F3F212B092}.Release|x86.ActiveCfg = Release|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -77,6 +77,7 @@ Global
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Release|x64.ActiveCfg = Release|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Release|x64.Build.0 = Release|Any CPU
{B2439738-5F46-4E59-95A1-92C3DF38696F}.Release|x86.ActiveCfg = Release|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -89,6 +90,7 @@ Global
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Release|x64.ActiveCfg = Release|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Release|x64.Build.0 = Release|Any CPU
{E01B6019-ACC6-40A6-A511-48D285D51C40}.Release|x86.ActiveCfg = Release|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -101,6 +103,7 @@ Global
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Release|x64.ActiveCfg = Release|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Release|x64.Build.0 = Release|Any CPU
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Expand All @@ -113,6 +116,6 @@ Global
{8EA0E595-45EC-40C1-82CE-269F4FA9EBB3} = {D1A9AE0B-AAC3-402B-A9BE-42F881FCC9B8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2367C55F-27F9-4D0D-97E6-D66076184A94}
SolutionGuid = {FB58350D-0EA3-4C2B-9033-86B52E8BE09A}
EndGlobalSection
EndGlobal
27 changes: 27 additions & 0 deletions SWYH/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SWYH
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -61,6 +62,18 @@ public partial class App : Application
private System.Windows.Forms.ToolStripMenuItem searchingItem = null;
private bool directClose = false; //Skip the statements in Application_Exit function.

private uint m_previousExecutionState; // cf. SetThreadExecutionState

private static class NativeMethods
{
// Import SetThreadExecutionState Win32 API and necessary flags
[DllImport("kernel32.dll")]
public static extern uint SetThreadExecutionState(uint esFlags);
public const uint ES_CONTINUOUS = 0x80000000;
public const uint ES_SYSTEM_REQUIRED = 0x00000001;
}


private void Application_Startup(object sender, StartupEventArgs e)
{
var startTest = 0;
Expand Down Expand Up @@ -112,10 +125,19 @@ private void Application_Startup(object sender, StartupEventArgs e)
notifyIcon.ShowBalloonTip(2000, "Stream What You Hear is running", "Right-click on this icon to show the menu !", System.Windows.Forms.ToolTipIcon.Info);
}
}
// raise priority a bit above normal user tasks
using (Process p = Process.GetCurrentProcess())
{
p.PriorityClass = ProcessPriorityClass.AboveNormal;
}
// Set new state to prevent system sleep (note: still allows screen saver)
m_previousExecutionState = NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
if (0 == m_previousExecutionState) {
System.Windows.Forms.MessageBox.Show("Call to SetThreadExecutionState failed unexpectedly.", "Stream What You hear");
// No way to recover; fail gracefully
this.Shutdown();
}

}

private void InitializeUI()
Expand Down Expand Up @@ -314,6 +336,11 @@ private void Application_Exit(object sender, ExitEventArgs e)
this.notifyIcon.Dispose();
}
}
// Restore previous state
if (0 == NativeMethods.SetThreadExecutionState(m_previousExecutionState)) {
// No way to recover; already exiting
}

}
}
}
38 changes: 33 additions & 5 deletions SWYH/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
*/

using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

[assembly: Guid("2ecd245f-4268-48ee-b0f1-0706ead1ba42")]
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Stream What You Hear")]
[assembly: AssemblyDescription("Stream What You Hear (SWYH) is a Windows application to stream the sound from your PC to an UPnP / DLNA device")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -34,8 +38,22 @@
[assembly: AssemblyCopyright("Copyright © 2012-2019 Sebastien.warin.fr ans others")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
Expand All @@ -45,7 +63,17 @@
// app, or any theme specific resource dictionaries)
)]

// Version 10.0 for local development
// Automatically update by the build pipeline with GitVersion
[assembly: AssemblyVersion("10.0.0.0")]
[assembly: AssemblyFileVersion("10.0.0.0")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1.1")]
[assembly: AssemblyFileVersion("1.5.217.1")] // MAJOR.minor.BuildDate.Release (Si Release impaire = BETA) || http://www.epochconverter.com/epoch/daynumbers.php
[assembly: GuidAttribute("2ecd245f-4268-48ee-b0f1-0706ead1ba42")]
65 changes: 51 additions & 14 deletions SWYH/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions SWYH/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5091987

Please sign in to comment.