-
Jan 30th, 2025, 08:34 AM
#1
Thread Starter
PowerPoster
Loss of memory.
Hi,
I'm trying to set-up a much used application from a previous computer (Win.10) in a new computer (Win.11), one subroutine starts:
Code:
Private Sub PMC(ByVal sender As Object, ByVal e As PowerModeChangedEventArgs)
If e.Mode = PowerModes.Resume Then
But I've forgotten what I need for it to work, I seem to remember that I needed to add a DLL somewhere, but there are dozens of them in the previous laptop so I can't tell which one to use or where to put it.
Poppa
Along with the sunshine there has to be a little rain sometime.
-
Jan 30th, 2025, 09:11 AM
#2
-
Jan 30th, 2025, 09:16 AM
#3
Re: Loss of memory.
Code:
Imports Microsoft.Win32
There are mentions online of combining PowerManagement in your app. with a windows service that runs all the time your computer runs. But I don’t know how you originally wrote your application…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 30th, 2025, 10:02 AM
#4
Thread Starter
PowerPoster
Re: Loss of memory.
 Originally Posted by .paul.
Code:
Imports Microsoft.Win32
There are mentions online of combining PowerManagement in your app. with a windows service that runs all the time your computer runs. But I don’t know how you originally wrote your application…
Thanks .Paul, That code is already there, right above 'Public Class Form1'.
Ought I to add Win32 somewhere? It's in dozens of places already, mostly with something added after the 'Win32' bit.
Along with the sunshine there has to be a little rain sometime.
-
Jan 30th, 2025, 08:52 PM
#5
Re: Loss of memory.
You need to read the documentation. The documentation for EVERY type tells you what namespace it's a member of and what assembly it's defined in. Note that the assembly may vary by .NET version. You're using the PowerModeChangedEventArgs and PowerModes types, so read the documentation for those types. In .NET 9, they are defined in Microsoft.Win32.SystemEvents.dll. In .NET Framework 4.8.1, they are defined in System.dll.
-
Feb 5th, 2025, 06:48 PM
#6
Thread Starter
PowerPoster
Re: Loss of memory.
 Originally Posted by jmcilhinney
You need to read the documentation. The documentation for EVERY type tells you what namespace it's a member of and what assembly it's defined in. Note that the assembly may vary by .NET version. You're using the PowerModeChangedEventArgs and PowerModes types, so read the documentation for those types. In .NET 9, they are defined in Microsoft.Win32.SystemEvents.dll. In .NET Framework 4.8.1, they are defined in System.dll.
I've really tried to understand what Microsoft is telling me but I'm baffled. Where they do give examples they're in C++ which may as well be in Latin. I can't find anything of use, you'll've seen elsewhere in this forum that I've tried to test what code I do have, (which works perfectly well in the application that I use in a Win.10 machine) but which fails to even call the method in this Win.11 one.
I'm no further with a solution to my problem.
Poppa
Along with the sunshine there has to be a little rain sometime.
-
Feb 5th, 2025, 07:33 PM
#7
Re: Loss of memory.
 Originally Posted by Poppa Mintin
I've really tried to understand what Microsoft is telling me but I'm baffled. Where they do give examples they're in C++ which may as well be in Latin. I can't find anything of use, you'll've seen elsewhere in this forum that I've tried to test what code I do have, (which works perfectly well in the application that I use in a Win.10 machine) but which fails to even call the method in this Win.11 one.
I'm no further with a solution to my problem.
Poppa
The online documentation for .Net generally defaults to C# (not C++ although that is available), you can choose the language you want the sample code to be displayed in near the top of the page - look for where it says C# or C++ and click the dropdown to display it in your preferred language.
-
Feb 5th, 2025, 09:15 PM
#8
Re: Loss of memory.
 Originally Posted by Poppa Mintin
I've really tried to understand what Microsoft is telling me but I'm baffled. Where they do give examples they're in C++ which may as well be in Latin. I can't find anything of use, you'll've seen elsewhere in this forum that I've tried to test what code I do have, (which works perfectly well in the application that I use in a Win.10 machine) but which fails to even call the method in this Win.11 one.
I'm no further with a solution to my problem.
Poppa
None of that's really relevant to the issue I addressed. You were saying that you didn't know what library to use to make that code work and I told you how to find out. The answer to that has been the same for almost 25 years. That doesn't mean that there aren't other issues but now you know how to find out what assembly a type is defined in, you won't have to ask again. As for where to put it, there is no putting it anywhere for a first-party assembly. If it's .NET Framework then you reference it and if it's .NET Core then you install the NuGet package. Again, nothing new.
As for language, the vast majority of examples are provided in both C# and VB. That you don't know that you can select the language from the drop-down at the top of the page just means that you haven't spent the time you should have to explore the documentation. As mentioned, it will default to C# but there's a drop-down arrow right next to the language at the top of the page. All you had to do was change that to VB once and it would then default to VB for you every time in the future. Imagine how many questions you could have answered for yourself if you'd learned how to use the documentation years ago. When I first started answering questions on this forum, I had no idea about many of them so I just read the documentation that the person asking the question hadn't bothered to and provided the answer that they could have found for themselves. The documentation won't answer every question but it will answer many and should always be consulted before asking elsewhere.
-
Mar 7th, 2025, 06:26 PM
#9
New Member
Re: Loss of memory.
 Originally Posted by Poppa Mintin
µµBut I've forgotten what I need for it to work
I literally pasted your post into ChatGPT and it said you need this:
Code:
AddHandler SystemEvents.PowerModeChanged, AddressOf PMC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|