Sunday, March 14, 2010

GSM Survey


Hi there

Ummm..., after some time, traveling far away from home. The climate changes, people changes and many things including Mobile Base Stations.

I, Was thinking, well... U know.., the idea is to build a survey module with all the facts I can gather for a given BT i.e. Signal Strength, BS ID, Frequency, etc...

Ok.. the blog is open for your comments.

And I will update my findings. Today (Now in fact) I gonna start writing the Win CE app.

Tuesday, February 16, 2010

Warm Booting Windows Mobile 6.0

Hi...

I was playing around my new HTC Kaiser and ummm... some times feel if there is a way to reboot dis and refresh the system, specially, after installing a new program.

Find below what I found on the net... I assume you have configured your ActiveSync correctly and know basics of VC++

Ok here it is

Include this in the header of your CPP code

#include
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED,FILE_ANY_ACCESS)


extern "C" __declspec(dllimport) BOOL KernelIoControl(
DWORD dwIoControlCode,
LPVOID lpInBuf,
DWORD nInBufSize,
LPVOID lpOutBuf,
DWORD nOutBufSize,
LPDWORD lpBytesReturned);

and here is the function

KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);

Have fun..
:)

Saturday, February 13, 2010

Kicking out the Printer Driven CashDrawer

Got panic? ummm its nt that kick... I basically wanted to explain how to send the Direct I/O commands to open the Printer Driven CashDrawer connected to a POS Printer.

Prity simple...

will just paste the code snippet grabbed from my VB (VB6) Code

Private Sub CmdOpenDevice_Click()

OPOSPOSPrinter1.Open("TM-T88IVE") 'Open the PosPrinter
OPOSPOSPrinter1.ClaimDevice(10000) 'Waiting for 10 seconds to get the ctrl
OPOSPOSPrinter1.DeviceEnabled = True

OPOSPOSPrinter1.PrintNormal(2&, Chr(l27) + Chr(112) + Chr(0) + Chr(50) + Chr(250)) 'Key code for the OpenDrawer is 127, 112, 0, 50, 250

End Sub

This will just kick it out

or else, ummm u may use the CashDrawer Service Object

like this

Private Sub OpenDrawer()
OPOSCashDrawer1.Open(StandardE) 'The Name of the device is StandardE
OPOSCashDrawer1.ClaimDevice(10000)

OPOSCashDrawer1.DeviceEnabled = True

OPOSCashDrawer1.OpenDrawer


OPOSCashDrawer1.WaitForDrawerClose(100, 4500, 100, 100)

End Sub

Happy Cording

Thursday, February 11, 2010

Changing the MAC address of the NIC

Recently I wanted to change the MAC id of the NIC, and was searching in the net to find a solution for how to do this from a computer program (By not manually changing the Windows Registry). So I gonna share what I have found from my search.

Please reply to this post with ur findings.

'VB.NET 2005

Imports System.Management
Imports System.Security.AccessControl

Public Class Form1
Private Sub FillNetworkAdapters()
Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)
ListBox1.Items.Add(strAdapter)
End If
Next
End Sub

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rs As New RegistrySecurity()


FillNetworkAdapters()
Label1.Text = ""
End Sub
Private Function GetMACAddress(ByVal Adapter As String) As String
Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)
If strAdapter = Adapter Then
Return mo.Item("MacAddress").ToString()
End If
End If
Next
End Function
Private Function DoPadding(ByVal x As String) As String
Dim Ret As String
Dim z As Integer

Ret = x
If Len(x) <>
For z = 1 To 4 - Len(x)
Ret = "0" & Ret
Next
End If

Return Ret
End Function
Private Function GetRoot(ByVal Adapter As String) As String

Dim rs As New RegistrySecurity()

' Allow the current user to read and delete the key.
'
rs.AddAccessRule(New RegistryAccessRule("Karnna", _
RegistryRights.FullControl, _
InheritanceFlags.None, _
PropagationFlags.None, _
AccessControlType.Allow))


Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine

Dim i As Integer = 0

Do
Dim Root As String = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\"
Dim Last As String = DoPadding(i)
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Root & Last, True)
regKey.SetAccessControl(rs)
Try
Dim cAdapter As String = regKey.GetValue("DriverDesc").ToString()
If cAdapter = Adapter Then
Return Root & Last
End If
Catch

' Exit Do
End Try
i += 1
Loop


End Function

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim regKey As Microsoft.Win32.RegistryKey
Dim Addr As String = GetRoot(ListBox1.SelectedItem.ToString())
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Addr, True)

regKey.SetValue("NetworkAddress", "00e04c4d1dA2")

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim mc2 As System.Management.ManagementClass
Dim mo2 As ManagementObject
mc2 = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc2 As ManagementObjectCollection = mc2.GetInstances()
Dim xIP As String()
For Each mo2 In moc2
If mo2.Item("IPEnabled") = True Then
Dim strAdapter
strAdapter = mo2.Item("Caption").ToString().Substring(11)
If strAdapter = ListBox1.Text Then
xIP = mo2.Item("IPAddress")
Label1.Text = xIP(0)
End If
End If
Next
End Sub
End Class

Saturday, February 6, 2010

My first blog post

Heys

Though I was playing with computers for a very long time, this is my very first blog post. Hope to do more in here...