|
yes i know i am not passing a url through.
Thats my exact question .... how can i catch the url of the window that is opening in IE so i can launch it from anywhere i want to !
Regarding the events, i am stopping the Ie from opening via e.cancel = true in the newwindow event
and then i tried on the navigating to run process.start(e.url.tostring())
|
|
|
|
|
Considering CancelEventArgs doesn't have a URL property, what you're doing isn't going to work.
You can try to handle the NewWindow or Navigating events of the WebBrowser control. I suggest reading up on those events to see exactly what they do, what argument they expose and what the properties of those arguments are before you proceed.
|
|
|
|
|
Public Delegate Sub NewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As NewWindowExtendedEventArgs)
Public Class NewWindowExtendedEventArgs : CancelEventArgs
Private url As Uri
Public ReadOnly Property Url As Uri
Get
Return url
End Get
End Property
Public Sub New(ByVal url As Uri)
Me.url = url
End Sub
End Class
Public Class ExtendedWebBrowser
Inherits WebBrowser
Private Class WebBrowserExtendedEvents
Inherits System.Runtime.InteropServices.StandardOleMarshalObject
Implements DWebBrowserEvents2
Private browser As ExtendedWebBrowser
Public Sub New(browser As ExtendedWebBrowser)
Me.browser = browser
End Sub
Public Sub NewWindow3(pDisp As Object, ByRef cancel As Boolean, ByRef flags As Object, ByRef urlContext As String, ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
Dim e As New NewWindowExtendedEventArgs(New Uri(url))
browser.OnNewWindowExtended(e)
cancel = e.Cancel
End Sub
End Class
<ComImport> _
<Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D")> _
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _
<TypeLibType(TypeLibTypeFlags.FHidden)> _
Private Interface DWebBrowserEvents2
<DispId(273)> _
Sub NewWindow3(<InAttribute, MarshalAs(UnmanagedType.IDispatch)> pDisp As Object, <InAttribute, OutAttribute> ByRef cancel As Boolean, <InAttribute> ByRef flags As Object, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef urlContext As String, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
End Interface
Public Event NewWindowExtended As NewWindowExtendedEventHandler
Private cookie As AxHost.ConnectionPointCookie
Private wevents As WebBrowserExtendedEvents
Protected Overrides Sub CreateSink()
MyBase.CreateSink()
wevents = New WebBrowserExtendedEvents(Me)
cookie = New AxHost.ConnectionPointCookie(Me.ActiveXInstance, wevents, GetType(DWebBrowserEvents2))
End Sub
Protected Overrides Sub DetachSink()
If cookie IsNot Nothing Then
cookie.Disconnect()
cookie = Nothing
End If
MyBase.DetachSink()
End Sub
Protected Overridable Sub OnNewWindowExtended(e As NewWindowExtendedEventArgs)
RaiseEvent NewWindowExtended(Me, e)
End Sub
End Class
Hope this helps. I just converted this from the C# code in #Develop. It allows for getting the URL of the event.
brisingr_aerowing@Gryphon-PC $ rake in_the_dough
Raking in the dough
brisingr_aerowing@Gryphon-PC $ make lots_of_money
Making lots_of_money
|
|
|
|
|
Hi all, I want to create a Windows service that detect system datetime change and as soon as it detects the change, it gives a message "System DateTime has been changed".
Public Class CltChk
Protected Overrides Sub OnStart(ByVal args() As String)
End Sub
Protected Overrides Sub OnStop()
End Sub
Private Sub CheckDateTimeClock()
Dim SysTime As Date = Date.Now
Dim CurrentHour As Integer = SysTime.Hour
Dim CurrentMinute As Integer = SysTime.Minute
Dim CurrentSecond As Integer = SysTime.Second
Dim CurrentMilliSecond As Integer = SysTime.Millisecond
End Sub
End Class
I created a windows service but I don't know how to start.
Please HELP me.
modified 9-Jul-13 8:36am.
|
|
|
|
|
Member 7815124 wrote: a Windows service ... it gives a message "System DateTime has been changed".
A Windows service cannot interact with the desktop, so it's not going to be able to display a message to the user. There might not even be a user logged in when the system time changes.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your quick answer.
So what am I to do ? Creating a windows process that runs in background ? What should be the code ?
I have written something please check it.....
Public Class Form1
Dim iDate As DateTime = DateTime.Now
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim iDateNow As DateTime = DateTime.Now
If iDateNow <> iDate Then
MsgBox("Date Time Change Detected.")
End If
End Sub
End Class
Is the above code OK ? How should I run it like a process ?
modified 9-Jul-13 7:53am.
|
|
|
|
|
That code is going to pop up a message every second. If you leave it running, it will fill your screen with messages, and eventually exhaust all system resources.
What are you actually trying to achieve?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, First I should tell you that I am not getting any message running this code(I do not know why? is it that I am not using a loop?).
Secondly and most important thing is I am trying to create something that detects System Date Time change and give a message to the user. This program will be connected to my main program i.e. if this program/process is closed then the main program will be closed automatically.
My main program contains a piece of code that writes install date, License period and last use date in the registry. If the user try to manipulate the system date and time my main program will not open (Although the idea or the code is not fullproof)
So I want to warn user through the detection of dateTime change that, to get back the last date time otherwise the program will not run.
|
|
|
|
|
There is no reliable way to do this without using an external clock source, such as one on the Internet.
The only place I know of to get that the system time changed would be from the System Event Log. Still, even the event log can be cleared out without your code ever seeing the event.
Monitoring for it and watching the time contantly isn't going to do you any good. What if the system time changes when Windows isn't running??
The only way to do it would be to compare the current system time to an external reference and make a note of the offset. Every once in a while (while your code is running) you'll have to compare the current time to the external source again and see if the time is current, again, considering the offset you noted before, plus or minus a variance. PC clocks don't run at exactly the same speed and will drift over time.
|
|
|
|
|
|
Simple to reroute using the host-file
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Even if you use the IP address?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you all for your quick answers. But I should inform you that I am not so much educated in vb.net like you all. Therefore believe me your answers are just like a Tangent for me.
Ok, let me state you my idea which i would like to implement
1. My process starts with windows (continuously checking the system date and time and matching.)
2. User starts main program (checks if the process is running.)
Somehow user understood and find that the process is responsible for date time checking. So he close the process from windows task manager.
3. My process close my main program before closing.
4. User wants to start main program. (Main program checks and found process is not running)
5. Main program will not run.
I tried to create the process and tried to close Microsoft Word with that but failed......
Imports System
Imports System.Diagnostics
Public Class Form1
Dim iDate As DateTime = DateTime.Now
Dim MyProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
Sub New()
InitializeComponent()
Timer1.Interval = 1000
Timer1.Enabled = True
Application.Run()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim iDateNow As DateTime = DateTime.Now
If iDateNow < iDate Then
For Each p As Process In MyProcess
p.Kill()
Next
End If
End Sub
End Class
While I tried to close the process, Microsoft word was not closing.
|
|
|
|
|
Biplob Singha Shee wrote: While I tried to close the process, Microsoft word was not closing.
You've not added any code to kill the process when your application exits. You'd need to do that from the Closing event of your form.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I wrote the code to kill the process
For Each p As Process In MyProcess
p.Kill()
Next
and before that I declare the variable
Dim MyProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
|
|
|
|
|
But in the code you posted, there is nothing which will run when the form is closed. The only time your p.Kill() code will execute is if the system time is changed to be earlier than the start time of your program.
The only time that will normally happen is when the computer transitions out of Daylight Saving Time, when the clocks go back by one hour. (Since that's not the issue you're trying to address, you should be using DateTime.UtcNow instead.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sir, could you please help me on closing an application from another application.
I need some code idea.
|
|
|
|
|
You just need to add the code to a handler for the Closing event of your form:
Private Sub FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
Dim MyProcess() As Process = Process.GetProcessesByName("winword")
For Each p As Process In MyProcess
p.Kill()
Next
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much. But I tried with this code. It is not closing Microsoft Word.
|
|
|
|
|
The name of the process is "winword.exe", not "winword".
Oh! And your code is making the rather LARGE assumption that there will only be one instance of Word running, created by your application. That is simplly not going to be the case and you should NOT be blindly killing off every instance of Word you find.
|
|
|
|
|
Your entire concept is flawed. You cannot reliably check to see if the time has been altered without using an external (on the Internet) time source.
And you really don't need two processes for this...
|
|
|
|
|
I know my code is "FLAWED" but my concept is not wrong as because in my area everybody does not have internet connection or Internet connection is not available for everybody as everybody can not bear the cost of internet connection.
So I have to do it without internet connection (External resource of DateTime checking).
I again say my code is FLAWED and that is why I am asking a help from you people. I know you all are exparts.
|
|
|
|
|
Again, there is NO WAY to check to see if the Date/Time has changed without an external time source. You can NOT do what you want without one.
|
|
|
|
|
Thank you sir for your reply.
But I know one thing. THERE IS NOTHING IMPOSSIBLE IN THIS WORLD. I do not want to invent anything but I have to discover the solution of my problem.
But the problem is I DO NOT HAVE MORE KNOWLEDGE IN VB.NET.
Thank you again for your quick and kind reply.
|
|
|
|
|
Biplob Singha Shee wrote: THERE IS NOTHING IMPOSSIBLE IN THIS WORLD
One, you're one THOSE. OK Mr. Smarty Pants. Lay flat on the ground and have a 6 ton African elephant stand directly on your chest for 10 minutes. Live to tell us about how it felt.
Biplob Singha Shee wrote: I have to discover the solution of my problem.
For the last time... Without a connection to an external time source, be it on the internet or a physically and properly secured server machine on the network that your client machine is connected to THERE IS NO WAY TO DETECT IF THE SYSTEM CLOCK IS NOT CORRECT.
Have a nice life.
|
|
|
|