2009-07-29 17 views

回答

3

我相信唯一的方法就是調用Win32 shell函數GetProfileType。您需要使用P/Invoke進行呼叫,然後檢查PT_ROAMING(其值爲2)的pdwFlags參數的輸出值。

我沒有看到關於pinvoke.net此功能,但這樣一個簡單的簽名樣本簽名:

BOOL WINAPI GetProfileType(  
    DWORD *pdwFlags 
); 

創建一個不會很難。

+0

@Bubbafat:具有漫遊配置文件的用戶在默認情況下沒有安裝權限是真的嗎?那麼如何設置這些權限呢? – gneash 2009-07-29 14:24:21

1
[DllImport("Userenv.dll", EntryPoint = "GetProfileType", SetLastError = true, CharSet = CharSet.Auto)] 
    public static extern bool GetProfileType(ref uint pdwflags); 

    [Flags] 
    enum Win32ProfileType : uint { 
     Local=0x00, 
     Temporary=0x01, 
     Roaming=0x02, 
     Mandatory=0x04 
    } 


    public void SomeTest() 
    { 
     uint type = 0; 
     if (GetProfileType(ref type)) { 
      //todo 
     } 
    } 
相關問題