2009-09-30

Batch change script for Visual C/C++ Projects

Visual C/C++ projects are XML files but they have a different file extension (*.vcproj).

Having to change an option to through tens of projects files each with more than one platform (Win32, Win64, Windows Mobile) and multiple configurations (Debug, Release) only by loading the projects in Visual Studio and clicking through the UI is not very appealing.

Since we already know that the project files are XML files one can write a program / script to change the desired option, in my case the change of the C runtime library - dynamic / static.

I have chosen WSH JScript, MSXML 3.0 and XPath to write a script to change Visual C/C++ projects. My decision was due two arguments: JScript is present on Windows XP, and the scripts can be debugged by Visual Studio 2005+ (//X command line parameter).

During the development I have stumbled on a XPath query problem, the function contains was not found in msxml3.dll. The problem was due to the fact that MSXML 3.0 was not instructed to use XPath as selection language (xmlDoc.setProperty("SelectionLanguage", "XPath");). Newer MSXML versions do not have this requirement though.

The message boxes displayed when issued from command line like change_runtime.js myproject.vcproj are due to the fact that JScript is not the default scripting language in WSH. One solution is to call the script like: cscript change_runtime.js myproject.vcproj, which requires some typing, the other solution is to change the default scripting language in WSH, which can be accomplished by running cscript //H:CScript.

The source code can be found here. Changing Visual C/C++ projects just become easier for me :-)

2009-09-19

Browsere moderne

Browserele web moderne (ultimile versiuni) știu să genereze caracterele lipsă din fonturi atunci când pagina web o cere.

Am decis să testez această funcționalitate pe un sistem Windows XP SP2, cu setările implicite (Engleză SUA), și fără actualizări. În special am urmărit cum se descurcă cu caracterele ș și ț cu virgulă, care lipsesc din fonturile cu care vine Windows XP SP2 (pentru mai multe informații a se vedea pagina lui Cristian Secară ș-uri și ț-uri). Ulterior am testat și sistemul de operare Windows 7.

Pagina de test conține o pangramă (Muzicologă în bej, vând whisky şi tequila, preţ fix.) scrisă cu familiile implicite de fonturi serif, fără serif și monospațiat în forma normală și cursivă. Setul de caractere setat a fost UTF-8.

Microsoft Internet Explorer 6


Microsoft Internet Explorer 7


Microsoft Internet Explorer 8


Mozilla Firefox 3.5.3


Google Chrome 3.0


Opera 10.0


Safari 4.0.3


Internet Explorer 6 a fost luat drept referință. Mozilla Firefox s-a descurcat cel mai bine la famillile de fonturi serif și fără serif în forma normală, forma cursivă și cea monospațiată a caracterelor ș și ț nu se integrează foarte bine cu restul caracterelor.

Pentru a repara problema caracterelor ș și ț în fonturile serif și fără serif Microsoft în luna Mai 2007 a scos un pachet de actualizare a unor fonturi din sistemele de operare Windows XP și Windows Vista.

Familia de fonturi monospațiate nu a beneficiat de o actualizare, a se vedea captura de ecran de mai jos:

Microsoft Internet Explorer 8 (cu pachetul de fonturi actualizate)



Windows 7 beneficiază de fonturi monspațiate care conțin caracterele ș și ț, a se vedea captura de ecran de mai jos:



Captura de ecran de mai sus arată o problemă în Internet Explorer 8 din Windows 7, problemă cu varianta implicită a fontului serif. Setarea "clear type" a fost activată, dar dintr-un motiv necunoscut textul este afișat foarte prost.

Mozilla Firefox 3.5.3 afișează corect caracterele ș și ț rulând pe Windows 7:



Google Chrome 3.0 afișează corect caracterele ș și ț rulând pe Windows 7:



Safari 4.0.3 afișează corect caracterele ș și ț rulând pe Windows 7:



Opera 10.0 afișează corect caracterele ș și ț rulând pe Windows 7:



Concluzie: în Windows 7 problema caracterelor ș și ț cu virgulă este deja rezolvată.

Hidden stream

If you wondered why does a security dialog pop up when you try to run the oggcodecs installer (or every executable for that matter) after downloading it from the Internet, this post is for you.

The security dialog looks like:



If you look at the file properties there is no checkbox like "this file came from the Internet" (CHM files have a check for this though), but this information is stored somewhere, in a NTFS Alternate Data Stream.

To check if a file has a NTFS Alternate Data Stream one can use the Streams utility made by By Mark Russinovich of Sysinternals fame.

Running streams oggcodecs_0.81.15562-win32.exe resulted: :Zone.Identifier:$DATA 46.

To view this "Zone.Identifier" stream I have used the more command like more < oggcodecs_0.81.15562-win32.exe:Zone.Identifier which resulted:

[ZoneTransfer]
ZoneId=3


Firefox is adding this extra information for every executable file downloaded. Does every web browser (I've tested only I few I know of) on Windows add this extra information?
  • Mozilla Firefox 3.5.3 - yes (:Zone.Identifier:$DATA 46)
  • Microsoft Internet Explorer 8.0 - yes (:Zone.Identifier:$DATA 26)
  • Google Chrome 3.0 - yes (:Zone.Identifier:$DATA 24)
  • Safari 4.0.3 - yes (:Zone.Identifier:$DATA 26)
  • Opera 10.0 - no

Interesting how the size of the stream varies with every browser. I have submitted a bug report to Opera, because they should also add this extra information to the downloaded files.

Adding the Zone.Identifier stream can be done easily with a batch file
(from_internet.cmd)

@echo off
if [%1] == [] (

  echo Usage: from_internet.cmd executable_name

) else (

  echo [ZoneTransfer]> %1:Zone.Identifier
  echo ZoneId=3 >> %1:Zone.Identifier

)


Deleting a stream can be done by using streams -d.