2011-01-27 5 views
0

Windows CEでWIFIを無効/有効にするためのサンプルコードがあります。Windows CEサンプルコードを実行しているエラー

The name 'Utilities' does not exist in the current context

は、なぜ私はこのエラーを取得しています:

[DllImport("coredll.dll", SetLastError = true)] 
private static extern int SetDevicePower(string pvDevice, int dwDeviceFlags, DevicePowerState DeviceState); 

private enum DevicePowerState : int 
{ 
    Unspecified = -1, 
    D0 = 0, // Full On: full power, full functionality 
    D1, // Low Power On: fully functional at low power/performance 
    D2, // Standby: partially powered with automatic wake 
    D3, // Sleep: partially powered with device initiated wake 
    D4, // Off: unpowered 
} 

private const int POWER_NAME = 0x00000001; 

public Form1() 
{ 
    InitializeComponent(); 
} 

//Utilities.WiFi.FindDriverKey() is simply a function that returns the whole registry key name 
//of the key containing the NDIS MINIPORT class GUID defined in he SDK’s pm.h: 

private void button1_Click(object sender, EventArgs e) 
{ 
    string driver = Utilities.WiFi.FindDriverKey(); 
    SetDevicePower(driver, POWER_NAME, DevicePowerState.D0); 
} 


private void button2_Click(object sender, EventArgs e) 
{ 

    string driver = Utilities.WiFi.FindDriverKey(); 
    SetDevicePower(driver, POWER_NAME, DevicePowerState.D4); 
} 


private static string FindDriverKey() 
{ 
    string ret = string.Empty; 

    //#define PMCLASS_NDIS_MINIPORT   TEXT("{98C5250D-C29A-4985-AE5F-AFE5367E5006}") 
    //(From "c:\Program Files (x86)\Windows Mobile 6 SDK\PocketPC\Include\Armv4i\pm.h") 
    string WiFiDriverClass = "{98C5250D-C29A-4985-AE5F-AFE5367E5006}"; 

    foreach (string tmp in Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Power\\State", false).GetValueNames()) 
    { 
     if (tmp.Contains(WiFiDriverClass)) 
     { 
      ret = tmp; 
      break; 
     } 
    } 

    return ret; 
} 

はしかし、私はこのエラーを取得しますか?

答えて

2

これはおそらくFindDriverKey()Utilitiesクラスまたは名前空間にあったからです。ちょうどFindDriverKey()への呼び出しの前にUtilities.Wifiを落とすと、あなたはすべて設定されるべきです。あるいは、ユーティリティの名前空間を作成し、Wifiという静的クラスを作成し、FindDriverKey()関数をWifiクラスの中にドロップすることもできます。

関連する問題