Re: GetSystemPowerState by Julian
Julian
Tue Aug 07 08:40:03 CDT 2007
ok this worked, the iFlags now returns the power state of the device.
Thanks for the help.
"<ctacke/>" wrote:
> pFlags is defined as a PDWORD, so that means it's a DWORD *, so it needs to
> go ByRef, not ByVal.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Managed Code in an Embedded World
> www.OpenNETCF.com
>
>
> "Julian" <Julian@discussions.microsoft.com> wrote in message
> news:DF36E433-A295-4D60-BD3D-825C8D95FE7F@microsoft.com...
> >I use Imports System.Runtime.InteropServices
> >
> > then declare
> > <DllImport("coredll.dll", CharSet:=CharSet.Unicode)> _
> > Public Shared Function GetSystemPowerState(ByVal pBuffer As String, ByVal
> > Length As Integer, ByVal pFlags As Integer) As Integer
> > End Function
> >
> >
> > and in my function I use the following:
> > Dim msgBuffer As New System.Text.StringBuilder(256)
> > Dim iFlags As Integer = 0
> > GetSystemPowerState(msgBuffer.ToString, msgBuffer.Capacity, iFlags)
> >
> > GetSystemPowerState returns 87 and msgBuffer is "". thanks in advance.
> >
> > "Peter Foot [MVP]" wrote:
> >
> >> a quick look at the Error Lookup tool would show that 87 - "The parameter
> >> is
> >> incorrect." . Post the P/Invoke definition you are using and we can offer
> >> advice on how to fix it.
> >>
> >> Peter
> >>
> >> --
> >> Peter Foot
> >> Microsoft Device Application Development MVP
> >> www.peterfoot.net | www.inthehand.com
> >> In The Hand Ltd - .NET Solutions for Mobility
> >>
> >> "Julian" <Julian@discussions.microsoft.com> wrote in message
> >> news:02EB305C-D23F-44DB-9766-2435F554BE60@microsoft.com...
> >> >I am currently using VB in VS.NET to write an application on a Windows
> >> >Mobile
> >> > 5 device. I am trying to get the current power state so I can work out
> >> > whether the device is in sleep mode or not so that I can then change it
> >> > to
> >> > IDLE or indeed wake the device up.
> >> >
> >> > However I have been trying to get GetSystemPowerState to work but it
> >> > seems
> >> > to only return the integer 87 at all times regardless of what I do.
> >> >
> >> > Maybe I am doing something wrong but would someone have a quick example
> >> > of
> >> > GetSystemPowerState in VB.NET that works on a Mobile 5 device?
> >> >
> >> > I expect I have the buffer, length or flag wrong, maybe all 3 but a
> >> > working
> >> > example would help a lot.
> >> >
> >> > thanks
> >> >
> >>
>
>
>