Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Frnd,
I register dll after 10 sec using the window service, can it is harmful for my pc. Please gave me suggestion
thanks
Posted

Do you mean that ten seconds after you start your Windows service, your PC crashes?

If so, then I would have a good hard look at the code: do you have a loop that is not terminating?

Sorry, but without relevant code fragments, it is not possible to tell what your problem is, exactly.
 
Share this answer
 
Comments
sbhhawsar 13-May-11 4:20am    
Actually i try to solve dll help problem so code like below please suggest me proper way
thanks
my code here please look it and give the suggestion
it is develop in vb.net 2008

Public Class test
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal _
lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private oTimer As System.Threading.Timer
Private otimer1 As System.Threading.Timer
Protected Overrides Sub OnStart(ByVal args() As String)

' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Dim oCallback As New System.Threading.TimerCallback(AddressOf OnTimedEvent)
oTimer = New System.Threading.Timer(oCallback, Nothing, 10000, 10000)
'Shell("C:\WINNT\system32\calc.exe", AppWinStyle.NormalFocus)
'shell("C:\Mvat .net\WindowsApplication3\WindowsApplication3\bin\Debug\WindowsApplication3.exe", AppWinStyle.NormalFocus)
End Sub
Private Sub onTimedStop(ByVal state As Object)
For Each RunningProcess In Process.GetProcessesByName("regsvr32")
RunningProcess.Kill()
Next
End Sub
Private Sub OnTimedEvent(ByVal state As Object)
Dim myLog As New EventLog
Dim oCallBack1 As New System.Threading.TimerCallback(AddressOf onTimedStop)
otimer1 = New System.Threading.Timer(oCallBack1, Nothing, 4000, 4000)
If Not myLog.SourceExists("DBMSWatcher") Then
myLog.CreateEventSource("DBMSWatcher", "DBMSWatcher Log")
End If
Dim proc As New Process
Dim proc1 As New Process
Dim proc2 As New Process
Dim proc3 As New Process
'Dim proc4 As New Process
proc.StartInfo.FileName = "C:\WINDOWS\system32\regsvr32.exe "
proc.StartInfo.Arguments = "/s C:\Progra~1\Common~1\System\ado\msadox.dll"
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True

proc.StartInfo.CreateNoWindow = True
' proc.Start()
'proc.Kill()
proc1.StartInfo.FileName = "C:\WINDOWS\system32\regsvr32.exe "
proc1.StartInfo.Arguments = "/s C:\Progra~1\Common~1\System\ado\msado15.dll"
proc1.StartInfo.UseShellExecute = False
proc1.StartInfo.RedirectStandardOutput = True
proc1.StartInfo.CreateNoWindow = True
proc1.Start()
'proc1.Kill()

proc2.StartInfo.FileName = "C:\WINDOWS\system32\regsvr32.exe"
proc2.StartInfo.Arguments = "sLinkLib.dll"
proc2.StartInfo.UseShellExecute = False
proc2.StartInfo.RedirectStandardOutput = True

'proc2.StartInfo.CreateNoWindow = True
proc2.Start()
'proc2.Kill()
proc3.StartInfo.FileName = "C:\WINDOWS\system32\regsvr32.exe "
proc3.StartInfo.Arguments = "/s SCRRUN.DLL"
proc3.StartInfo.UseShellExecute = False
proc3.StartInfo.RedirectStandardOutput = True

proc3.StartInfo.CreateNoWindow = True
proc3.Start()
'proc3.Kill()
proc4.StartInfo.FileName = "C:\Mvat .net\WindowsApplication3\WindowsApplication3\bin\Debug\WindowsApplication3.exe"
'proc4.StartInfo.Arguments = "MSStdFmt.dll"
proc4.StartInfo.UseShellExecute = False
proc4.StartInfo.RedirectStandardOutput = True

proc4.StartInfo.CreateNoWindow = True
proc4.Start()

'For Each RunningProcess In Process.GetProcessesByName("regsvr32")
' RunningProcess.Kill()
'Next
myLog.Source = "DBMSWatcher"
myLog.WriteEntry("Something Happened!", EventLogEntryType.Information)
End Sub
Protected Overrides Sub OnStop()

' Add code here to perform any tear-down necessary to stop your service.
End Sub
End Class
OriginalGriff 13-May-11 4:39am    
Stop calling Regsvr32 all the time! It only needs to be done once for each DLL, and is n-ormalyy done at installation.

Rip that code out - all of it.
Start small, and work up. Literally start with enough code to start your service, log it ran, and stop it. Then add code carefully, to build up to what your service should do. But don't call regsvr32 every time you run it!
Do you mean using regsvr32/regasm or some other registration?
Regsvr32/regasm should only be called once when you install the dll (unless you are a developer changing the interface).

It is not dangerous if the dll belongs to you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900