|
Hello and good day
Windows XP Professional allows for "locking" of a computer as opposed to logging out or shutting down. Currently, the network I am on has no Event Sync for this practice whereas it does have them for Logon and Logout.
I'm trying to write a small application that will populate a column in a datagrid with the status of individuals on the network (whether they are in or out of the office). To do this, I need an Event Sync to push out to all network machines that fires when their computer is locked.
Any help would be greatly appreciated. I have also posted in this in a couple other message boards because I'm not 100% certain which board it most pertains to.
Thank you!
|
|
|
|
|
It's possible to do. You'll have to write a small service application that gets installed on each workstation you want to monitor. This montior service will have to create it's own window, then call the Win32 API function WTSRegisterSessionNotification[^] and tell it you want to receive the WM_WTSSESSION_CHANGE[^] message, which BTW, only works with XP and above. In your window code, override WndProc. In there you'll wait for that message to arrive. Look at WPARAM part of the message for that value WTS_SESSION_LOCK and WTS_SESSION_UNLOCK. If you see either of those values, you'll send a message back to your tracking server application.
BTW - Why would you want to do such a thing?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
There is an application the company I work for uses to do many things - one among them being monitoring atttendance. Currently the attendance system is flawed in that it only checks for events fired via Logon and Logoff. However, if somebody simply doesn't log off they can circumvent the whole process.
It isn't at all that we care a great deal about the attendance itself - although we do - it's simply that with the sort of business we do, we need to be in constant contact with one another thus we need to know as soon as possible when somebody is away from their desk. Firing an event on lockdown should resolve this issue.
Thank you for the help.
|
|
|
|
|
<soapbox>I'm glad I don't work there! Really, there is no substitute for laying the Mark I EyeBall on someone for attendance purposes.</soapbox>
There are plenty of times where I get into work and don't log into my machine, or any machine for that matter, until 10, 11am, ... Not to mention being in meetings for hours on end.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am currently getting a "NullReferenceException: object reference not set to an instance of an object" when I try to check a DataRow("columnname") to see if it is a DBNull.Value. The search works fine when you put a value the is in the DB, but when you try to search for an invalid record, it gives me the NullReferenceError. I tried to do a New DataRow, as most NullRefs i've came across stem from missing the New keyword, but it looks like thats not the right way to go. Any suggestions would be appreciated. The line of code that gives the error is "If drCustomersSearch("MortgageNumber") Is DBNull.Value Then"
SqlConnection1.Open()
SqlDataAdapter1.Fill(DsNameandAddress, "NameandAddress")
SqlConnection1.Close()
If txtSearch.Text = "" Then
MessageBox.Show("You must type in a Mortgage Number" & Chr(13) & " to Search For. Try search again.", "Missing Morgage Number", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim dtCustomersUpdate As New DataTable
Dim drCustomersSearch As DataRow
Dim drCustomersSearchNoRow As DataRow
dtCustomersUpdate = DsNameandAddress.Tables.Item("NameandAddress")
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
If drCustomersSearch("MortgageNumber") Is DBNull.Value Then
MessageBox.Show("Your entry is not a valid Mortgage number." & Chr(13) & Chr(13) & "Try search again.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtSearch.Focus()
txtMortgageNumber.Text = ""
Else : txtMortgageNumber.Text = drCustomersSearch("MortgageNumber")
End If
Nathan Lindley, .NET Aficionado
|
|
|
|
|
Perhaps it is not the field "MortgageNumber" that is in error, but the drCustomersSearch that is. You should do a check after this statement:
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
To make sure that drCustomersSearch actually found something. Perhaps that was the problem. Hope this helps.
|
|
|
|
|
Thanks for the quick response kschuler
This line of code: If drCustomersSearch("MortgageNumber") Is DBNull.Value Then is where the error occurs. That line is testing to see if the PK (MortgageNumer) of the table (NamesandAddress) is available. The goal is to have it come back null when there is no record, but instead I get the NullReferenceExc. The search works fine when you use a valid MortgageNumber, but for some reason it can't return a row with nulls. Am I missing something to be able to handle a row with nulls? Again thanks for the response.
Nathan Lindleyy, .NET Aficionado
|
|
|
|
|
I didn't think anything else was required to be able to check if something was DBNull.Value. I would try debugging. Put a break point on that statement and see what value is says drCustomersSearch("MortgageNumber") really is...then check what just drCustomersSearch's value is...If that doesn't shed some light on it, you might want to put the whole thing in a try block and in the catch portion put a messagebox to display the exception's message. Sometimes they have better error message there. Sorry I can't be more helpful.
|
|
|
|
|
Thanks again Kschuler.
I did the debugging and the values for the drCustomersSearch comes back as Nothing. I guess when it cant find the row it returns Nothing as the value. I did a check for Nothing, but still got the NullReferenceException. Not sure how to work around this. Might have to rethink the whole approach.
Nathan Lindley, .NET Aficionado
|
|
|
|
|
When you say that you are checking for nothing, are you checking just the DataRow object? I think your code should look something like this:
dtCustomersUpdate = DsNameandAddress.Tables.Item("NameandAddress")
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
If drCustomersSearch Is Nothing Then
MessageBox.Show("Customer could not be found.")
Else
If drCustomersSearch("MortgageNumber") Is DBNull.Value Then
MessageBox.Show("Your entry is not a valid Mortgage number." & Chr(13) & Chr(13) & "Try search again.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtSearch.Focus()
txtMortgageNumber.Text = ""
Else : txtMortgageNumber.Text = drCustomersSearch("MortgageNumber")
End If
End If
|
|
|
|
|
The problem is you're trying to get the value of a row that doesn't exist. Since your call to dtCustomersUpdate.Rows.Find() returned Nothing , you have to check if drCustomersSearch is Nothing before you try and do anything with it.
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
If Not drCustomersSearch Is Nothing Then
If drCustomersSearch("MortgageNumber") Is DBNull.Value Then
MessageBox.Show(blah, blah, blah)
txtSearch.Focus()
txtMortgageNumber.Text = ""
Else
txtMortgageNumber.Text = drCustomersSearch("MortgageNumber")
End If
Else
' The search didn't find anything, handle this case...
End If
It's standard practice to check to see if any object actually exists before you try and use it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Kschuler, Dave!
I had checked it for being Nothing before and was still getting the NullReference, but when i checked if Not Nothing, it seemed to do the trick. Thanks for the advice.
Nathan Lindley, .NET Aficionado
|
|
|
|
|
Hi all.
I'd search in the board how an can get text that is at the coordinate x,y (I have a flexgrid on external program and want to get the text of some row/column by its x,y coordinates).
I didn't found nothing. Can someone help me?
Please, help me.
Thx in advance.
Best Regards,
Marco Alves.
|
|
|
|
|
You can't. The control has to export the functionality to do that, and it doesn't. There is no Win32 API calls you can make to easily force the text out of the control.
An alternative would be to implement a kind of OCR (Optical Character Recognition) to read the text from a bitmap screenshot image.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
In C#, VB, Managed C++, or VC++?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In any language.
If it is not possible, how I can get number of rows of a msflexgrid of a external program?
|
|
|
|
|
See if this helps.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i'm currently working on a program to capture a manually higlighted text/chars in AXwebbrowser object. is there any way that i could capture that event in run-time? if there's none. is there any alternative that i could use?
|
|
|
|
|
Kenneth Villasenor wrote: is there any way that i could capture that event in run-time
There is no such event exposed by the Browser control.
Kenneth Villasenor wrote: is there any alternative that i could use
AFAIK, the Browser control doesn't respond to WM_GETTEXT message the way you would expect it to. So, no, there is no alternative to it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
aside from relying on the browser control. is there any way that i could handle the highlighted text and store it's value to a variable.
|
|
|
|
|
You just asked the exact same question you did in your original post. There's no way to get at that text, so there's no way to get it into a variable.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I want to print multiple values in the same Parameter Field of Crystal Report. I fetch data from table in loop and assign it to a Parameter Field. My problem is that it overwrites the last value, I want it to Display as New Value for the same Parameter Field in a new row. I'm writing the sample code below to make it clear.
For count = 0 To 2
crReportDocument.SetParameterValue(0, "Amit" & CStr(count))
crReportDocument.SetParameterValue(1, count)
Next
Now for the Parameter Field 0 and 1, the value printed in report is
Amit 2 2
But I want my output to be
Amit0 0
Amit1 1
Amit2 2
My requirement is such that I cannot bind Crystal Report to a datasource.(pity). I have to define Parameter Field and supply values to them through the code.
An early reply or suggestion will be highly appreciated.
|
|
|
|
|
Hi
I created an application using vb.net,which logs the error in event viewer. This application is working well at XP and windows 2003. But at windows 2000, it is showing error. Can any1 please tell me, what are changes i need to make in the system or code, so as to execute it on windows 2000.
Thanks in advance
Manish
|
|
|
|
|
First, Windows 2000 has to have at least Service Pack 4 installed.
Next, check to make sure that the account your running your app under has sufficient rights to write to the event log.
Lastly, you might want to post the error message your getting when you run your app.
Oh!! There are no changes you have to make to your code, it should work already with no changes.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have given Admin rights to internet user as well as ASPNET user.
I have also made changes in the registry of Event Log so as to allow guest.
Please let me know is there any solution for this.....
Thanks for your reply
Manish
|
|
|
|