tag:blogger.com,1999:blog-25848177755112617142024-03-13T23:22:18.838-07:00Let's Tech TrekNaresh Mirkhelkarhttp://www.blogger.com/profile/12903549130608983867noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2584817775511261714.post-34225249347820489102010-10-29T14:21:00.000-07:002010-11-09T11:17:39.812-08:00Unlock the Windows Mobile Device programmatically<div style="text-align: center;"><br /></div>Windows Mobile 6.5 comes with a 'lock' mechanism just like any other mobile device .This feature has been available since Pocket PC days, although the mechanism was a little different. Though this built in locking feature was available, many companies and users had to build their own locking feature as no direct API/Handle was available for granular control of locking and timing.<div><br /><div>Most of the cases, these locks are not password protected by users, and the sole intention of locking is to prevent any unwitting access to applications on Today screen.</div><div><br /><div>Now, there are situations where the device is locked and the user warm boots the device. Under certain conditions when the device warm boots, the OS takes the user back to the locked state. Though unlocking the device is as simple as sliding the button (as shown in picture)</div><img src="http://4.bp.blogspot.com/_3lJK_bkt2-g/TMs98d0pz7I/AAAAAAAAAAc/6Hr0ZLpLXmU/s320/LockedState.bmp" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 281px; height: 320px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5533584676161703858" /><div>If not in all the cases, there are some cases where some start up applications run on a warm boot and come on top of today screen (controlled by its Z-index), eventually to find the focus being stolen by unseen lock screen hidden behind this app. Now the user is bogged under the real 'dead lock' scenario, he can neither close the app on top of the screen nor unlock the device, a catch-22 situation. </div></div><div>To avert such situation any start up app should ensure that the device is either programmatically unlocked and stay behind the lock screen. I couldn't find the way of keeping the app being the lock screen, but definitely found of way of unlocking the device..courtesy the Remote Spy tool shipped with VS.NET 2005+ onwards.</div><div>This tool helps in trapping all hte messages an open windows goes through. A quick look at the editor showed that lock runs under the name of "ConfettiLockScreen". By sending the right messages in right order simulates a 'slide' event and voila... unlocks the device.</div><div><br /></div><div><div><br /></div><div> [DllImport("coredll.dll", EntryPoint = "SendMessage")]</div><div> extern public static Int32 SendMessage(</div><div> IntPtr hWnd, // handle to destination window</div><div> uint Msg, // message</div><div> uint wParam, // first message parameter</div><div> uint lParam); // second message parameter</div><div><br /></div><div> [DllImport("coredll.dll", EntryPoint = "FindWindow")]</div><div> extern public static IntPtr FindWindow(string className,</div><div> string windowName);</div><div><br /></div><div> public Form1()</div><div> {</div><div> InitializeComponent();</div><div> IntPtr hwnd = FindWindow("ConfettiLockScreen", null);</div><div> if (hwnd != null && hwnd != IntPtr.Zero)</div><div> {</div><div> SendMessage(hwnd, 0x00000111, 0x00004076, 0 ); //WM_COMMAND</div><div> SendMessage(hwnd, 0x00000008, 0, 0); //WM_KILLFOCUS</div><div> SendMessage(hwnd, 0x00000281, 0, 0xC000000F); //WM_IME_SETCONTEXT</div><div> SendMessage(hwnd, 0x00000282, 0, 0x00000001); //WM_IME_NOTIFY</div><div> }</div><div> else</div><div> MessageBox.Show("Could not get handle to lock object");</div><div> }</div></div><div><br /></div><div><br /></div><div><br /></div></div>Naresh Mirkhelkarhttp://www.blogger.com/profile/12903549130608983867noreply@blogger.com0tag:blogger.com,1999:blog-2584817775511261714.post-64895037239552837492010-06-22T12:51:00.000-07:002010-07-29T07:45:21.529-07:00What Windows Phone 7 offers CF developers?Yesterday I was looking for some insights on Windows Phone 7 and what it offers for Windows Mobile developers. After going through the MS sites, it seems Microsoft wanted to bridge the gap between full framework and compact framework developers, or essentially make any .Net developer (who uses Silverlight) a Windows Phone developer.<br /><br />So, in other words, rug has been pulled under the legs of developers who are working with .Net CF :-)<br /><br />Stumbled across this good book from Charles Petzold. Scheduled to be released by year end, but has few review chapters that focuses on what Windows Phone 7 is all about. A definite good read.<br />http://www.charlespetzold.com/phone/index.html<br /><br /><br />In a nutshell...<br />1. .NET CF is OUT (ironically, it is still the core runtime engine .NET CF 3.7 on the device, but framework is not available for developers)<br />2. Silverlight and XNA are IN<br />3. WP7 defines the hardware and not the OEM's<br />4. No custom SIPs<br />5. C/C++ is also OUT. NO native coding. Only Managed.<div>6. Doesn't support copy/paste</div><div>7. No Mutiltasking. very unlike WM 6 Series.<br />8. SQL CE - This is not part of CTP, but seems to be in works and will be released later. Till then its either Isolated Storage or XML files.<div><br /><br />Still needs to see if Windows Phone is specific for Smart phone or can scale up to Enterprise level applications that Windows Mobile has been supporting using a technology mix.</div></div>Naresh Mirkhelkarhttp://www.blogger.com/profile/12903549130608983867noreply@blogger.com0tag:blogger.com,1999:blog-2584817775511261714.post-69873975769554137612010-06-13T09:19:00.000-07:002010-06-18T09:38:49.841-07:00Setting WIFI using registryThis is another of those challenges Pocket PCs/Windows Mobile devices throw at developers. <div>With the advent of CSPs (Configuration Service Provider), much of the device interaction complexities are resolved, however there are few that still either elude us or cryptic in implementation. </div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3lJK_bkt2-g/TBUQun-Rh2I/AAAAAAAAAAM/yQC6InFoeS4/s1600/Connections.bmp"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 166px;" src="http://3.bp.blogspot.com/_3lJK_bkt2-g/TBUQun-Rh2I/AAAAAAAAAAM/yQC6InFoeS4/s320/Connections.bmp" border="0" alt="" id="BLOGGER_PHOTO_ID_5482306514583652194" /></a><div>One such issue that I came across is setting the wifi, i.e., configuring the network adapter to use either"Work" or "The Internet" options. Though I read some articles on using CSP's CM_NetEntries on resolving this issue, somehow it didn't work for me. </div><div><br /></div><div>Using the below approach by setting the guid in the registry did the trick. </div><div><div><br /></div><div>string WiFiSettingPath = @"HKEY_LOCAL_MACHINE\ControlPanel\WiFi\Ethernet";</div><div> Microsoft.Win32.Registry.SetValue(WiFiSettingPath, "DestId", "{A1182988-0D73-439E-87AD-2A5B369F808B}");</div></div><div>//{A1182988-0D73-439E-87AD-2A5B369F808B} -- is the guid for work</div><div><br /></div><div>As usual once you set as above, warm boot the device for the new settings to take affect.</div><div>Note: Sending a WM_BROADCAST doesn't work in this case.</div>Naresh Mirkhelkarhttp://www.blogger.com/profile/12903549130608983867noreply@blogger.com0tag:blogger.com,1999:blog-2584817775511261714.post-29378081133245312222010-06-07T14:15:00.000-07:002010-06-18T09:39:51.090-07:00Disable Windows Mobile 'out of box' Phone<span class="Apple-style-span" style="font-family:'trebuchet ms';"><span class="Apple-tab-span" style="white-space:pre"> </span>You may have noticed many times that soft phone on windows mobile (6.0, 6.1, 6.5) pops up on screen whenever you press the green phone button. This could be annoying if the device happens to be of type PocketPC (like the robust ones used in retail stores) where other LOB applications are of significance and not the phone itself. I could not find an easy way to turn it off and comes up when I inadvertently end up hitting the key owing to the size of the small keypad.</span><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><br /></span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';">I figured this phone application is controlled by OS and runs as CProg.exe. Killing this process doesn't help because OS kick starts it, if found not running. </span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><br /></span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';">Use the following workaround to turn it off completely...</span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';">1. Create a console exe that does nothing and name it as CProg.exe</span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';">2. Override the below registry entries</span><span class="Apple-style-span" style=" ;font-family:'trebuchet ms';"><span class="Apple-tab-span" style="white-space:pre"> </span>HKLM\SOFTWARE\Microsoft\Shell\Rai\:MSCPROG</span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><span class="Apple-tab-span" style="white-space:pre"> </span>0 = "CProg"</span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><span class="Apple-tab-span" style="white-space:pre"> </span>1 = ""\[path to exe]<path><complete><path>\CProg.exe""</path></complete></path></span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><br /></span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';">...and warm boot the device.</span></div><div><span class="Apple-style-span" style="font-family:'trebuchet ms';"><br /></span></div>Naresh Mirkhelkarhttp://www.blogger.com/profile/12903549130608983867noreply@blogger.com0