Friday, August 26, 2011

Say, you need to return an array of strings from a COM "interop" object implemented on C# to be able then access to its items from a code on VBScript.

The only correct way to do that is make the method to return the VARIANT which is an array of VARIANTs, not strings.
In other words, the return value of the VBScript's VarType() function has to be 0x200C, not 0x2008 ! Only then VBScript will be able to access the array's members.

In the C# terms, you need to make the code look like follows:


public Object f() { // the function returns (VARIANT *)
Object[] a = new Object[3]; // which is an array of VARIANTs
a[0] = "a"; // each of them contains a string
a[1] = "b";
a[2] = "c";
return a;
}

Thursday, August 25, 2011

cmd variables tricks

Get the variable value with replaced part to some new string:
%variable:wildcard_string=new_string%
Get only part of the variable:
%variable:~num_chars_to_skip%
%variable:~num_chars_to_skip,num_chars_to_keep%
%variable:~num_chars_to_skip_from_start, -num_chars_to_skip_from_end%
%variable:~-num_chars_to_skip_from_end,num_chars_to_keep%
%variable:~-num_chars_to_skip_from_end,-num_chars_to_skip_from_end%
other variable substitutions can be found in the command-line reference

Sunday, August 21, 2011

Pulse

In Debian squeeze videos played in the Adobe flash player had no sound.
A solution - activate the virtual "Pulse" audio driver and make it to be the default.
To do that, create file /etc/asound.conf or ~/.asoundrc with the following content:

pcm.pulse {
type pulse
}

ctl.pulse {
type pulse
}

Thursday, June 23, 2011

Browser pas

Desperate one behaves vilely. Opera installer v11.11 made that browser default without asking me (I can swear, no questions were asked). To return the IE as default browser (not that I like or use IE for browsing, but to make it start first for test purposes) I had to modify the registry.
As it turned out, the HKCR hive is not a link but a cascade union of the HKEY_LOCAL_MACHINE\SOFTWARE\Classes and then HKEY_CURRENT_USER\Software\Classes. So, modifying one branch, make sure there is no the same in the second place which will override the values.

Wednesday, June 15, 2011

A certification pit

Each time we need renew or issue a new certificate for test web servers it becomes a quest. The certification server is installed on a windows 2003 server and each time it behaves different. I wonder, if somebody noticed that too?
It works differently in different browsers, and does not let you in even with IE until the browser's advanced security property "Enable Integrated Windows Authentication" is off.

Monday, May 9, 2011

USB drive instead of Floppy.

Some things beyound my understanding. Here is a story. After a windows update on our DELL server, windows 2003 refused to boot, even in the safe mode. We decided to run the recovery from the installation DVD. But the problem instantly occured - the installer did not recognize the DELL's PERC/5i RAID controller. The machine did not have a floppy drive (even though the motherboard actually has a floppy connector on it). We contacted the DELL tech support and were told to put the PERC driver to a USB flash drive using special utility available also to download (the content of the drive was gone, so saddly to say). Then, standard F6 key worked and the installer saw the driver on the USB drive as it was a floppy disk.
How it did that? No clue.

Friday, April 8, 2011

COM to .NET

How to make a .NET class library be accessible as a COM object?
  1. Create a new .net class library project for the wrapper
  2. Declare the class as "ComVisible":
    using System.Runtime.InteropServices;
    [ComVisible( true )] public class ClassName
  3. Generate the Keyfile:
    C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\sn.exe -k "keyfile.snk"
  4. Set the project property to sign the library using the generated keyfile
  5. Generate the Registry entry with the path to the library .dll as the "codebase":
    regasm.exe %TRGDIR%\LibName.dll /codebase
    Specify also the /tlb option if the library is to be imported by the C++ #import directive
  6. Check the registry has the ProgId: LibName.ClassName and refers to the CLSID which has the "codebase" path to the LibName.dll