Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Start the Bluetooth service?

29 views
Skip to first unread message

Alon

unread,
Dec 23, 2009, 12:29:02 AM12/23/09
to
Hi,

How can I start the Bluetooth service (MS Stack) from code?

I've seen many snippets around the net about CreateFile and ControlIODevice
but none of them worked for me...

I'm using WinCE 6.0 with CF 2.0.

Thanks,

Alon

Luca Calligaris [eMVP]

unread,
Dec 23, 2009, 2:26:20 AM12/23/09
to
Have you tried
%_WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\BLUETOOTH\SAMPLE\BTLOADER ?

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Alon" <Al...@discussions.microsoft.com> ha scritto nel messaggio
news:5A2027FA-1784-4CFB...@microsoft.com...

Alon

unread,
Dec 23, 2009, 7:13:01 AM12/23/09
to
Hi Luca,

Thanks for your reply.

I'm actually programming for the first time to WinCE, till now I always
programmed to WinMO.

So, I have the WinMO 6 SDK (which does not hold that sample). Does the
sample path you wrote about is from WinCE SDK? Which version? I could locate
only WinCE 5.0 SDK in MS site that is from 2004. Can you post the link to
version 6.0?

Thanks,

Alon

Vinoth [MCTS]

unread,
Dec 23, 2009, 9:08:01 AM12/23/09
to
As far i know, there is no standard sdk release for windows ce 6.0. if you
want to develope an application particularly for the device, you have to
create your own sdk on the platform builder using the OSDesign(sln) of the
corresponding BSP.
if you want a SDK for device emulator then you have to create a OSDesign and
select the needed component on the Device emulator BSP.

--
vinoth.R
Aritcles:
http://www.windowsfordevices.com/articles/AT8185724467.html
http://e-consystems.com/gprsconnectivity.asp
http://vinoth-vinothblog.blogspot.com
http://www.e-consystems.com/blog

Luca Calligaris [eMVP]

unread,
Dec 23, 2009, 10:18:10 AM12/23/09
to
the sample comes from the WINCE600 tree, not from an SDK; you should
download an evaluation version of WINCE600 to have that code

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Alon" <Al...@discussions.microsoft.com> ha scritto nel messaggio

news:E97E0096-7CF2-46E1...@microsoft.com...

Alon

unread,
Dec 23, 2009, 3:11:01 PM12/23/09
to
hmm, Is there a chance someone can wrap it and send me the sample in a zip?

Also, is this sample in .Net or C++?

thanks,

Alon

Paul G. Tobey [ eMVP ]

unread,
Dec 23, 2009, 5:17:01 PM12/23/09
to
Not legally, no. Redistributing of the source code from a CE install is
blocked by the license agreement, as I read it. If you install the
evaluation version of Windows CE, you can use the sample code.

It's in C/C++.

Paul T.

Alon

unread,
Dec 23, 2009, 5:40:03 PM12/23/09
to
Hi,

I'm running Win7 x64 with VS2008.

The Windows Embedded 6.0 SP1 wont install without VS2005...

Alon

Alon

unread,
Dec 23, 2009, 5:46:01 PM12/23/09
to
Hi Paul,

For some refresh issues, I just notice your post...

So if not sending me the sample, can someone post here a .Net code snippet?

Thanks in advanced!!

Alon

Luca Calligaris [eMVP]

unread,
Dec 23, 2009, 10:51:05 PM12/23/09
to
I do not know if this can help:

http://msdn.microsoft.com/en-us/windowsembedded/ce/aa714519.aspx

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Alon" <Al...@discussions.microsoft.com> ha scritto nel messaggio

news:0AECD6AE-B887-4EBB...@microsoft.com...

Alon

unread,
Dec 24, 2009, 2:58:01 PM12/24/09
to
Thank you very much Luca for the link - I download and installed and it
almost did it...

The issue is that those classes use the "bthutil.dll" which suppose to be
part on every standard WinCE image but of course, as "Murphy stopped by..."
on my PND it doesn't exist.

I will need a more 'source' code.

Maybe you know of a company that can develop it for me? I'm really desperate
and this project is way too important.

Thanks,

Alon


Alon

unread,
Dec 24, 2009, 10:51:01 PM12/24/09
to
It looks like the only solution for me is to use CreateFile and
DeviceIoControl to start the BT.
So I've tried it but DeviceIoControl always return 0 and the error is 87.
CreateFile seems to work ok. If I need to guess - I'm passing the wrong
parameters to the CreateFile/DeviceIoControl. Here is my code if someone can
look at it (is a VB.Net code but a C# reply is ok as well):

Class BTLoader2
Private Const FILE_DEVICE_SERVICE As UInt32 = &H104
Private Const METHOD_BUFFERED As UInt32 = 0
Private Const FILE_ANY_ACCESS As UInt32 = 0

<DllImport("coredll.dll")> _
Private Shared Function CreateFile(ByVal lpFileName As String, ByVal
dwDesiredAccess As UInteger, ByVal dwShareMode As UInteger, ByVal
lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As UInteger,
ByVal dwFlagsAndAttributes As UInteger, ByVal hTemplateFile As IntPtr) As
IntPtr
End Function

<DllImport("coredll.dll")> _
Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal
dwIoControlCode As UInt32, ByVal lpInBuf As IntPtr, ByVal nInBufSize As
UInt32, ByVal lpOutBuf As IntPtr, ByVal nOutBufSize As UInt32, ByRef
lpBytesReturned As UInt32, ByVal lpOverlapped As IntPtr) As UInt32
End Function

<DllImport("CoreDll.dll", EntryPoint:="GetLastError")> _
Private Shared Function GetLastError() As Integer
End Function

Private Shared Function IOCTL_SERVICE_START() As UInt32
Return CTL_CODE(FILE_DEVICE_SERVICE, 1, METHOD_BUFFERED,
FILE_ANY_ACCESS)
End Function

Private Shared Function CTL_CODE(ByVal DeviceType As UInt32, ByVal
[Function] As UInt32, ByVal Method As UInt32, ByVal Access As UInt32) As
UInt32
Return ((DeviceType) << 16) Or ((Access) << 14) Or (([Function]) <<
2) Or (Method)
End Function

Public Sub StartBT()

Dim hDev As IntPtr = CreateFile("BTD0:", CUInt(IO.FileAccess.Read Or
IO.FileAccess.Write), CUInt(IO.FileShare.Read Or IO.FileShare.Write),
IntPtr.Zero, 3, 0, IntPtr.Zero)

Dim BytesReturned As UInt32 = 0

Dim Result As UInt32 = DeviceIoControl(hDev, IOCTL_SERVICE_START(),
IntPtr.Zero, 0, IntPtr.Zero, 0, BytesReturned, IntPtr.Zero)

If Result <> 0 Then
MsgBox("Success")
Else
MsgBox(GetLastError, , "Error")
End If
End Sub

End Class

Paul G. Tobey [ eMVP ]

unread,
Dec 29, 2009, 2:39:01 PM12/29/09
to
There's no such thing as a "standard device". There are virtually zero
components that are required for Windows CE devices. The choice of what to
support and how is up to the device OEM. Certainly you aren't required to
use the Microsoft Bluetooth stack, so you can't be required to use their
utility DLL. Maybe your device uses some other BT stack, resulting in a
different procedure for turning on Bluetooth.

Paul T.

0 new messages