Home | Blog | Publications | Photos | Services | About | Contact

Blog Archive - January, 2007

Back to Blog index.

Wed, 31 Jan 2007 14:40:22 GMT:
A free .NET book from Charles Petzold

I learned earlier this week that Charles Petzold, one of THE C/C++ programmers and Windows specialists, has published a new, free eBook for .NET developers that covers the basics of the environment. It is called ".NET Book Zero", and is available from his site in PDF and XPS formats. Go download your copy today! Thanks JH for the tip.

Mon, 29 Jan 2007 08:39:31 GMT:
HD Photo, a new file format from Microsoft

Another digital photography related post, but also interesting for software developers: Microsoft has announced a new file format for high-definition still images (think photographs) called "HD Photo", which was formely called Windows Media Photo.

This file format is the "JPEG killer" that Microsoft proposes as the future native file format for digital cameras. (Another is Adobe's DNG, but that's a different story.)

For us programmers, the interesting thing is that .NET Frameworks 3.0 can be used to manipulate HD Photo files, however I'm yet to check which APIs these would be. CNET News also has a report about the new file format.

Sat, 27 Jan 2007 05:38:08 GMT:
A free digital photo information tool from Microsoft

Microsoft has announced the availability of a new free tool called "Photo Info 1.0." This tool is useful for photographers (and why not for programmers as well, why need to manipulate or use digital photos in their applications), as it allows to "add, change and delete common metadata properties for digital photographs from inside Windows Explorer."

The tool supports JPEG, TIFF, WDP, HDP (HD Photo), NEF and Canon CR2 files, and can be downloaded from Microsoft's web site.

Fri, 26 Jan 2007 17:44:30 GMT:
Bringing back the Delphi classics: my articles from 1996-1998 again available

If you are a long-time Delphi enthusiast, you might recall the mid-to-late 90s when Delphi 1 and 2 rocked the 16-bit and 32-bit Windows development. At that time, in 1996 to 1998, I maintainced a site similar to this one you are reading now, but because of changing computers and migrating from floppy-based backups to tape/optical media (yes, it's true), I didn't bother to copy the old articles to one of the new looks of the site about 10 year ago.

Still, even today I receive requests from time to time whether I would have a copy of these articles. For example, my semi-legendary article about my MMX assembler for Delphi 2 is one of the top-requested articles, and thus I took a time machine and went and fetched the old articles back.

So here you go: the first two articles I rescued from the mists of time:

I've also uploaded the links to these articled to my Publications page, where I've a created a new section named "Archive". Enjoy!

Thu, 25 Jan 2007 16:28:57 GMT:
My HDR photography article in Tietokone

The January 2007 issue of the Finnish Tietokone magazine has my HDR photography article (High Dynamic Range) on pages 68-69. Enjoy!

Thu, 25 Jan 2007 15:14:31 GMT:
Download a book excerpt to learn Windows Presentation Foundation

I was reading TheServiceSide.net today when I noticed that they offer a free download of an excerpt of Adam Nathan's book, "Windows Presentation Foundation Unleashed". You can download the book's Chapter 3, "Important New Concepts in WPF" (about 35 pages) in PDF format.

Wed, 24 Jan 2007 15:05:50 GMT:
Nostalgy: the legendary role playing game: Rogue

Back in the 1990s, ASCII based games (or, should I say ANSI?) were popular, and among them the classic "Rogue", which was a role-playing game (RPG) and a Dungeons & Dragons clone on the PC. As you can guess, I used to play the game quite often back then, but since I moved to Windows and another PCs, my Rogue game was lost, and I didn't have the time to dig it from my backup floppies. I don't know where I got the idea just today, but I found out that I missed by Rogue sessions, so it was time to find the game from the Internet. Luckily, I was able to succeed.

To get started with Rogue, you can download Rogue for MS-DOS (works also under Windows XP/Vista) as a ZIP file from ClassicGaming.com, and also directly from my site, in case the download link becomes unavailable in the mists of time. Happy gaming!

(It would be also interesting to port Rogue to C# and Windows Presentation Foundation. Volunteers, anybody?)

Mon, 22 Jan 2007 15:03:12 GMT:
List of bugs fixed in Fixed in Visual Studio 2005 SP 1

Microsoft has announced a list of customer-reported bugs in Visual Studio 2005, that were fixed in Service Pack 1. The list contains almost 400 bugs, which is a great indication why you should report bugs that you find (or vote for them, in case they are already reported), instead of letting "somebody else" report it.

Fri, 19 Jan 2007 14:17:56 GMT:
Where is your blog located geographically?

I recently learned about a new service for bloggers called FeedMap, which takes your blog feed URL, and locates it on a map, given your manual help, or special tags on your web site. Kind of a cool invention, but when I tried it myself, I wasn't able to correctly pinpoint my blog location (my home, actually), since the pointer always updated it about half a mile in the wrong direction. But nonetheless, it looks nice to have a map. :-)

Thu, 18 Jan 2007 17:04:43 GMT:
Next Delphi version to use the MSBuild engine

I was just reading the Borland/CodeGear blogs, when I noticed that there was an entry pointing to what Nick Hodges (Delphi Product Manager) had said about the forth-coming version of Delphi, codenamed Highlander. Nick mentioned that Delphi will in the future be using Microsoft's MSBuild engine/platform for building projects, which should be great news for developers wanting to better customize and and automate builds (one hand up here). Good going, CodeGear.

Thu, 18 Jan 2007 16:50:26 GMT:
Finnish MVP Summit at Luosto, Lapland

Microsoft Finland arranged earlier this week an MVP Summit for Finnish MVPs and candidates. In addition, many ITpro.fi group leaders were present, and we brainstormed future developments regarding the site and the Finnish IT professional communities. The location was Luosto in Finnish Lapland, and good weather graced us there. Thanks a lot to Janne & Nina for the arrangements and the possibility to be there, and thanks to everybody else foor good company!

Sat, 13 Jan 2007 09:47:07 GMT:
Converting a local path to an UNC path with WNetGetUniversalName from C#

Using shared (mapped) network drives is common in many organizations, but sometimes you want to convert the local path (say, U:\) to the UNC path and share name to become computer-independent. The Windows Win32 API has the function named WNetGetUniversalName that is able to do such a conversion, but how would you call this method from managed code? Here's the solution.

Firstly, you need to define the function WNetGetUniversalName as an external function so that you can use using .NET P/Invoke. The function declaration is:

[DllImport("mpr.dll")]
public static extern int WNetGetUniversalName(
  string lpLocalPath,
  int dwInfoLevel,
  ref StringBuilder lpBuffer,
  ref int lpBufferSize);

Next, you will need several constants to help you with this function:

const int UNIVERSAL_NAME_INFO_LEVEL = 1;
const int ERROR_MORE_DATA = 234;
// optional:
const int ERROR_NOT_CONNECTED = 2250;
const int MAX_PATH = 260;

Here, only the first two constants are needed, but the two latter can be useful as well. For example, if you pass in an invalid network share name, such as one that doesn't exist, WNetGetUniversalName will return ERROR_NOT_CONNECTED (2250).

Now then, here's a wrapper around the said API function:

public string ConvertLocalPathToUnc(
  string localPath)
{
  StringBuilder buffer = new StringBuilder();
  int size = 0;
  // First call WNetGetUniversalName with an
  // empty buffer to get size of buffer needed.
  int retVal = WNetGetUniversalName(
    localPath, UNIVERSAL_NAME_INFO_LEVEL,
    ref buffer, ref size);
  if (retVal == ERROR_MORE_DATA)
  {
    // WNetGetUniversalName returns the space
    // needed in size, now allocate space for a
    // buffer of this size.
    buffer = new StringBuilder(size);
    retVal = WNetGetUniversalName(
      localPath, UNIVERSAL_NAME_INFO_LEVEL,
      ref buffer, ref size);
    if (retVal != 0)
    {
      throw new Win32Exception(retVal);
    }
  }
  else
  {
    throw new Win32Exception(retVal);
  }
  return buffer.ToString();
}

Here, I'm first calling WNetGetUniversalName with a buffer of zero size, in which case WNetGetUniversalName returns the proper size of the buffer needed. Then I re-allocate a StringBuilder object with the given size, and call WNetGetUniversalName again. If errors occur, the code raises a Win32Exception. For example, in the case of the ERROR_NOT_CONNECTED error, the exception message is "This network connection does not exist."

Finally, here's an example how to call the ConvertLocalPathToUnc method:

string localPath = "U:\\";
string unc = ConvertLocalPathToUnc(localPath);
MessageBox.Show(localPath + " = " + unc);

This would simply display on the screen a message box with text similar to the following:

U:\ = \\myserver\myshare\

Keywords: howto, c#, .net, how to convert path to unc, get unc path from local path, network path, network share

Fri, 12 Jan 2007 15:20:43 GMT:
Interesting list of C# and Delphi blogs

I was surfing the Internet for C# information, and learned that Charlie Calvert from Microsoft (and ex-Borlander) has a nice list of C# bloggers, mostly from the Microsoft Visual Studio team.

I also today learned about a new Borland/CodeGear related Delphi web site, that tries to aggregate all "important" Delphi blogs into one feed. The site can be found at DelphiFeeds.com. The site also monitors the Delphi newsgroups.

Happy reading!

Wed, 10 Jan 2007 14:52:30 GMT:
SQL Server connection strings and ADO.NET

When you are connecting to a SQL Server 2005 database with ADO.NET using for example C# or Delphi, the IDEs are able to build default connection strings easily. For example, to connect to a server named "SERV-DB" and the database "SALES", you would use a connection string like the following (on a single line):

Data Source=SERV-DB;Initial Catalog=SALES;
User ID=myname;Password=mypassword;

However, things get tricky when your database server hosts multiple SQL Server instances, each of which must run on different TCP/IP ports. In such a case, it is difficult (it was, for me at least) to find the proper documentation how to do this properly. For example, your database administrator might tell to you that the SQL Server instance you need to connect to is named "ERP" and the TCP/IP port number would be 1386 and not 1433, which is the default port for the default instance.

In such a case, you need to specify the instance name and the port number in the "Data Source" atrribute of the connection string as follows: "Data Source=servername\instance,port". Given the above example names, the full connection string would be the following. Note how you should also specify the network library as "dbmssocn" (the socket library) so that the ADO.NET provider knows that you want to connect using TCP/IP:

Data Source=SERV-DB\ERP,1386;Initial Catalog=SALES;
Network Library=dbmssocn;User ID=myname;Password=mypassword;

That should solve your connection string problems.

Keywords: howto, specify sql server instance and port number, connect to different instance, change sql server port, ado.net connection string.

Mon, 08 Jan 2007 18:29:09 GMT:
My Windows Vista article in TDM

The latest issue 137 of The Delphi Magazine (TDM) has published my article "What's New In Windows Vista?". This article takes a deep dive into the new features and APIs that exist in Windows Vista. I did aim the article especially for Win32 developers, since Borland/CodeGear doesn't yet have much to offer for .NET 2.0/3.0 (ex-WinFX) developers.

I hope you enjoy the article. As always, feedback is welcome.

Sat, 06 Jan 2007 09:32:59 GMT:
Microsoft Word turns 18

Although I use either Borland/CodeGear Delphi or Visual Studio almost every day, there's one application I probably use even more often: word processing. And in my case, this application is Microsoft Word (when I'm not using Notepad or UltraEdit). Word has recently come to the respectable age of 18 years, as eWeek reports.

When you think about it, no matter how hard-core programmer you are, you probably need to use Word at least from time to time: for e-mail (if you use Outlook+Word for that), documentation, specifications, and so forth. Although the essentials of word processing haven't changed much since the first version of Word for Windows, the fact that Word is today very customizable piece of software and also highly programmable, makes it more than just a word processor. In fact, some ISVs have integrated their applications to Office platform so deeply, that the user doesn't need to step away from Word, Excel or Outlook. Developing add-ins and solutions for 2007 Office System is something I definitely want to investigate further this year. Stay tuned!

Wed, 03 Jan 2007 15:04:39 GMT:
Programmers again to blame of bad user experience

If you are designing software with a GUI or developing web applications, you need to take into consideration how your users view and use your solution. The adage that "software is too difficult to use" is so old that many of us sometimes overlook it, especially when people with seemingly little understanding about IT complain about it.

But, there's still something to think about as eWeek reports. These articles always seem to start in the same way, but if you have the endurance to read to the end of the article, you will find the discussion about providing options to users.

As developers and often also technology enthusiasts, we like control. Giving the user the option to customize your application and set options/preferences is good for us, but not often so to the average user. Too little options can make the "power users" skip your program, and too many can make the basic users complain about difficulty. Something to think about.

In case you haven't yet made your New Year's Resolution, this is a good one: let us try to write application that even more users find easy to us. But of course, you can't always please everybody.

Tue, 02 Jan 2007 14:11:49 GMT:
So you thought development tools couldn't be a security risk?

Happy New Year 2007 to everybody! If you're reading this through your RSS reader, then you have successfully changed the URL of my blog.

Back to business then: when we develop software, we usually don't think that the development tool could be itself a security risk, while we still understand that the applications we write can become security risks if not written properly. However, modern development tools are complex applications, and thus can be vulnerable just as any other application.

For example, your loved Visual Studio 2005 has a security issue that affects the Professional and Team Editions. Microsoft has released the Security Bulletin MS06-073 regarding this issue in December. If you haven't applied this patch, now would be a good time to do so.

 

› Blog Archive