2014-02-20 127 views
-1

我試圖修改我的最終項目的Wiimote白板應用程序。我在編程語言C#中的經驗很少。有人可以幫助我,告訴我這段代碼的含義嗎?

我不知道幾行代碼的意思是什麼: 任何人都可以幫我嗎?

[DllImport("bthprops.cpl", CharSet = CharSet.Auto, SetLastError = true)] 
    static extern IntPtr BluetoothFindFirstDevice(ref BLUETOOTH_DEVICE_SEARCH_PARAMS SearchParams, ref BLUETOOTH_DEVICE_INFO DeviceInfo); 

    [DllImport("bthprops.cpl", CharSet = CharSet.Auto, SetLastError = true)] 
    static extern bool BluetoothFindNextDevice(IntPtr hFind, ref BLUETOOTH_DEVICE_INFO DeviceInfo); 

    [DllImport("bthprops.cpl", CharSet = CharSet.Auto, SetLastError = true)] 
    static extern bool BluetoothFindDeviceClose(IntPtr hFind); 

    [DllImport("bthprops.cpl", CharSet = CharSet.Auto, SetLastError = true)] 
    static extern uint BluetoothSetServiceState(IntPtr hRadio, ref BLUETOOTH_DEVICE_INFO DeviceInfo, ref Guid guid, int ServiceFlags); 

    [DllImport("bthprops.cpl", CharSet = CharSet.Auto, SetLastError = true)] 
    static extern uint BluetoothRemoveDevice(ref BLUETOOTH_ADDRESS Address); 

我非常感謝您是否願意幫助我。
我在找一個掌握了C#編程語言的人來指導我在這個項目中。
我希望有人願意幫助我。
我很抱歉我的英文很薄弱。

+2

[MSDN](http://msdn.microsoft.com/en-us/library/e59b22c5.aspx) –

+0

非常感謝! 我現在知道,這是用來從bthprops.cpl中調用方法的。 但是我想知道每個代碼的目的是什麼,我希望你願意幫助我。 –

+0

http://msdn.microsoft.com/en-us/library/windows/desktop/aa362927(v=vs.85).aspx – JosephHirn

回答

0

您已經顯示的這些語句是從DLL導入函數入口點。這些函數入口點都是「C」語言調用。這種情況下的DLL被稱爲:「bthprops.cpl」。這是Windows的藍牙控制面板控制。

在每種情況下,該語句都指定了DLL的名稱,後面跟着函數簽名的聲明。例如:

static extern IntPtr BluetoothFindFirstDevice(ref BLUETOOTH_DEVICE_SEARCH_PARAMS SearchParams, ref BLUETOOTH_DEVICE_INFO DeviceInfo); 

這些DLLImport語句的影響是該函數現在可以在C#應用程序中調用。在這種情況下,它是一個函數,允許您開始迭代所有藍牙設備。

+0

謝謝彼得的解釋。 所以第一種方法啓動迭代藍牙設備。 ,第二個找到下一個藍牙設備。 第三個關閉迭代過程。 按照BLUETOOTH_DEVICE_INFO中的描述發現藍牙設備時是否停止迭代過程,或枚舉所有藍牙設備? 第四個代碼做了什麼?我很抱歉我的英語非常虛弱。 –

+0

你可以在這裏找到關於這些函數的所有細節:http://msdn.microsoft.com/en-us/library/windows/desktop/aa362927(v=vs.85).aspx –

相關問題