Thursday, January 19, 2006

Array var in Managed(.Net) C++

In managed C++, define an array variable for a managed class, in syntax, is different from standard C/C++. For example,


using System::Drawing;
//...
array<PointF, 1>^ pointsF = gcnew array<PointF, 1>(100);
// PointF pointsF[100]; // is wrong
// PointF pointsF[] = gcnew PointF[100]; // is wrong
//...
pointsF[0].X = 11.23f;
pointsF[0].Y = 0.54f;


where PointF is a structure defined in System::Drawing namespace.

For String class, you have define an array of String as:


array<String^, 1>^ s = gcnew array<String^, 1>(10);
//String^ s[] = gcnew String^[10]; // wrong again


The general format to define an array of type is:


[qualifiers] [cli::]array<[qualifiers]type1[, dimension]>^ var =
gcnew [cli::]array<type2[, dimension]> (val[,val...])


See MSDN on Array Keyword

Read More...

Wednesday, January 11, 2006

Windows Installer Problem

Some times I got anoying error messages when I tried to open some applications such as VB6.0. The message is like a dialog window with the message:

Setup is aborting now. Cannot detect file: mediainfo.ini


This is caused by Windows Installer when I tries to find some files based on Registry settings. For example, I removed some binary files which were installed by Windows Installer but I could not find Uninstaller for those files or I could not run uninstaller successfully.

Here are some steps to avoid these messages:

Locate missing files

  • Open Event Viewer from Administration Tools.
  • View property for the most recent warning messages in Application node, and make a note of missing file, for example, "C:\MyTools\Bin\Interop.Utility.dll".
Search for Registry settings for missing files
  • Open RegEdit
  • Locate to "My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer"
  • Search for the file with path found above. Note, do not include drive like "C:" in the search string.
  • You should find a key like this: "...\UserData\S-1-5-18\Components\D1311F8CC3D78BB42BCF6A". Under this one you will find a key Item with a value like "C?\\MyTools\Bin\Interop.Utility.dll".
Change Reistry Settings
  • What I do first is to find the missing files and copy them to a folder like "C:\MissingFiles\Installer\"
  • Then I change the registry key item's value to "C?\MissingFiles\Installer\Interop.Utility.dll".
After I change all the registry items for these missing files, I will not get warning message any more.

I am not sure if I should remove these registry keys or not. For safe purpose, I try to find missing files and udpate registry instead.

Read More...