不要使用 Windows 方法检测 Skype 是否处于“紧凑视图”或“默认视图”,而是尝试阅读配置文件文件存储这些类型的设置并由 Skype“实时”更新。该文件位于
%AppData%\Skype\<your-skype-user-name>
例如在 Windows 7 中,这是位置
C:\Users\<your windows user>\AppData\Roaming\Skype\<your-skype-user-name>
该文件内部存在一个名为MultiWindowMode
这是 Xpath 的位置MultiWindowMode
/config/UI/General/MultiWindowMode'
对于“紧凑视图”,该条目的值为“1”;对于“默认视图”,该条目的值为“0”
检查这个演示,它使用 XPath 解析文件并读取MultiWindowMode
.
{$APPTYPE CONSOLE}
uses
ComObj,
ActiveX,
Variants,
SysUtils;
function SkypeISCompactView(const SettingsFile : string) : Boolean;
var
XmlDoc : OleVariant;
Node : OleVariant;
begin
Result:=False;
if FileExists(SettingsFile) then
begin
XmlDoc := CreateOleObject('Msxml2.DOMDocument.6.0');
try
XmlDoc.Async := False;
XmlDoc.Load(SettingsFile);
XmlDoc.SetProperty('SelectionLanguage','XPath');
if (XmlDoc.parseError.errorCode <> 0) then
raise Exception.CreateFmt('Error in Xml Data %s',[XmlDoc.parseError]);
Node :=XmlDoc.selectSingleNode('/config/UI/General/MultiWindowMode');
if not VarIsClear(Node) then
Result:=Node.text='1';
finally
XmlDoc:=Unassigned;
end;
end;
end;
begin
try
CoInitialize(nil);
try
Writeln(BoolToStr(SkypeISCompactView('C:\Users\<your windows user>\AppData\Roaming\Skype\<skype user>\config.xml'),True));
except
on E:Exception do
begin
Writeln(E.Classname, ':', E.Message);
end;
end;
finally
CoUninitialize;
end;
Readln;
end.