Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visual studio 2005 advice

Status
Not open for further replies.

tjbradford

Technical User
Dec 14, 2007
229
GB

Hi all,

I have done some programming with vb6 but i'm struggling to get an app to work as required, i read up that the .net framework might solve this but im abit stuck

i have created an app that will show the systems idle time "no user interaction" run as a system service.

great , but

the only way i can see to hibernate the PC is to run the following command

Application.SetSuspendState(PowerState.Hibernate, true, true);

but this is i believe c sharp ?

and the service i created was in vb - i'm abit lost with all these other languages

how can i overcome this can i convert one or something ?
 
I forgot to add that i'm trying to do this as a service, it complains on seeing Application.SetSuspendState(PowerState.Hibernate, True, True) so i commented it out and added a timer to see if calc.exe was called, but it wasn't

it says the service is running which is great but running nothing !

Public Class Service1

Protected Overrides Sub OnStart(ByVal args() As String)
Timer1.Enabled = True
Timer1.Interval = 10000
Timer2.Enabled = True
Timer2.Interval = 30000
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
End Sub

Protected Overrides Sub OnStop()
Timer1.Enabled = False
' Add code here to perform any tear-down necessary to stop your service.
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim MyLog As New EventLog() ' create a new event log
' Check if the the Event Log Exists
If Not MyLog.SourceExists("int") Then
MyLog.CreateEventSource("int", "Myservice Log")
' Create Log
End If
MyLog.Source = "int"
' Write to the Log
MyLog.WriteEntry("int Log", "This is log on " & _
CStr(TimeOfDay), _
EventLogEntryType.Information)
' Application.SetSuspendState(PowerState.Hibernate, True, True)


End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

call ("c:\windows\system32\calc.exe")
End Sub
End Class
 
I have never worked on a service application. So I can't say exactly what it is.

From a windows app I use this code to invoke an exe
Code:
 Process.Start("c:\windows\system32\calc.exe")
and your code
Code:
call ("c:\windows\system32\calc.exe")
was not acceptable for it

It was not complaining when I tested the code
Code:
Application.SetSuspendState(PowerState.Hibernate, True, True)
It went on hibernate state without any problem.

Zameer Abdulla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top