Thursday, August 14, 2008

Regular expressions: Remove last appearance of some element

If you want to match A, B and C but don't want C to be the last element you can do it using this regular expression:



[ABC]+(?<!C)





Note that [ABC]+ can be mutch more complex then this is.

Wednesday, August 13, 2008

Binding ASP.NET TreeView to a DataSet or an ObjectDataSource

Excellent article:

http://www.varjabedian.net/archive/2008/04/22/binding-asp.net-treeview-to-a-dataset-or-an-objectdatasource.aspx

Wednesday, August 06, 2008

Monday, August 04, 2008

Retrieve local ip address


CStringArray straIPAddresses;


straIPAddresses.RemoveAll();

WSADATA wsa_Data;

int wsa_ReturnCode = WSAStartup(0x101,&wsa_Data);

char szHostName[255];

gethostname(szHostName, 255);

struct hostent *host_entry;

host_entry = gethostbyname(szHostName);

int nAdapter = 0;

while ( host_entry->h_addr_list[nAdapter] )

{

char * szLocalIP;

szLocalIP = inet_ntoa (*(struct in_addr *)host_entry->h_addr_list[nAdapter]);

nAdapter++;

straIPAddresses.Add(szLocalIP);

}

WSACleanup();


Saturday, August 02, 2008

Detect available serial ports

You can use class found at http://www.naughter.com/enumser.html to detect available serial ports on your PC. Class is using seven different methods to enumerate serial ports.