难道delphi搞不定活动桌面吗?(100分)

  • 主题发起人 主题发起人 友美子
  • 开始时间 开始时间

友美子

Unregistered / Unconfirmed
GUEST, unregistred user!
难道delphi搞不定活动桌面吗?
我要求:1、检查活动桌面是否打开或关闭
2、激活或关闭活动桌面
我查了资料,有人说delphi搞不定,有人说用注册表,但我发现机子不同注册表项也不同,比如我win98机子的关闭是03,打开是43,而论坛有的帖子说23,63或21,61
现在,我查到一篇文章是vc的,介绍的很详细,不知有人可否翻译为delphi
网址是http://www.vckbase.com/vckbase/vckbase10/vc/nonctrls/atlcomocx_02/1002001.htm
里面还有-下载本文例子代码
可惜我对com和vc不懂
 
说delphi搞不定的人是傻B
 
作者:hubdog
获得墙纸
procedure TForm1.Button1Click(Sender: TObject);
var
ADeskTop:IActiveDesktop;
wallpaper:PwideChar;
begin
ADeskTop:=CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
GetMem(wallpaper,128);
ADeskTop.GetWallpaper(wallpaper,128,0);
ShowMessage(string(wallpaper));
FreeMem(wallpaper);
end;
设置墙纸
procedure TForm1.Button1Click(Sender: TObject);
var
ADeskTop:IActiveDesktop;
wallpaper:PwideChar;
begin
ADeskTop:=CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
wallpaper:='d:/2.bmp';
ADeskTop.SetWallpaper(wallpaper,0);
ADeskTop.ApplyChanges(AD_APPLY_ALL);
end;
获得桌面主题数
procedure TForm1.Button1Click(Sender: TObject);
var
adesktop:IActiveDesktop;
Count:integer;
begin
adesktop:=createcomobject(clsid_activedesktop) as IActivedesktop;
adesktop.GetDesktopItemCount(Count,0);
ShowMessage(IntToStr(Count));
end;
???????????????????????????
adesktop:=createcomobject(clsid_activedesktop) as IActivedesktop;
Acomponent.dwsize:=SizeOf(TShcomponent);
OleCheck(adesktop.GetDesktopItem(1,acomponent,0));
 
前辈:我要求:1、检查活动桌面是否打开或关闭
2、激活、关闭活动桌面
我不会..........
 
问题:几个关于活动桌面的问题 ( 积分:100, 回复:9, 阅读:100 )
分类:系统相关 ( 版主:luyear, zyy04 )
来自:jackyzhao, 时间:2000-7-2 15:24:00, ID:275181 [显示:小字体 | 大字体]
1.怎样知道用户的计算机中装有活动桌面?
2.怎样判断当前活动桌面是打开的还是关闭的?


来自:akju, 时间:2000-7-27 22:30:00, ID:296161
问题1很容易olecheck(createcomobject(class_iactivedesktop))(classid具体是什么
记不清了,你再查查是什么东西,只要没有异常就是安装了活动桌面)
2、就搞不清了,关键是iactivedesktop接口的好多方法用delphi调用会出错,
tmd到exex问过也没人知道,用VC到是肯定可以,简直有点莫名其妙。
 
uses shlobj,comobj;
{ 打开/关闭活动桌面 }
function SetActiveDesktop(const b: Boolean): integer;
var
Desktop: IActiveDesktop;
Info: TComponentsOpt;
begin

DeskTop := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
Result := GetLastError;
info.dwSize := sizeof(info);
info.fActiveDesktop := b;
info.fEnableComponents := false;
Desktop.SetDesktopItemOptions(info, 0);
DeskTop.ApplyChanges(AD_APPLY_ALL);
end;

uses
ComObj, ShlObj, ActiveX;
{ 允许/关闭活动桌面 }
procedure EnableActiveDesktop(bValue: Boolean);
const
CLSID_ActiveDesktop: TGUID = (D1: $75048700;
D2: $EF1F;
D3: $11D0;
D4: ($98, $88, $00, $60, $97, $DE, $AC, $F9));
var
MyObject: IUnknown;
ActiveDesk: IActiveDesktop;
twpoComponentOpt: TComponentsOpt;
begin

MyObject := CreateComObject(CLSID_ActiveDesktop);
ActiveDesk := MyObject as IActiveDesktop;
with twpoComponentOptdo

begin

ZeroMemory(@twpoComponentOpt, SizeOf(TComponentsOpt));
dwSize := SizeOf(twpoComponentOpt);
fEnableComponents := bValue;
// fActiveDesktop := True;
end;

ActiveDesk.SetDesktopItemOptions(twpoComponentOpt, 0);
ActiveDesk.ApplyChanges(AD_APPLY_ALL);
end;

{ 设置活动桌面墙纸 }
function SetActiveDesktopWallpaper(FileName: string): integer;
var
Desktop: IActiveDesktop;
Temp: WideString;
begin

DeskTop := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
Result := GetLastError;
Temp := FileName;
Desktop.SetWallpaper(PWideChar(Temp), 0);
DeskTop.ApplyChanges(AD_APPLY_ALL);
end;

{ 判断活动桌面是否存在 }
function ActiveDesktop : Boolean;
begin

Result := FindWindowEx(FindWindowEx(FindWindowEx(
GetDesktopWindow, 0, 'Progman', nil), 0,
'SHELLDLL_DefView', nil), 0, 'Internet Explorer_Server',
nil) <> 0;
end;
 
uses
ComObj, ShlObj, ActiveX;
{--------------------------------------------------------------------------}
{测试活动桌面是否有效}
function IsActiveDeskTopOn: Boolean;
var
h: HWND;
begin
h := FindWindow('Progman', nil);
h := FindWindowEx(h, 0, 'SHELLDLL_DefView', nil);
h := FindWindowEx(h, 0, 'Internet Explorer_Server', nil);
Result := h <> 0;
end;

{--------------------------------------------------------------------------}
{测试活动桌面是否有效,没有试验成功}
function IsActiveDesktopEnable: Boolean;
const
CLSID_ActiveDesktop: TGUID = '{75048700-EF1F-11D0-9888-006097DEACF9}';
var
ActiveDesk: IActiveDesktop;
ComponentsOpt: TComponentsOpt;
hr: HRESULT;
dwReserved: DWORD;
begin
ZeroMemory(@ComponentsOpt, SizeOf(TComponentsOpt));
ComponentsOpt.dwSize := SizeOf(TComponentsOpt);
hr := CoCreateInstance(CLSID_ActiveDesktop, nil, CLSCTX_INPROC_SERVER,
CLSID_ActiveDesktop, ActiveDesk);
if SUCCEEDED(hr) then
begin
hr := ActiveDesk.GetDesktopItemOptions(ComponentsOpt, dwReserved);
// ActiveDesk._Release;
end;
Result := ComponentsOpt.fActiveDesktop;
end;

{--------------------------------------------------------------------------}
{激活活动桌面}
procedure TForm1.Button1Click(Sender: TObject);
const
CLSID_ActiveDesktop: TGUID = '{75048700-EF1F-11D0-9888-006097DEACF9}';
var
ActiveDesk: IActiveDesktop;
ComponentsOpt: TComponentsOpt;
begin
ActiveDesk := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
with ActiveDeskdo
begin
ComponentsOpt.dwSize := SizeOf(ComponentsOpt);
GetDesktopItemOptions(ComponentsOpt, 0);
ComponentsOpt.fActiveDesktop := True;
SetDesktopItemOptions(ComponentsOpt, 0);
ApplyChanges(AD_APPLY_ALL);
end;
end;


uses
ComObj, ShlObj, ActiveX;
procedure EnableActiveDesktop(bValue: Boolean);
const
CLSID_ActiveDesktop: TGUID = (D1: $75048700;
D2: $EF1F;
D3: $11D0;
D4: ($98, $88, $00, $60, $97, $DE, $AC, $F9));
var
MyObject: IUnknown;
ActiveDesk: IActiveDesktop;
twpoComponentOpt: TComponentsOpt;
begin
MyObject := CreateComObject(CLSID_ActiveDesktop);
ActiveDesk := MyObject as IActiveDesktop;
with twpoComponentOptdo
begin
ZeroMemory(@twpoComponentOpt, SizeOf(TComponentsOpt));
dwSize := SizeOf(twpoComponentOpt);
{这块有点小问题,原来下面的注释掉了,但是不起作用,后来去掉了注释,可以了,
但是两个的区别,暂时不知道}
fEnableComponents := bValue;
fActiveDesktop := bValue;
end;
ActiveDesk.SetDesktopItemOptions(twpoComponentOpt, 0);
ActiveDesk.ApplyChanges(AD_APPLY_ALL);
end;
 
good 看到了delphi的风采,可惜我的水平太低......
 
后退
顶部