Welcome to the CSIG, a Special Interest Group of the ACGNJ. This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs. (See the Random Access section below for an extra topic about Filtering and how the Tracking Reference syntax helps in C++ .Net CLI.)
This month we have to Step Back to avoid a Catch-22 problem. Most of the programs that I have written in the past few years have be designed for Microsoft's .NET Framework. Unfortunately, when a program is run on a computer that doesn't have the proper updates nor the .NET package installed, the program stops with a very unfriendly error message giving no clue as to the problem. Of course, Microsoft has a "solution" called "Deployment" but unfortunately it doesn't apply to anyone using the Express versions of the DOT NET compiler. The Express versions versions don't include "Setup" or "Clickonce" options for their projects.
Here's only one of several vague error messages that may be received: "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem." There's probably nothing wrong with the application. The computer just needs its software updated. (Check the software documentation just in case the software does need something special.)
This program, Query Dot Net, can be run on any computer to test compatiblilty. By "any computer" I mean Windows 98, Windows 98 Second Edition, Windows Me, Windows 2000, Windows XP, Windows Server 2003, Vista, Windows 7, etc. It reports the installed versions, if any, of .NET software and provides a button to go to the Microsoft web site and download the latest files. For many applications, this is enough. Complex "Setup programs" are not required or even desired, since often the user does not want to a) Modify the registry. b) Create new directories. c) Add Startup Menu items, etc.
This program will provide a means to discuss C++ programming in a Visual Studio enviornment. Here are some of the topics that are included in the discussion.
1. Using Visual Studio 6 (from the past). |
2. Access the registry using MFC libraries. |
3. Checking for proper DOT NET Foundation prerequisites. |
4. Listboxes and Textboxes. |
5. Adding a photo background. |
6. Program logic. |
7. Handling the Registry. |
There are a number of ways to refer to Microsoft's latest compilers and code. Here's what Wikipedia says: The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.
Microsoft .Net Framework 3.5 |
C++ 9.0 |
.Net 3.5 |
CLI |
Common Language Infrastructure |
Managed |
/////////////////////////////////////////////////////////////////////////////
// QueryRegistry() Enumerate any installed versions and display
void CQueryDotNetDlg::QueryRegistry()
{
long xx; char name[BUFFSIZE]; HUSKEY hKey1; DWORD index, count, dataType;
// IN IN IN OUT
xx=SHRegOpenUSKey(REG_USER_AGENT, KEY_READ, NULL, &hKey1, TRUE);
if (ERROR_SUCCESS != xx) return;
index = 0;
while(1) // Enumerate Values under HKLM
{
count = BUFFSIZE;
// IN IN OUT IN-OUT OUT
xx=SHRegEnumUSValue(hKey1, index, name, &count, &dataType, NULL, NULL, SHREGENUM_HKLM);
if (ERROR_SUCCESS != xx) break;
if (strlen(name) > 0)
{
m_Category.AddString(name);
}
++index;
}
SHRegCloseUSKey(hKey1);
}
//
// Launch the browser and go to the Microsoft Download site.
//
#define DOWNLOAD_SITE \
"http://www.microsoft.com/downloads/details.aspx
?familyid=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en"
void CQueryDotNetDlg::DownloadSite()
{
ShellExecute(this->m_hWnd,"open", DOWNLOAD_SITE, NULL, NULL, SW_SHOWMAXIMIZED);
}
void CQueryDotNetDlg::OnButton1()
{
GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
DownloadSite();
GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
}
A special topic about Digital Filtering and how the Tracking Reference syntax helps in C++ .Net CLI. will also be discussed. The syntax is new to the .Net compiler and also relates to interior pointers, "interior_ptr". Through the use of this new syntax no only can programs be designed more effeciently, but they also can be made to run faster.