Turn ON/OFF BT/Widcomm on BA with eVc - Windows Mobile Development and Hacking General

Does anyone know how to turn on and off the Widcomm bluetooth on a Blue Angel from within C/eVc? :?:
tia

The only official way to turn off the radio is to destroy the last of the BT objects using the stack (the stack is object orientated, creating an object turns it on, destroying the lst object turns it off, this assumes you have the widcomm SDK). The problem is that the BT app that runs in the system tray (and shows you that bluetooth icon in the bottom left) owns a stack object that you cant properly destroy, hence you can't turn the radio off.
hrm...
If the tray app wasn't running, theres a function in the wbtapiCE.dll called UnloadStack ([email protected]@@[email protected]@[email protected]) which should force the stack to unload and probably turn off the radio.

So we might be able to turn it OFF this way. And how do we turn in ON again ;-)

Theres a corrasponding LoadStack ([email protected]@@[email protected]@[email protected]) which would do the job.
Each of these accept two parameters, the first appears to be a pointer to a class, the second a numeric value.
For the class pointer, it appears that you can define an 8 byte array and call the constructor ( [email protected]@[email protected] ) on it, remember to call the destructor ( [email protected]@[email protected] ) when your done. The hex value appears to be 0x123456 for LoadStack and 0x654321 for UnloadStack.
I really don't know how successfull you would be starting the stack yourself, spinning up the BT tray app, then killing it and shutting down the stack, you may find you have to replace all the functionality of the tray app yourself.

Complicated stuff. I might be easier off doing FindWindow on the BtApp and find the ON and OFF buttons and programatically press them.

Hello All.
I call wbtapiCE.dll functions for on/off BT on dell axim x30.
I use, two dll metods
[email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::UnloadStack(unsigned int)
and
>> [email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::LoadStack(unsigned int)
But no positive effect.
Anybody know what i doing wrong?
Sample code below:
{
CString szDllPath = _T("wbtapiCE.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
//__cdecl CWBtAPI::CWBtAPI(void)
typedef void (CWBtAPI::*PFNCreateCWBt)();
typedef void (CWBtAPI::*PFNDestructorOfCWBt)();
typedef int (CWBtAPI::*PFNLoadCWBt)(unsigned int);
typedef int (CWBtAPI::*PFNUnLoadCWBt)(unsigned int);
//>> >> [email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::UnloadStack(unsigned int)
CWBtAPI* a1 = (CWBtAPI*)_alloca(sizeof(CWBtAPI));
PFNCreateCWBt pfnCreateWBt = force_cast<PFNCreateCWBt>(GetProcAddress(hMod, TEXT("[email protected]@[email protected]")));
(a1->*pfnCreateWBt)();
//////////////////////////////////////////////////////////////////////////
PFNUnLoadCWBt pfnUnLoadA = force_cast<PFNUnLoadCWBt>(GetProcAddress(hMod, TEXT("[email protected]@@[email protected]@[email protected]")));
AfxMessageBox(_T("Started pfnUnLoadA"));
int result = (a1->*pfnUnLoadA)( 0x654321);
CString err = _T("Done pfnUnLoadA");
AfxMessageBox(err );
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
PFNLoadCWBt pfnLoadA = force_cast<PFNLoadCWBt>(GetProcAddress(hMod, TEXT("[email protected]@@[email protected]@[email protected]")));
AfxMessageBox(_T("Started pfnLoadA"));
result = (a1->*pfnLoadA)(0x123456);
AfxMessageBox(_T("Done pfnLoadA"));
//////////////////////////////////////////////////////////////////////////
PFNDestructorOfCWBt pfnDestA = force_cast<PFNDestructorOfCWBt>(GetProcAddress(hMod, TEXT("[email protected]@[email protected]")));
(a1->*pfnDestA)();
/*************************************************************************/
FreeLibrary(hMod);
}

could some kind soul maybe write a script to do someth like that...

I make it BT on/off
Jn dell axim X30 exist btpwr.dll.
This dll export some interesting methods.
1 0 0000128C PowerDeInit
2 1 00001284 PowerInit
3 2 00001258 PowerOff
4 3 0000121C PowerOn
I call this methods directly from dll, and i turn on turn off bt !!
Sample code below:
void DoTrayOn()
{
CString szDllPath = _T("btpwr.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
typedef int (*BTPowerOn)();
BTPowerOn bton = (BTPowerOn) GetProcAddress(hMod, TEXT("PowerOn"));
if (NULL != bton)
{
// AfxMessageBox(_T("Start DoTrayOn"));
(bton) ();
}else
{
// AfxMessageBox(_T("Error NULL DoTrayOn pointer"));
}
FreeLibrary(hMod);
}
void DoTrayOff()
{
CString szDllPath = _T("btpwr.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
typedef int (*BTPowerOff)();
BTPowerOff bton = (BTPowerOff) GetProcAddress(hMod, TEXT("PowerOff"));
if (NULL != bton)
{
// AfxMessageBox(_T("Start DoTrayOn"));
(bton) ();
}else
{
// AfxMessageBox(_T("Error NULL DoTrayOn pointer"));
}
FreeLibrary(hMod);
}

Bluetooth turn on/turn off
Hello
Have you a solution for turn on and turn off bluetooth by code?
I have a widcomm stack and I use c# .net

i'm searching for a solution for my Touch Pro 2 with Widcomm BT Stack.
i can turn on BT by creating an object of CBtIf, but can't turn of BT by deleting the object.
someone has an idea?
regards
IceFire

Related

RIL - Telepfone

Hi,
here my second problem :?
Has someone of you an idea how to Answer a call automaticly? I tried RIL_Answer and it seams to work, but i can't talk because the speaker and micro seems to be off.
Also I tried to dial with RIL_Dial - but there seems nothing to go on.
Greetings from hanovre again and
many many thanks for every idea
Andreas )
PS: Is there somewhere a RIL-Command to send AT-Commands directly (in text, not in HEX)?
PS: Is there somewhere a RIL-Command to send AT-Commands directly (in text, not in HEX)?
Click to expand...
Click to collapse
unfortunately there is not.
auto-answer
to make auto answer of phone call, just simulate the hardware key is pressed. not too hard to write in mVC+.
the question is: what next?
auto-answer works fine when you can switch to the speakerphone mode automatically right after the software did pick-up the call
I cannot do that, I tried in several ways but it is not working.
I cannot simulate "longer-press" of hardware buttons as you know you can turn on/off the speakerphone mode
Hi.
I'm also trying to use RIL_Dial. The way I'm running this function is:
RIL_Dial (g_hRil, (CHAR*)_T("696761699"), RIL_CALLTYPE_VOICE, RIL_DIALOPT_NONE)
My XDA seems to accept and try to establish the call since it opens the phone interface (without displaying the passed number). But then I get this answer back from the phone: UNKNOWN APPLICATION
Anyone knows how I can establish a call with this function?
Thanks,
Erik.
@ballrock2:
To answer a call using RIL_Answer do this:
- Call RIL_Answer
- Sleep(100)
- Send a VK_F4 down
- Sleep(100)
- Send a VK_F4 Up
You can then talk.
Quan
does not works
you dream,
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), 0, 0);
return one shot of button down emulation
no matter how long you are awaiting for the next
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);
so, in this way we cannot emulate tap-and-hold of the green phone button to turn on the speakerphone mode
can you explain or just post how you managed to initialize RIL ?? i dont seem to figure it out !!
thanks.
nutitija
Use Search
In Last Time
/*
callback for result of async functions
*/
void CALLBACK ril_result_callback(DWORD dwCode, HRESULT hrCmdID, const void* lpData, DWORD cbData, DWORD dwParam)
{
....
}
/*
callback for phony notifications (like incoming call)
*/
void CALLBACK ril_notify_callback(DWORD dwCode, const void* lpData, DWORD cbData, DWORD dwParam)
{
...
}
...
HRIL ril = NULL;
......
/*
1 - for RIL1: device
RIL1: device for COM2: device
*/
if (RIL_Initialize(1, ril_result_callback, ril_notify_callback, RIL_NCLASS_CALLCTRL | RIL_NCLASS_NETWORK | RIL_NCLASS_SUPSERVICE | RIL_NCLASS_RADIOSTATE, 0, &ril) < 0)
return;
.....
ok i kinda got the whole idea of it now, this is my implementation to try to initialize RIL however i get the following error :
error C2660: 'RIL_Initialize' : function does not take 6 parameters
Anybody can help me here ? i'm guessing maybe gotta do something with the RIL header file or lib or exp ?
************************************************
// Global Variables
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
DWORD g_dwParam = 0x55AA55AA;
HRIL g_hRil = NULL;
// RL initilize
void CTerminalDlg::RIL_Initialize()
{
result = RIL_Initialize(1, ril_result_callback, ril_notify_callback, dwNotificationClasses, g_dwParam, &g_hRil);
}
************************************************
// Global Variables
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
DWORD g_dwParam = 0x55AA55AA;
HRIL g_hRil = NULL;
// RL initilize
void CTerminalDlg::RIL_Initialize()
{
result = ::RIL_Initialize(1, ril_result_callback, ril_notify_callback, dwNotificationClasses, g_dwParam, &g_hRil);
}
learn C++

Turn "Wireless" or "Flight mode" on/off

Hi,
I'm developing soft on XDA II using C++ and VB.NET. I made an application that connects to GPRS and everything seems to work fine!
Sometimes "Flight mode" is turned on, without a user intervention (when the battery goes totaly down).
Now I need to control the "flight mode" by code. I looked into the registry, but I couldn't find a setting that sets the "flight mode".
Is there anyone that knows how to turns "flight mode" on and off by code?
Thanks!
Sam
I suppose you could find the information on the link below
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcetapi/html/cmcontelephonyapi.asp
Good luck.
Hi,
I checked it out, but the TAPI has very much methods and properties. Does anyone has an idea what functions I should use to set and get the "flight mode"-state?
Thanks in advance!
Sam
The so-called "flight mode" simply refers to whether the radio is switched on or off. Flight mode on = radio off and vice versa.
To switch the radio on/off programmatically requires the use of TAPI. It is not a simple process.
The calls you need are declared in <extapi.h>:
lineSetEquipmentState(hLine, LINEEQUIPSTATE_FULL); // Turn on
lineSetEquipmentState(hLine, LINEEQUIPSTATE_MINIMUM); // Turn off
Note that after turning on the radio, you also need to register to the network (on XDA2 only - XDA1 does this automatically):
lineRegister(hLine, LINEREGMODE_AUTOMATIC, NULL, 0L);
I have been doing this on the XDA for the last year and have recently moved the code to the XDA2
I found out about having to register the phone on the network quite quickly and the code below works on the XDA2 with 1 problem remaining.
When the radio is being turned on the device freezes for up to 12 seconds(the start menu will not open if tapped etc).
Has anyone else experienced this and do is there a way to stop it from happening.
Code:
DWORD setPhoneState(DWORD state)
{
if(NULL == m_hLineApp)
{
return -1;
}
DWORD dwDeviceID = m_dwDeviceID;
LONG lRC = 0;
HLINE hLine = NULL;
DWORD dwState, dwRadioSupport;
lRC = lineOpen( m_hLineApp, dwDeviceID, &hLine, m_dwAPIVersion, 0,
NULL, LINECALLPRIVILEGE_OWNER, LINEMEDIAMODE_DATAMODEM,
NULL);
if(lRC < 0)
{
if(hLine != NULL)
{
lineClose(hLine);
hLine = NULL;
}
return lRC;
}
lRC = lineGetEquipmentState(hLine, &dwState, &dwRadioSupport);
if(lRC < 0)
{
lineClose(hLine);
return lRC;
}
if((LINEEQUIPSTATE_MINIMUM == state) ||
(LINEEQUIPSTATE_NOTXRX == state))
{
lRC = lineUnregister(hLine);
if(lRC < 0)
{
lineClose(hLine);
return lRC;
}
}
if(dwState != state)
{
lRC = lineSetEquipmentState(hLine, state);
}
if(lRC < 0)
{
lineClose(hLine);
return lRC;
}
if((LINEEQUIPSTATE_FULL == state) ||
(LINEEQUIPSTATE_RXONLY == state) ||
(LINEEQUIPSTATE_TXONLY == state))
{
lRC = lineRegister(hLine, LINEREGMODE_AUTOMATIC, NULL, LINEOPFORMAT_NONE);
if(lRC < 0)
{
lineClose(hLine);
return lRC;
}
}
lRC = lineClose(hLine);
return lRC;
}
I've also noticed significant delays when switching on the radio on an XDA2. That's just the way it is.
But I think the code above could be improved. The point is that many TAPI calls complete asynchronously - in other words, when you call them, they return before doing what you've asked. Subsequent progress is indicated via "TAPI notifications".
When switching the radio on, the above code calls lineSetEquipState and then immediately calls lineRegister - before the previous TAPI call has actually finished. By using TAPI notifications to detect completion, the call to lineRegister can be delayed until the radio is actually switched on.
I think this would make the XDA2 more responsive and reduce the delays to a few seconds rather than 12 seconds. However it would involve a significant restructuring of the code - so it may not be worth the trouble.
I assume that you mean using the TAPICallback function specified in lineInitialize and handling the LINE_DEVSPECIFIC message.
If this is what you mean, do you have any info on the parameters passed with this message or do you check the register status and then register if necessary?
How I can do it in .NETCF?
lineSetEquipmentState(hLine, LINEEQUIPSTATE_FULL); // Turn on
lineSetEquipmentState(hLine, LINEEQUIPSTATE_MINIMUM); // Turn off
Thanks!!
VB.NET Sample Code
Imports OpenNETCF.Tapi
Private BuTapi As New Tapi
Public Function SampleFunc As Integer
BuTapi.Initialize()
'Getting DevCaps
Dim BuDc As New LINEDEVCAPS(1024)
BuDc.Store()
Dim dwVersion As New Integer
Dim ret As New Integer
dwVersion = BuTapi.NegotiateVersion(0)
ret = NativeTapi.lineGetDevCaps(BuTapi.hLineApp, 0, dwVersion, 0, BuDc.Data)
'Creating Line
Dim BuHat As Line
BuHat = BuTapi.CreateLine(0, LINEMEDIAMODE.DATAMODEM, LINECALLPRIVILEGE.OWNER)
Dim BuOperator As New LINEOPERATOR
Dim data(BuOperator.SizeOf) As Byte
ret = CellTSP.lineGetCurrentOperator(BuHat.hLine, data)
ByteCopy.ByteArrayToStruct(data, BuOperator)
'Changing Airplane Mode
Dim Result as Integer
Result = CellTSP.lineSetEquipmentState(BuHat.hLine, LINEEQUIPSTATE.FULL)
BuTapi.Shutdown()
Return Result
End Function
Where can I get OpenNETCF.Tapi??? I use Opennetcf v1.2 but it doesn´t contain OpenNETCF.Tapi!!!
I'm wondering about the same thing - didn't find any information about OpenNETCF.Tapi on their website.
OpenNETCF.Tapi isn't free, it's include in the package 'OpenNETCF Telephony Library SDK with 10 Device Licenses', which costs $500...
If anyone has a free solution... I'm trying to get it to work anyway.

Programmatically cycle sound icon (sound/vibrate/mute)

When you click on the sound icon, you get the two sliders and three radio buttons. Anyone know how to set those radio buttons through code (C++) so it gets reflected in the icon display (and actually changes the "profile")?. I'd like to change to vibrate/mute/sound at different times using something like alarmToday to run a small app.
Thanks,
sbl
I wrote a profiles app in .net and C++ here are some code snippets;
You can change the registry values for the volumes (I cant remember which as I wrote it a long time ago), then you need to call the following to have the values applied.
// ProfilesHelper.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "ProfilesHelper.h"
#include <windows.h>
#include <Soundfile.h>
void WINEXPORT SetSoundMode(int mode)
{
// Initialize an empty SNDFILEINFO structure
SNDFILEINFO sndfile = {0};
if (mode == 0)
sndfile.sstType = SND_SOUNDTYPE_ON;
if (mode == 1)
sndfile.sstType = SND_SOUNDTYPE_VIBRATE;
if (mode == 2)
sndfile.sstType = SND_SOUNDTYPE_NONE;
SndSetSound(SND_EVENT_ALL, &sndfile, false);
void AudioUpdateFromRegistry();
}
void WINEXPORT SetSystemVolume(long volume)
{
waveOutSetVolume(NULL, volume);
void AudioUpdateFromRegistry();
}
Hi,
I have a similar need of programatically cycling the sound icon to MUTE VIBRATE and normal volume icon. I can do it successfully on Windows Mobile 5.0. I created a sample application with Visual Studio 2005 for WM 5.0 and I am able to set the icons as i want. But when i tried it for PPC2003 I was not able to compile that. Missing SoudFile.h. Can any one help me to find out how to do the same thing on PPC2003 specifically i-mate devices like PDA2 and PDA2K.
Thanks
With Regards,
Bhagat Nirav K.
i know its a 2 ur old post..but i need help also now
how can i mute sounds using C# in .net 2.0 for WM6
Just forget about this header file...
Operate on HKCU\ControlPanel\Notifications\ShellOverrides\Mode value. It can have 3 states: 0 == normal, 1 == vibrate and 2 == silent. That's all
Probably you need to call AudioUpdateFromRegistry function from coredll.dll.
Or... another method
look at HKCU\ControlPanel\Sounds\RingTone0:Sound, it takes 3 different values:
*none*
*vibrate*
your ringtone name, taken from SavedSound value in the same key.
Hi,
Firstly I know this post is way old, but I thought of responding to it since I was stuck on this topic for a couple of days and couldnt find a way to resolve it.
Also others having this problem will also be redirected here through various search results as I was. So to aid them
1. Meddling with the registry to change the sound profiles didnt work for me. I tried Changing the Mode inHKCU\ControlPanel\Notifications\ShellOverrides\Mode but that didnt work on my phone.
2. What I currently have working is the following code - C# with Pinvoke
public enum SND_SOUNDTYPE
{
On,
File,
Vibrate,
None
}
private enum SND_EVENT
{
All,
RingLine1,
RingLine2,
KnownCallerLine1,
RoamingLine1,
RingVoip
}
[StructLayout(LayoutKind.Sequential)]
private struct SNDFILEINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szPathName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
public SND_SOUNDTYPE sstType;
}
[DllImport("coredll.dll")]
public static extern void AudioUpdateFromRegistry ();
[DllImport("aygshell.dll", SetLastError = true)]
private static extern uint SndSetSound(SND_EVENT seSoundEvent, ref SNDFILEINFO pSoundFileInfo, bool fSuppressUI);
static void SetProfileNormal()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.On;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
static void SetProfileVibrate()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.Vibrate;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
static void SetProfileMuted()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.None;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
Hope this helps

How to programatically turn Bluetooth ON and OFF in Rhodium

I cannot get BT toggled in Rhodium using the usual method for Widcomm/Broadcom:
Code:
HWND bt_hwnd = FindWindow(L"WCE_BTTRAY", 0);
UINT COMMANDGET = RegisterWindowMessage(L"WIDCOMM_WM_GETSTACKSTATUS");
DWORD resultget = SendMessage(bt_hwnd, COMMANDGET, 0, 0);
UINT COMMAND;
if(resultget > 0)
COMMAND = RegisterWindowMessage(L"WIDCOMM_WM_BTRADIO_ON");
else
COMMAND = RegisterWindowMessage(L"WIDCOMM_WM_BTRADIO_OFF");
resultset = SendMessage(bt_hwnd, COMMAND, 0, 0);
I've seen that the new Broadcom stack has many more messages, but cannot figure how to use them for turning BT ON and OFF. Does anybody know how to do this?
Code:
WIDCOMM_WM_STACK_LOAD
WIDCOMM_WM_STACK_UNLOAD
WIDCOMM_WM_GETSTACKSTATUS
WIDCOMM_WM_SETSTACKCONFIG
WIDCOMM_WM_BTRADIO_OFF
WIDCOMM_WM_BTRADIO_ON
WIDCOMM_WM_VISIBLE1
WIDCOMM_WM_REG_PROF_NOTIF
WIDCOMM_WM_REG_PROF_EVENT
WIDCOMM_WM_ACTIVESYNC
WIDCOMM_WM_ISVISIBILITYTIMER
WIDCOMM_WM_IDENT_CHANGE
WIDCOMM_WM_POST_STACK_LOAD
WIDCOMM_WM_UPDATE_STATUS
WIDCOMM_WM_KILL_VISIBILITYTIMER
WIDCOMM_WM_SET_FM_CONFIG
WIDCOMM_WM_PROF_CHANGE_EVENT
WIDCOMM_WM_STACKLOADED
WIDCOMM_WM_STACKUNLOADED
WIDCOMM_WM_TRAYUNLOADED
WIDCOMM_WM_ACTIVATE
beemerTPPC said:
I cannot get BT toggled in Rhodium using the usual method for Widcomm/Broadcom...
Click to expand...
Click to collapse
From what I've found on the web, you can't toggle anymore. The function calls are still implemented but the have no effect.
For beeing able to turn BT off / on, the procedure (afair) is:
- unload stack
- set registry entry
- load stack
I simply even didn't find out how to unload the stack programmatically, so I gave up for the moment.
However, you might be able to figure out by debugging the function the commmgr is using. Just an idea.
cheers
can't you just use 32Feet? BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable
grzegorzaksamit said:
can't you just use 32Feet? BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable
Click to expand...
Click to collapse
Broadcom stack is not supported by 32feet.
EDIT:
According to this info it's supported now
http://32feet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28849
Not sure if this at all still relevant, but to me it was today. I loaded up IDA on CommManager and it turned out very simple:
#include <windows.h>
#include <BtSdkCE.h>
Code:
int main(int argc, char* argv[]) {
HWND bt_hwnd = FindWindow(L"WCE_BTTRAY", 0);
int WIDCOMM_WM_GETSTACKSTATUS = RegisterWindowMessage(L"WIDCOMM_WM_GETSTACKSTATUS");
DWORD radio_enabled = SendMessage(bt_hwnd, WIDCOMM_WM_GETSTACKSTATUS, 0, 0);
UINT WIDCOMM_WM_SETSTACKCONFIG = RegisterWindowMessage(L"WIDCOMM_WM_SETSTACKCONFIG");
if (!radio_enabled)
SendMessage(bt_hwnd, WIDCOMM_WM_SETSTACKCONFIG, 1, 1);
else
SendMessage(bt_hwnd, WIDCOMM_WM_SETSTACKCONFIG, 0, 0);
return 0;
}
I tested this on 4 different widcomm stack carrying device (rhodium, leo, hp214, hp hx4100) and it seems to work fine. Hopefully this will save someone a bit of time, as it took my quite a while to figure it out, but then again I'm not really used to reverse engineering.
works it too for the wizard
No idea, afaik wizard uses microsoft stack so it's not an issue anyway. I do believe u can use the widcomm stack on the wizard, in that case this would work.
bluetooth toggler
try this the attached zip file. unzip and copy to your device in \windows\start menu\programs
vanilaguy said:
try this the attached zip file. unzip and copy to your device in \windows\start menu\programs
Click to expand...
Click to collapse
old bluetooth switcher wont work with Leo
executable
Figured I might as well compile it. Should work on every widcomm enabled stack.
Also added a managed C# class to enable and disable radios on both microsoft and widcomm stack enabled devices. Creating a native one for both stacks shouldn't be hard either, but I have no need for it at all, so I didn't.
Code:
public static class BthRadio {
/// <summary>
/// Whether the device is equipped with a Widcomm bluetooth stack
/// </summary>
public static bool IsWidcomm;
/// <summary>
/// Whether the device is equipped with a Microsoft bluetooth stack
/// </summary>
public static bool IsMicrosoft;
/// <summary>
/// Determines stack properties
/// </summary>
static BthRadio() {
// determine stack type used on this device
IsWidcomm = OpenNETCF.NativeMethods.NativeLibraryExists("BtSdkCE50.dll") ||
OpenNETCF.NativeMethods.NativeLibraryExists("BtSdkCE30.dll");
IsMicrosoft = !IsWidcomm;
}
/// <summary>
/// Toggles bluetooth radio enabledness
/// </summary>
/// <returns>Whether the action was performed successfully</returns>
public static bool ToggleRadio() {
if (IsEnabled()) return DisableRadio();
else return EnableRadio();
}
/// <summary>
/// Returns whether primary radio is enabled
/// </summary>
/// <returns></returns>
public static bool IsEnabled() {
int mode = -1;
if (IsMicrosoft) {
int success = BthGetMode(ref mode);
return success == 0 && mode >= 1;
}
else {
IntPtr bt_hwnd = Win32.FindWindow("WCE_BTTRAY", null);
uint WIDCOMM_WM_GETSTACKSTATUS = Win32.RegisterWindowMessage("WIDCOMM_WM_GETSTACKSTATUS");
int radio_enabled = Win32.SendMessage(bt_hwnd, WIDCOMM_WM_GETSTACKSTATUS, 0, 0) & 1;
return radio_enabled != 0;
}
}
/// <summary>
/// Attempts to enable the bluetooth radio.
/// </summary>
/// <returns>True if operation executed successfully, otherwise false</returns>
public static bool EnableRadio() {
if (IsMicrosoft) return BthSetMode(1) == 0;
else {
uint WIDCOMM_WM_SETSTACKCONFIG = Win32.RegisterWindowMessage("WIDCOMM_WM_SETSTACKCONFIG");
int result = Win32.SendMessage(Win32.FindWindow("WCE_BTTRAY", null), WIDCOMM_WM_SETSTACKCONFIG, 1, 1);
if (result == 0) return false;
// sleep at least 3 seconds, required before change can take effect
Thread.Sleep(3000);
// now poll at most an additional 15 seconds to determine if the
// change was in fact effective
for (int i = 0; i < 15; i++) if (IsEnabled()) break;
return IsEnabled();
}
}
/// <summary>
/// Attempts to disable the bluetooth radio.
/// </summary>
/// <returns>True if operation executed successfully, otherwise false</returns>
public static bool DisableRadio() {
if (IsMicrosoft) return BthSetMode(0) == 0;
else {
uint WIDCOMM_WM_SETSTACKCONFIG = Win32.RegisterWindowMessage("WIDCOMM_WM_SETSTACKCONFIG");
int result = Win32.SendMessage(Win32.FindWindow("WCE_BTTRAY", null), WIDCOMM_WM_SETSTACKCONFIG, 0, 0);
if (result == 0) return false;
// sleep at least 3 seconds, required before change can take effect
Thread.Sleep(3000);
// now poll at most an additional 15 seconds to determine if the
// change was in fact effective
for (int i = 0; i < 15; i++) if (!IsEnabled()) break;
return !IsEnabled();
}
}
#region Bluetooth P/Invoke declarations
[DllImport("BthUtil.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int BthSetMode(int dwMode);
[DllImport("BthUtil.dll", CharSet = CharSet.Auto)]
public static extern int BthGetMode(ref int pdwMode);
#endregion
}
Wow, can you share the full code. I Just started developing and this is a bit to hard to implement for me
ajhvdb said:
Wow, can you share the full code. I Just started developing and this is a bit to hard to implement for me
Click to expand...
Click to collapse
I did, right? What did I omit?
"togglebth.exe" test report: work great with Leo
great skill!
zzattack said:
I did, right? What did I omit?
Click to expand...
Click to collapse
Wel i'm a starting developer... Could you share the project solution folder, including you function. This way I can debug/compile it.
ajhvdb said:
Wel i'm a starting developer... Could you share the project solution folder, including you function. This way I can debug/compile it.
Click to expand...
Click to collapse
Well sure I can do that, but it doesn't get any simpler than this. You'll need Visual Studio 2008, the broadcom SDK installed (and VS point to it's include/library files), and the Windows Mobile 5.0 SDK (or higher, I'd pick 6.0 and 6.5). Anyway, I attached the solution.
Thanks, and fast. I just wanted to see how you would use this class. (It's completely new to me).
Edit:
Just looked at it. So your communicating whit this WCE_BTTRAY program and depending on the answer do something.
ajhvdb said:
Thanks, and fast. I just wanted to see how you would use this class. (It's completely new to me).
Edit:
Just looked at it. So your communicating whit this WCE_BTTRAY program and depending on the answer do something.
Click to expand...
Click to collapse
This isn't much of a class, just a few lines of code :S
It just looks for the current status, if it's currently enabled it tries to disable the stack, if it's disabled it tries to enable it and that's it ;/

[WM6] Disabling taskbar, SIP and hardware keys (including green and red buttons)

Hello there!
I've seen a lot of questions on this topic, and just yesterday, my client asked for this feature implemented in the app that we are currently developing...
After a veeeery intensive and long night, i finally found how to disable all these things! The code is written in c# using .net CF 2.0, and has been tested successfully on a HTC Tynt device. The interesting thing is that it will also disable the End Call and Make Call hardware buttons (VK_TEND and VK_TTALK). If you intend to use this in a production environment you might consider improoving it a little bit.
[DllImport("coredll.dll")]
private static extern bool UnregisterFunc1(KeyModifiers modifiers, int keyID);
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window
int id, // hot key identifier
KeyModifiers Modifiers, // key-modifier options
int key //virtual-key code
);
public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8,
Modkeyup = 0x1000,
}
private void DeactivateUI()
{
try
{
// deactivate the SIP button
IntPtr hSip = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON");
EnableWindow(hSip, false);
// deactivate the SIP button
IntPtr hTaskBar = FindWindow("HHTaskBar", null);
EnableWindow(hTaskBar, false);
// deactivate the hardware keys
for (Int32 iCounter = 193; iCounter <= 207; iCounter++)
{
UnregisterFunc1(KeyModifiers.Windows, iCounter);
RegisterHotKey(this.Handle, iCounter, KeyModifiers.Windows, iCounter);
}
UnregisterFunc1(KeyModifiers.None, 0x73); //VK_TEND
RegisterHotKey(this.Handle, 0x73, KeyModifiers.None, 0x73);
UnregisterFunc1(KeyModifiers.None, 0x72);
RegisterHotKey(this.Handle, 0x72, KeyModifiers.None, 0x72); //VK_TTALK
}
catch (Exception ex)
{
Log.WriteError(ex, false);
}
}
Cheers!
Very good, helped me a lot! But how do I unlock the keys again, without rebooting?
Thanks!
gciochina said:
Hello there!
I've seen a lot of questions on this topic, and just yesterday, my client asked for this feature implemented in the app that we are currently developing...
After a veeeery intensive and long night, i finally found how to disable all these things! The code is written in c# using .net CF 2.0, and has been tested successfully on a HTC Tynt device. The interesting thing is that it will also disable the End Call and Make Call hardware buttons (VK_TEND and VK_TTALK). If you intend to use this in a production environment you might consider improoving it a little bit.
[DllImport("coredll.dll")]
private static extern bool UnregisterFunc1(KeyModifiers modifiers, int keyID);
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window
int id, // hot key identifier
KeyModifiers Modifiers, // key-modifier options
int key //virtual-key code
);
public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8,
Modkeyup = 0x1000,
}
private void DeactivateUI()
{
try
{
// deactivate the SIP button
IntPtr hSip = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON");
EnableWindow(hSip, false);
// deactivate the SIP button
IntPtr hTaskBar = FindWindow("HHTaskBar", null);
EnableWindow(hTaskBar, false);
// deactivate the hardware keys
for (Int32 iCounter = 193; iCounter <= 207; iCounter++)
{
UnregisterFunc1(KeyModifiers.Windows, iCounter);
RegisterHotKey(this.Handle, iCounter, KeyModifiers.Windows, iCounter);
}
UnregisterFunc1(KeyModifiers.None, 0x73); //VK_TEND
RegisterHotKey(this.Handle, 0x73, KeyModifiers.None, 0x73);
UnregisterFunc1(KeyModifiers.None, 0x72);
RegisterHotKey(this.Handle, 0x72, KeyModifiers.None, 0x72); //VK_TTALK
}
catch (Exception ex)
{
Log.WriteError(ex, false);
}
}
Cheers!
Click to expand...
Click to collapse
Can u provide the EnableWindow method.I am getting the error in this method
Implement code
Hello!
I have created app to WM 5 - 6.5, but users can close it using END button. I see your code, but i can't implement ( i mean I don't have sufficient knowledge) it to visual studio 2008.
Could you tell me what should I do?
Error 1 'APP.Kiosk' does not contain a definition for 'Handle' and no extension method 'Handle' accepting a first argument of type 'APP.Kiosk' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\lupag\Moje dokumenty\Pobieranie\CEKiosk\CEKiosk\Kiosk.cs 155 43 CEKiosk
Handle? wtf

Categories

Resources