BPSoftware.com
Home   Utilities   Purchase   FAQ   Support   Contact        
Shareware Utilities
 APrintDirect
 AIconExtract
 AFile Attribute Manager
Freeware Utilities
 AddrMon
 AFileSync
 ASysIcon
 B&P Table Utilities
 BPACLer
 BPSNMPMon
 BPSNMPUtil
 CharCount
 Delphi® Components
 MacAddr
Miscellaneous
 BPSoftware Blog
 Purchase Shareware
 Support

 


Friday, April 14, 2006
In time for Easter

I've always liked those corny 'Easter Eggs'. In fine fashion some posts just can't go unreferenced. Take bring them back home! for example.

Labels: , ,

posted by Brad Prendergast at 7:26:00 AM (0 comments)
Links to this post
Permalink
Wednesday, April 12, 2006
ErrorProvider

For some reason one of my favorite .NET Framework Class is the ErrorProvider class. This class allows you to visually indicate to the user that there is an error with one of the form controls. For example, if you have a user input form that allows the user to input information into a TextBox and the user tries to proceed without filling in the TextBox you can set the ErrorProvider to display an error icon, with an error hint, adjacent to the TextBox. The option of setting the BlinkStyle and BlinkRate is also neat.

A real simple example:
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
if TextBox1.text = '' then
ErrorProvider1.SetError(TextBox1,'Invalid Text Entered.')
else
ErrorProvider1.SetError(TextBox1,'');
end;






It is pretty basic and simple to use, but for some reason I am fascinated by it.

Labels: , ,

posted by Brad Prendergast at 6:43:00 AM (0 comments)
Links to this post
Permalink
Monday, April 10, 2006
Ho Hum

I did receive a couple inquiries about yesterday's post with VB.NET. Well, here goes:

Imports Microsoft.Win32

Public Class frmMain
Const basetzikey = _
"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"


Private Sub frmMain_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load

FillComboBox(cbxTimeZone)

End Sub

Private Sub FillComboBox(ByVal cbxCombo As ComboBox)

Dim rootkey As RegistryKey
Dim subkeynames As String()
Dim subkeyname As String

cbxCombo.Items.Clear()
rootkey = Registry.LocalMachine
subkeynames = rootkey.OpenSubKey(basetzikey, False).GetSubKeyNames
For Each subkeyname In subkeynames
cbxCombo.Items.Add(subkeyname.ToString)
Next
End Sub


Private Sub cbxTimeZone_SelectedValueChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cbxTimeZone.SelectedValueChanged

FillTextEdit(cbxTimeZone.Text, txtOutput)

End Sub

Private Sub FillTextEdit(ByVal timezone As String, _
ByRef txtEdit As TextBox)

Dim sb As New System.Text.StringBuilder
Dim rootkey As RegistryKey
Dim subkeyvalues As String()
Dim subkeyvalue As String
Dim keyname As String
Dim b As Byte()
Dim i As Integer

txtEdit.Clear()

sb.Append(basetzikey)
sb.Append(timezone)
keyname = sb.ToString

' clear stringbuilder
sb.Remove(0, sb.Length)

rootkey = Registry.LocalMachine
subkeyvalues = rootkey.OpenSubKey(keyname, False).GetValueNames
For Each subkeyvalue In subkeyvalues
sb.Remove(0, sb.Length)
sb.Append(subkeyvalue)
sb.Append(": ")
sb.Append(rootkey.OpenSubKey(keyname, False).GetValue(subkeyvalue).ToString)
sb.Append(vbCrLf)
If (subkeyvalue = "TZI") Then
b = rootkey.OpenSubKey(keyname, False).GetValue(subkeyvalue)
i = BitConverter.ToInt32(b, 0)
sb.Append("Bias: ")
sb.Append(i.ToString)
sb.Append(" minutes.")
sb.Append(vbCrLf)
End If

txtEdit.AppendText(sb.ToString)
Next
End Sub
End Class

Labels: , ,

posted by Brad Prendergast at 6:30:00 AM (2 comments)
Links to this post
Permalink
Sunday, April 09, 2006
Where is the registry in .NET?

Back in January, I posted about retrieving system Time Zone Information. Without going into a verbose explanation of why, I decided to move the application that utilizes this code to .NET. In the process of moving this application ‘forward’ (Is moving to .NET considered going forward?) I got the impression that the registry might have lost some importance in .NET. What is the basis for my initial feeling? Well, first take a guess at the namespace where Registry access resides…. If you guessed Microsoft.Win32 you guess right.

With that being said, and not dwelling on the fact that they places registry access into the Win32 namespace (don't forget to put that in your uses clause) I went ahead and created a new WinForm application with a System.Windows.Forms.ComboBox (cbxTimeZone) and System.Windows.Forms.TextBox (txtOutput). I changed the Multiline property of the TextBox to True and set it to ReadOnly.

I changed up the code as follows:
const
basetzikey = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\';

procedure TWinForm.FillComboBox(cbxCombo: ComboBox);
var
rootkey: RegistryKey; //Microsoft.Win32.RegistryKey
subkeynames: array of string;
subkeyname: string;
begin
cbxCombo.Items.Clear;
rootkey:= Registry.LocalMachine;
subkeynames:= rootkey.OpenSubKey(basetzikey,false).GetSubKeyNames;
for subkeyname in subkeynames do
cbxCombo.Items.Add(subkeyname.ToString);
end;

procedure TWinForm.FillTextEdit(timezone: string; txtEdit: TextBox);
type
bytearray= array[] of byte;
var
sb: System.Text.StringBuilder;
rootkey: RegistryKey; //Microsoft.Win32.RegistryKey
subkeyvalues: array of string;
subkeyvalue: string;
keyname: string;
b: bytearray;
i: Smallint;

begin
txtEdit.Clear;

sb:= StringBuilder.Create;
sb.Append(basetzikey);
sb.Append(timezone);
keyname:= sb.ToString;

sb.Remove(0, sb.Length);

rootkey:= Registry.LocalMachine;
subkeyvalues:= rootkey.OpenSubKey(keyname,false).GetValueNames;
for subkeyvalue in subkeyvalues do
begin
sb.Remove(0, sb.Length);
sb.Append(subkeyvalue);
sb.Append(': ');
sb.Append(rootkey.OpenSubKey(keyname,false).GetValue(subkeyvalue).ToString);
sb.Append(#13#10);
if subkeyvalue = 'TZI' then
begin
// you could reporduce the TIME_ZONE_INFORMATION record
// I am just looking for the BIAS which is the first two bytes
// of the structure

b:= bytearray(rootkey.OpenSubKey(keyname,false).GetValue(subkeyvalue));// as bytearray;
i:= b[1] shl 8;
i:= i + b[0];
sb.Append('Bias: ' );
sb.Append(i);
sb.Append(' minutes.');
sb.Append(#13#10);
end;
txtedit.AppendText(sb.ToString);
end;
end;


procedure TWinForm.cbxTimeZone_SelectedIndexChanged(sender: System.Object; e: System.EventArgs);
begin
FillTextEdit(ComboBox(sender).Text,txtOutput);
end;

constructor TWinForm.Create;
begin
inherited
Create;
InitializeComponent;
FillComboBox(cbxTimeZone);
end;




The next thing I am going to experiment with is whether or not it is more efficient to clear out and reuse a stringbuilder or create a new one each time I loop through and build the strings as above.

Labels: , ,

posted by Brad Prendergast at 2:00:00 PM (1 comments)
Links to this post
Permalink
Tuesday, April 04, 2006
Managing my Newsgroups

I’ve been participating in newsgroups for many years. Newsgroups are a great way for members of a community to share and discuss information. Part of my daily ritual includes the reading/posting new messages on groups that I monitor. I used to use the Outlook Express newsreader to manage the newsgroups that I subscribe to.

One of the major issues that I had with monitoring newsgroups was that depending on where I am and what I am doing I could be checking these newsgroups from one of four separate computers. Using Outlook Express, any post that was created after the last time I had checked the newsgroups on a particular computer showed up as a new message, regardless if they were read by me on another computer. This nuisance created the need to find a newsreader that would allow me to check newsgroups from separate computers without causing read messages to show up as new if I had already read them regardless of which computer was used. After poking around I decided to give Colin Wilson’s XanaNews a shot (I currently use XanaNews and I am extremely pleased with it and I would recommend it as a newsreader). A number of things drew me to this program one of the major things is that it was written with Delphi®.

XanaNews doesn’t have any ‘written’ or ‘published’ instructions for using it on a removable storage device; however after some poking I did find all of the settings are stored in the HKEY_CURRENT_USER\Software\Woozle registry key. One of the options available in the registry and XanaNews configuration is the “Messagebase Directory”. The Messagebase Directory is where the XanaNews message files are stored. I had mentioned before that I use my 1 GB SanDisk to store all my portable files. After some experimentation I found that if I set up XanaNews with all of my preferred settings on a computer that I could export the HKEY_CURRENT_USER\Software\Woozle registry key and import it into another computer and have all the same settings. The only thing that needs to be adjusted is the location of the message base directory, depending on which drive the USB Flash Drive is assigned. This allows me to manage newsgroup messages (both on and offline) from many computers without duplicating efforts. In the XanaNews directory on my flash drive I have the message base directory program executable and my exported registry file (that I update as needed).

The only thing on my XanaNews wish-list is the option to allow for user settings to be stored to a disk file (ini) or the registry (I know it is open source). Other than that it is an excellent feature rich program and if you haven’t tried it, give it a shot.

Labels: , ,

posted by Brad Prendergast at 7:01:00 AM (4 comments)
Links to this post
Permalink
Meaningful Information

Did you realize that tomorrow at two minutes and three seconds past one o’clock the time and date will be: 01:02:03 04/05/06?

Labels: ,

posted by Brad Prendergast at 6:33:00 AM (4 comments)
Links to this post
Permalink
Recent Posts
 Command Line: Visual Source Safe
 SQL: Remove / Delete Orphan Users
 SQL Delete/Drop a User from each Database
 Is there an 'I' in phone?
 SQL Optimization: Am I missing any indexes? - Part...
 Meaningful Signature File Quotes
 My Shared RSS Items
 Edit those XML files
 A little System.Diagnostics
 Wi-Fi Detector Shirt


Labels



Archives
 October 2005
 November 2005
 December 2005
 January 2006
 February 2006
 March 2006
 April 2006
 May 2006
 June 2006
 July 2006
 August 2006
 September 2006
 December 2006
 January 2007
 February 2007
 March 2007
 September 2007
 October 2007
 November 2007
 July 2008
 November 2008
Powered by Blogger