这是我查找的相关资料··是用C#写的,哪位高手帮忙翻成delphi的,感谢啊!使用了WMI ( Windows Management Instrumentation ) 和 MQL ( Management Query Lanagauge)得到系统的信息。主要的文件是:System.management.dll读取当前会话的用户名的程序:private void Read_Shared_Folder() { int cnt = 0; try { // MQL for Shaer Information ManagementObjectSearcher searcher = new ManagementObjectSearcher("root//CIMV2","SELECT * FROM Win32_Share"); foreach (ManagementObject queryObj in searcher.Get()) { RDirPath = queryObj["Path"].ToString(); if (!RDirPath.Equals("") || RDirPath.Equals("IPC$") || RDirPath.Equals("ADMIN$") ) { File_Watcher(RDirPath); } load_Shared_Item(cnt, queryObj["Name"].ToString(), queryObj["Path"].ToString(), queryObj["Description"].ToString(), queryObj["Status"].ToString() ); cnt=cnt+1; } }catch (ManagementException e) { MessageBox.Show("An error occurred while querying for WMI data: " + e.Message); } } 读取当前会话的用户名的程序: private void Read_Current_Session() { int counter = 0; int ActiveTime; int itime; string sharename; try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root//CIMV2", "SELECT * FROM Win32_ServerConnection"); ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("root//CIMV2", "SELECT * FROM Win32_ServerSession"); // Read the object foreach (ManagementObject ServerQobj in searcher2.Get()) { RemoteOS = ServerQobj["ClientType"].ToString(); IDealTime = ServerQobj["IdleTime"].ToString(); itime = Int32.Parse(IDealTime) / 60; IDealTime = itime.ToString(); } foreach (ManagementObject queryObj in searcher.Get()) { RemoteIPAddress = queryObj["ComputerName"].ToString(); RemoteUserName = queryObj["UserName"].ToString(); RemoteActiveTime = queryObj["ActiveTime"].ToString(); ActiveTime = (Int32.Parse(RemoteActiveTime)) / 60; RemoteActiveTime = ActiveTime.ToString(); sharename = queryObj["ShareName"].ToString(); if (!sharename.Equals("IPC$")) { Load_Current_Session(counter, RemoteIPAddress, RemoteUserName, RemoteActiveTime,IDealTime,RemoteOS); load_Access_folder(counter, RemoteUserName, sharename); counter += 1; } } } catch (ManagementException e) { MessageBox.Show("An error occurred while querying for WMI data: " + e.Message); } }