[問題] windows service使用shell32獲得網卡狀態的問題
小弟在windows form中, 使用shell32可成功取得網路卡是否被啟用
但是放在windows service中執行這個function時服務就會停止
請問是甚麼情況使得這樣操作會出問題, 該如何解決呢? 謝謝.
function如下, 傳入參數item="啟用"
private bool Check_NetworkCard_Status(string item)
{
bool bflag = false;
Shell32.Shell shell = new Shell32.ShellClass();
Shell32.Folder folder = shell.NameSpace(49);
foreach (Shell32.FolderItem fi in folder.Items())
{
Shell32.ShellFolderItem folderItem = (Shell32.ShellFolderItem)fi;
foreach (Shell32.FolderItemVerb fiv in folderItem.Verbs())
{
if (!fiv.Name.Contains(item))
continue;
else
{
bflag = true;
break;
}
}
}
return bflag;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.177.40
推
04/26 23:29, , 1F
04/26 23:29, 1F