Friday, April 21, 2006

How to incorporate ZIP functions into Classic VB Applications

VB Script, or VB6, or VBA are still the dominating office automation languages. It is important to let them be able to use the ZIP utilities too. Please note that .NET Framework may not exist everywhere, so a "native" ZIP COM, not through InterOp, is needed under this condition. Fortunately there is one for VB.

InfoZIP’s Freeware ZIP32.dll and UnZIp32.dll can be wrapped with a library CGZipLibrary.dll. To be able to Zip/Unzip from VB, you will need to: Get these three libraries.

Copy zip32.dll and unzip32.dll to c:\windows\system32 directory or c:\winnt\system32.
Regsvr32 CGZipLibrary.dll

To test, get sample VB6 Project. The sample project will zip the files in current directory to c:\ziptest.dll. Be sure to add reference to CGIZipLibrary.dll before you run.

How to test AutoPlay CD

AutoPlay CD is useful, as it automatically execute the demo or installation program when you insert this CD into CD drive. It is a powerful marketing/IT tool.

The autoplay.inf file at the root folder of the CD ROM tells the System what to do when the CD is inserted.If the content of autoplay.inf is like:

[autorun] open=Filename.exe
icon=Filename.exe,1

Then the system will execute Filename.exe at the root of the CD. The iconized image of this drive will become the icon of FileName.exe too.

Below is the link of how to make Autoplay.inf file:
http://msdn.microsoft.com/library/?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/autorun/autoplay_works.asp

Now, how do we test Autoplay CD ? Burn the CD time and test ? If something goes run then burn again ? That is terrible experience.

How about using USB drive to simulate the Insert action ? Well, Microsoft does not support USB Drive, as the Media Type declared by USB drive is not Removable Drive, which is supported, but is Removable Media, which is not supported.

Well, how about Network Drive ? Yes, you can create a folder called, say C:\AUTOPLAY and then share this folder to the network as, say, AUTOPLAY. When you map a drive, say K: from other machine, or even your own machine to AUTOPLAY, Autoplay.inf will be triggered. This approach saves time and money to burn CD again and again.

Please note that Windows has a registry to record what types of drives can run AutoPlay. You may need to make sure the network drive on your machihne does support AutoPlay by checking/modifying the registry:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/autorun/autoplay_reg.asp

Terminal Service IP Filtering on Windows Server 2000/2003

Unlike Internet Information Services (IIS),Windows Terminal Services does not have a place in the admin/config functions to Filter the IP’s such that it can only allow certain IP’s to login to the Services. This is a problem, because it opens the door for any hackers from the world to use TCP port 3389 to try to login. Even if they fail, they may have locked out many accounts when the legitimate users triy to login in.

As a matter of fact, starting from Windows Server 2000, Windows has a central place to accept or block IP traffic. It is under Administrative Tools -> Local Security Policy -> IP Security Policy. By default, all traffic inbound/outboard of any protocol for any ports are accepted.
To limit IPs to Terminal Service (TCP port 3389), or any other services like SQL Server Services, SNMP, SMTP, etc, we will need to create a Policy and activate it. A Policy contains pairs of (IP List + Actions). One the policy is set and activated, only IP’s not permitted will be allowed. For example, if we only allow IP Block 221.111.229.0/24 to access this Terminal Service, we should create an entry with this IP block and the action "Permit". After that, we should add another entry to "Deny" Any IP addresses. With these two entries in this policy, when it is activated, it will only allow this IP block 221.111.229.0/24 to access the Terminal Service. We can add more IP blocks if needed.

For step by step instructions for Windows 2000 Server, please refer to:
http://www.securityfocus.com/infocus/1559

Set up IP Security Policy for Windows 2003 Server is very similar.