Convert html to multipage tiff file

 Htmlsnapshot now supports converting html into multiple page tiff files. here is the sample code. You just need to specify the page width in pixel. The component will save the image into a multipage tif.

‘demo html to multipage tiff generation function

Set WshShell = WScript.CreateObject(“WScript.Shell”)
‘Declare object
Dim snap
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetTimeOut CLng(200000)
snap.SnapUrl “http://www.google.com/“, “google.tiff”

‘Set CCITT3 encoding for TIFF
snap.SetTIFFEncoder 1
snap.SaveMultipageTiff “m-google-ccitt-3.tiff”, 200

‘Set CCITT4 encoding for TIFF
snap.SetTIFFEncoder 2
snap.SaveMultipageTiff “m-google-ccitt-4.tiff”, 200

‘Set RLE encoding for TIFF
snap.SetTIFFEncoder 3
snap.SaveMultipageTiff “m-google-rle.tiff”, 200

‘Set none encoding for TIFF
snap.SetTIFFEncoder 4
snap.SaveMultipageTiff “m-google-none.tiff”, 200

snap.SetTIFFEncoder 1

‘Change thresholding when converting to monochrome
snap.SetThreshold 200
snap.SaveMultipageTiff “m-google-ccitt-4-1.tiff”, 200

Set snap = Nothing

Fedora 8 mouse invisible issue

I tried to install 64 bit fedora 8 today.

The installation went smoothly. When I came to the login interface, the mouse pointer was invisible. It was so frustrated.

I did some search on internet and  found that this problem appears on 64 bit linux with Nvida display card. So it may be a driver issue.

Fortunately there is a workaround that seems work for me.

su
gedit /etc/grub.conf

Remove the “rhgb” in the file. Then reboot again, the mouse pointer seems to come back now.

Disabling Internet Explorer Enhanced Security Configuration

Disabling Internet Explorer Enhanced Security Configuration

Preface:

Windows Server 2003 shipped with security locked down by default.  Part of this locking down is Internet Explorer Enhanced Security which is an extra layer of protection when surfing the internet using Internet Explorer (more information can be found by going here on a Windows Server 2003 [test] machine).  Some people want to uninstall it.  That’s OK, Microsoft allows that, and that’s what this will show you how to do.
Before we start, understand the way the uninstaller works.  You can uninstall the entire Configuration, or just for users, or just for Administrators.  The un-installer is set up like this:

Enhanced Security
->For Administrators
->For Users

If you have just random users connecting via Remote Desktop or Terminal Services, you may want to leave the Users configuration installed.  This tutorial will be removing all of it.

Method:

Click Start, put your mouse over Control Panel, and click Add/Remove Programs

Now click Add/Remove Windows Components

After a few seconds a window will pop-up.  Click the check mark next to Internet Explorer Enhanced Security Configuration (to make it unchecked).  If you’d like to only disable it for Administrators or only for Users you can click Details and do so.

Press Next, let it finish, and it’s complete!

Questions:

Q: How do I know if it is enabled?

A: When you open Internet Explorer up you will see this dialog

Q: How do I know if it’s disabled?

A: When you load up Internet Explorer Internet Explorer will tell you:

Caution: Internet Explorer Enhanced Security Configuration is not enabled

Resolve a GDI issue of Vista

I meet the issue on both Vista and XP. When I open several windows (maybe 10),  the system begins to show problem. The context menu cannot open or any new GUI program cannot run etc.

I did a search today and found many people met this issue.  A recommended fix is below:

 To make this change, navigate regedit to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems. The “Windows” value contains a big honkin’ string, and one part of it is “SharedSection=xxxx,yyyy,zzzz”. The second number (yyyy) is the one that you want to increase. Standard registry editing disclaimers apply, YMMV.

It seems to work after I made the change. 

More details, please see

http://support.microsoft.com/kb/184802
http://weblogs.asp.net/kdente/archive/2004/06/04/148145.aspx

PHP XMLRPC library

Recently I played with php xml rpc library. My main goal is to post articles from php to wordpress blog.

There are a lot of implementation on the web.

First I tried the one on sourceforge.

http://phpxmlrpc.sourceforge.net/

I use the library to develop method to post a new articles or edit an existing article on a wordpress blog.

The sample code is like  this:

 $content['title'] = ”A post”
 $content['description'] = $article;
 $content['categories'] = “General”;
  $c = new xmlrpc_client(“/xmlrpc.php”, “localhost”, 80);
   $x = new xmlrpcmsg(“metaWeblog.newPost”,
       array(php_xmlrpc_encode(“1″),
       php_xmlrpc_encode($blogUser),
       php_xmlrpc_encode($blogPass),
       php_xmlrpc_encode($content),
       php_xmlrpc_encode(“1″)));
   $c->return_type = ‘phpvals’;
   $r =$c->send($x);
   if ($r->errno==”0″)
   {
    echo “Successfully Posted! articel ID:”;
    print $r->val;
   }
   else
   {
     echo “xmlrpc meets some error”;
     print_r($r);
   }

But when I tried to implement uploading images with metaWeblog.newMediaObject method, the library cannot support base64 value encoding correctly.

Then I realized the library used by wordpress itself should be a good candidate. It is actually from here: http://scripts.incutio.com/xmlrpc/beginners.php

$client = new IXR_Client(‘http://scripts.incutio.com/xmlrpc/simpleserver.php’);
if (!$client->query(‘test.getTime’)) {
   die(‘An error occurred – ‘.$client->getErrorCode().”:”.$client->getErrorMessage());
}
print $client->getResponse();

This library is more easily to use. Highly recommended!

FAQ: How do I register the Audio record component?

How do I register the component?

Answer: Once you buy the component, a registration code will be sent to you by email. After creating an object instance of Active Audio Record in your favorite programming languages, calling the SetCode method with the code you got by email before recording. In this way, every limitation in trial mode will be removed.

‘Here is a quick example in VB Script:
Dim rec
‘Create the Audio Record Object

Set rec = CreateObject(“AudioCtl.AudioRecord.1″)
‘Set your code here

rec.SetCode “Your license code here”
‘Then do what ever you like …

Install php, mysql and phpMyadmin on Vista IIS7

Today I tried to install php, mysql and phpMyadmin on Vista IIS7. After several hours, I finally got it through.

Here are some tips:

1. Download latest php, mysql from their website

 I use php 5.2.4, mysql 5.0,.

2. Install IIS service on Vista by adding Windows features. Note that, you need to choose the IIS components ISAPI etc when adding the features. IIS7 seems to be componentized. so if you don’t check the ISAPI feature, php cannot run as ISAPI under IIS7

 3.  Extract php zip file to d:php.  copy the file php.ini-dist to windows folder (d:windows) and rename it to php.ini (erase the -dist part).
Now open the php.ini in notepad.

a. Inside the file, look for the line ;extension=php_mysql.dll and delete the semi-color (;) from the beginning of the line
b. Modify extension_dir to be d:phpext
c.  Set session.save_path = “D:phpphpsessions”. Make sure you make a directory  “D:phpphpsessions” and it can be written by IIS USER account.
d. Copy extphp_mysql.dll to d:windowssystem32

 3. Run IIS manager, Click “handler mapping”, Add script map

In the window that pops up, fill up the fields with these values:

“Request path:” *.php

“Executable:” d:phpphp5isapi.dll

“Name:” PHP

Note, every time you modify php.ini, you need to restart the “World Web Publishing Service” to make it take effect.

4. Install Mysql with the office setup. (You may need to open the Mysql TCP port in the windows firewall)

5.  Last, try phpinfo.php in your  IIS folder

<?php

phpinfo();

?>

You should be able to see mysql box in the output html

6. Install PhpMyAdmin, use a simple config.inc.php. It will work

<?php
$cfg['blowfish_secret'] = ‘ba17c1ec07d65003′;  // use here a value of your choice

$i=0;
$i++;
$cfg['Servers'][$i]['auth_type']     = ‘cookie’;
?>

Referrence:

http://blondr.blogspot.com/2006/11/set-up-iis-7-w-mysql-and-php-5.html

http://forums.iis.net/p/1116593/1735066.aspx#1735066

Registering DLL and ActiveX controls from code

From http://delphi.about.com/od/windowsshellapi/l/aa040803a.htm
 

Registering DLL and ActiveX controls from code 
 
How to register (and unregister) OLE controls such as dynamic-link library (DLL) or ActiveX Controls (OCX) files from a Delphi application. 
 
 
 
 
One of the features that make Delphi so popular is that when it comes to project deployment, you as a developer (in most cases) only need to send the executable file (exe) of your application.

However, in some situations, for example when you import an ActiveX control into your project, you’ll need to make sure that this ActiveX control is registered on your users machines. If the control is not registered there, an EOleSysError exception will be displayed to your user eyes.

RegSvr32.exe
The regsvr32.exe command-line tool registers dll and ActiveX controls on a system. You can manually use the Regsvr32.exe (Windows.Start – Run) to register and unregister OLE controls such as dynamic link library (DLL) or ActiveX Controls (OCX) files that are self-registerable.
When you use Regsvr32.exe, it attempts to load the component and call its DLLSelfRegister function. If this attempt is successful, Regsvr32.exe displays a dialog indicating success.

RegSvr32.exe has the following command-line options:

Regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname
 /s – Silent; display no message boxes
 /u – Unregister server
 /i – Call DllInstall passing it an optional [cmdline];
      when used with /u calls dll uninstall
 /n – do not call DllRegisterServer; this option must
      be used with /i

From Delphi code
To call the regsvr32 tool from within Delphi code, you’ll need a function that can execute a file and wait for the execution to finish.
This is how the ‘RegisterOCX’ procedure could look:

procedure RegisterOCX;
type
  TRegFunc = function : HResult; stdcall;
var
  ARegFunc : TRegFunc;
  aHandle  : THandle;
  ocxPath  : string;
begin
 try
  ocxPath := ExtractFilePath(Application.ExeName) + ‘Flash.ocx’;
  aHandle := LoadLibrary(PChar(ocxPath));
  if aHandle <> 0 then
  begin
    ARegFunc := GetProcAddress(aHandle,’DllRegisterServer’);
    if Assigned(ARegFunc) then
    begin
      ExecAndWait(‘regsvr32′,’/s ‘ + ocxPath);
    end;
    FreeLibrary(aHandle);
  end;
 except
  ShowMessage(Format(‘Unable to register %s’, [ocxPath]));
 end;
end;
 
Note: the ocxPath variable points to the ‘Flash.ocx’ Macromedia ActiveX control.

To be able to register itself, an ActiveX control needs to implement the DllRegisterServer function. In simple words, this function creates registry entries for all the classes inside the control. We do not need to worry about the DllRegisterServer function we just want to make sure it is there. For the sake of simplicity, we’ve presumed that the ActiveX control (the *.ocx file) is located in the same folder as where your application is.

The red line in the above code, does the job of calling the regsvr32 tool by passing the “/s” switch along with the full path to the ActiveX control. The function is ExecAndWait.

uses shellapi;

function ExecAndWait(const ExecuteFile, ParamString : string): boolean;
var
  SEInfo: TShellExecuteInfo;
  ExitCode: DWORD;
begin
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    lpParameters := PChar(ParamString);
    nShow := SW_HIDE;
  end;
  if ShellExecuteEx(@SEInfo) then
  begin
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
    Result:=True;
  end
  else Result:=False;
end;
 
The above, ExecAndWait, function uses ShellExecuteEx API call to execute a file on a system. If you need more examples of executing any file from Delphi, check the Start from Delphi article.

Flash.ocx inside Delphi exe
All set, but if you think twice, you’ll ask yourself “How did that Flash.ocx got there?”. You are right! If there is a need to register an ActiveX control on your user machine than you need to make sure the user has the ocx you (your program) need. One way to go is to place the entire ActiveX (or DLL) inside your applications exe as a resource. When the ocx is stored inside your exe it is easy to extract it, save to disk and call the RegisterOCX procedure. I’ve already written several articles on using resources from Delphi exe, here are some you might find useful here:

Tips: get the filename of current exe file or dll

It is good to keep some programming tips we used.

To get the filename of the application, most of the time you can call:

sFileName := Application.ExeName; // or sFileName := ParamStr(0);

Perhaps you are working on a DLL and are interested in the filename of the DLL rather than the filename of the application, then you can use this function:

function Sto_GetModuleName: String;
var
  szFileName: array[0..MAX_PATH] of Char;
begin
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  Result := szFileName;
end;

The above is from
http://www.martinstoeckli.ch/delphi/delphi.html#AppRedirectOutput