📄 safenativemethods.cs
字号:
// Copyright (c) David Vescovi. All rights reserved.
// Part of Project DrumStix
// Windows Embedded Developers Interest Group (WE-DIG) community project.
// http://www.we-dig.org
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/?linkid=2933443.
//
#region Using directives
using System;
using System.Runtime.InteropServices;
using Gumstix.Bluetooth;
#endregion
namespace Gumstix
{
internal static class SafeNativeMethods
{
#region Win32 Methods
const string BTHGUM_DLL = "bthgum.dll";
const string BTDRT_DLL = "btdrt.dll";
const string WINSOCK_DLL = "Ws2.dll";
const string CORE_DLL = "coredll.dll";
#region CE Bluetooth Radio Functions
[DllImport(BTHGUM_DLL)]
public static extern int HCI_StartHardware();
[DllImport(BTHGUM_DLL)]
public static extern int HCI_StopHardware();
[DllImport(BTDRT_DLL)]
public static extern int BthGetHardwareStatus(ref int status);
#endregion
#region Bluetooth Utility Functions
[DllImport(BTDRT_DLL)]
public static extern int BthSetPIN(byte[] btAddr, int pinLength, byte[] pin);
[DllImport(BTDRT_DLL)]
public static extern int BthRevokePIN(byte[] btAddr);
[DllImport(BTDRT_DLL)]
public static extern int BthReadLocalAddr(byte[] btAddr);
#endregion
#region CE Winsock functions
[DllImport(WINSOCK_DLL)]
public static extern int WSAStartup(ushort version, byte[] wsaData);
[DllImport(WINSOCK_DLL)]
public static extern int WSACleanup();
[DllImport(WINSOCK_DLL)]
public static extern int WSALookupServiceBegin(byte[] querySet, int flags, ref int lookupHandle);
[DllImport(WINSOCK_DLL)]
public static extern int WSALookupServiceNext(int lookupHandle, int flags, ref int bufferLen, byte[] results);
[DllImport(WINSOCK_DLL)]
public static extern int WSALookupServiceEnd(int lookupHndle);
[DllImport(WINSOCK_DLL)]
public static extern int WSASetService(byte[] regInfo, int op, int flags);
[DllImport(WINSOCK_DLL)]
public static extern int WSAGetLastError();
#endregion
#region IoControl
[DllImport(CORE_DLL)]
public static extern bool KernelIoControl(Int32 dwIoControlCode, byte[] lpInBuf, Int32 nInBufSize,
byte[] lpOutBuf, Int32 nOutBufSize, ref Int32 lpBytesReturned);
#endregion
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -