Tuesday, December 28, 2010

How to enable multi-region on DVD Drive Matshita UJ892

In a typical laptop DVD Drive, you will only have 5 times to set the Region Code of the physical drive.

You can patch the DVD Drive's firmware to allow unlimited setting of the Region Code.

This entry is tested for Matshita DVD Drive model UJ892 only.

1. Download the firmware flashing tool : "MatshitaWinDump" and "MatshitaFlash".
Link here
2. Follow the instruction on the website to do the backup of your DVD Drive's firmware and to create a patched firmware.
3. Follow the instruction on the website to run the flashing program to flash to the patched firmware.
4. Install DVD43 to enable decrypting of your DVD.
Link here

Wednesday, December 15, 2010

Simulating keypress

The following code will allow you to simulate the keypress of the keyboard.
This function accepts a string to simulate typing them. It will press the Enter key at the end of the simulation. The code will handle pressing of the "Shift" key when needed.

C++ Source code. MFC.

===============


void SendKeypress(CString strText)
{
int len, i;
char c;
len = strText.GetLength();
for (i = 0; i < len; i++) {
c = strText[i];
WORD vkey = VkKeyScan(c);
WORD shift = HIBYTE(vkey);
BYTE scan = MapVirtualKey(vkey, 0);
if (shift) {
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT,0), 0, 0);
}
keybd_event(vkey, scan, 0, 0);
keybd_event(vkey, scan, KEYEVENTF_KEYUP, 0);
if (shift) {
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT,0), KEYEVENTF_KEYUP, 0);
}
}
// Press "Enter"
keybd_event(VK_RETURN, 0x1c, 0 , 0);
keybd_event(VK_RETURN, 0x9c, KEYEVENTF_KEYUP, 0);
}

Simulate clicking of mouse buttons

The following code allows you to simulate clicking of the mouse button programmatically.
It will remember the current cursor position, move to the coordinate to click, perform the click and restore the cursor position.

C++ source code.

===============

void ClickOnPoint(int x, int y)
{
POINT prevPt;
GetCursorPos(&prevPt);
SetCursorPos(x, y);

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

SetCursorPos(prevPt.x, prevPt.y);
}

Check whether a file exist in C++

The following code allows you do check whether a particular file exist.

C++ source code. Using Shell API.

=======

BOOL CheckFileExist(LPCTSTR lpszFullPathName)
{
BOOL bResult = FALSE;
SHFILEINFO shfileinfo;
if (SHGetFileInfo(lpszFullPathName, 0, &shfileinfo, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME) != 0) {
// File Exist
bResult = TRUE;
}
return bResult;
}

Monday, October 25, 2010

How to extend Windows XP grace period

When you install a fresh Windows XP, you are given 30 days grace period to activate the OS. You can use the following method to extend the grace period by another 30 days.

You have to do this before your grace period is over.
eg, 1-2 days before it activation is required.

Steps:
1. Open a command prompt.
2. Copy and Paste the following into the command prompt.
rundll32.exe syssetup,SetupOobeBnk
3. Launch Event Viewer (from Administrative Tools in Control Panel). Click on "Application". You will see 1 entry called "Windows Product Activation".
4. Double click on that entry and you will see this "Your Windows product has not been activated with Microsoft yet. Please use the Product Activation Wizard within 30 days. ".
5. Now you have another 30 days of grace period again.

You can repeat this process when the 30 days is ending again. However, you can only do this for 3 times. After that, this method will not work.

Monday, August 30, 2010

Failed to install Visual Studio 2008 SP1

If your system has Microsoft Office installed, you may encounter problem when installing Visual Studio 2008 SP1.

The log shows the "Visual Web Developer" is causing the error.

Here is a solution that works for me. You can give it a try.

=======

Rename (or Delete) these two registry keys:

HKEY_CLASSES_ROOT\Installer\Products\00002109120000000000000000F01FEC

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\00002109120000000000000000F01FEC

Renaming the directory

C:\Program Files (x86)\Microsoft Web Designer Tools\VWD

To

C:\Program Files (x86)\Microsoft Web Designer Tools\Junk



(source : http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/315c7885-e680-4a83-b6a5-8a2795f596ea )

Tuesday, August 24, 2010

WinMobile - How to receive SMS

Windows Mobile, C#

Using MessageInterceptor object to receive SMS.
This is not able to read SMS already in the Inbox.


using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;

MessageInterceptor _interceptor = null;

private void Form_OnLoad(object sender, EventArgs e)
{
_interceptor = new MessageInterceptor();
_interceptor.MessageReceived += new MessageInterceptorEventHandler(Interceptor_MessageReceived);
}

void Interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
{
SmsMessage msg = e.Message as SmsMessage;
if (msg != null)
{
System.Diagnostics.Debug.WriteLine("From: " + msg.From.Address);
System.Diagnostics.Debug.WriteLine("Body: " + msg.Body);
}
}

WinMobile - How to retrieve a web page

Windows Mobile, C#

The following function is for retrieving a web page from given URL.

bool RetrieveWebPage(String strUrl, ref String strReturn)
{
bool results = true;

try
{
HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create(strUrl);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
StringBuilder strbuilder = new StringBuilder();

while (readStream.EndOfStream == false)
{
strbuilder.Append(readStream.ReadLine());
}
response.Close();
readStream.Close();
strReturn = strbuilder.ToString();
}
catch (Exception e)
{
strReturn = "";
results = false;
}

return results;
}

Wednesday, May 12, 2010

Outlook error "Unable to open the Outlook window"

Yesterday I encounter an error in my Outlook. It is able to run but when it at the stage of opening the email window, it prompts the error "Unable to open the Outlook window". Or something similar, I can't remember the exact text.

I did some tracing and found that it is trying to read something from a XML.
C:\Documents and Settings\\Application Data\Microsoft\Outlook\Outlook.xml

My copy of the XML file is corrupted. Fortunately, I have a backup of it. I replaced the corrupted copy and my Outlook is back working.

Sunday, April 25, 2010

MapInfo : Setting default drawing Style

How to set the default drawing Style for the AddMapTool ?

AddMapToolProperties addMapToolProperties = mapControl1.Tools.AddMapToolProperties as AddMapToolProperties;
CompositeStyle cs = addMapToolProperties.CompositeStyle;
LineWidth lw = new LineWidth(5, LineWidthUnit.Pixel);
SimpleLineStyle ls = new SimpleLineStyle(lw, 2, Color.Blue, false);
addMapToolProperties.CompositeStyle.LineStyle = ls;

You create the AddMapToolProperties and change the CompositeStyle according to what you want and then use this addMapToolProperties when creating your AddMapTool.

MapInfo addMapTool

Using the MapInfo various addMapTools (AddCircleMapTool, AddEllipseMapTool, AddLineMapTool, AddPointMapTool, AddPolygonMapTool, AddPolylineMapTool, AddRectangleMapTool, AddTextMapTool), how do you specify which Layer should the Tool add its item onto ?

The answer is to use the ToolFilter and the addMapToolsProperties.InsertionLayerFilter() function.

See the code below.

AddMapToolProperties addMapToolProperties = mapControl1.Tools.AddMapToolProperties as AddMapToolProperties;
ToolFilter toolFilter = (ToolFilter)addMapToolProperties.InsertionLayerFilter;
if (toolFilter != null && !toolFilter.IncludeLayer(myLayer2.MapLayer))
{
toolFilter.SetExplicitInclude(myLayer2.MapLayer, true);
}

After which, use the new "addMapToolProperties" when you create your AddMapTool.