简体   繁体   English

如何以编程方式将小工具安装到用户的桌面?

[英]How can I install a gadget to a user's desktop programmatically?

Is is possible to install a gadget to a user's desktop somehow? 是否可以以某种方式将小工具安装到用户的桌面? I believe I need to copy all the files to a the user's gadget folder, eg 我相信我需要将所有文件复制到用户的小工具文件夹,例如

C:\Users\curusername\AppData\Local\Microsoft\Windows Sidebar\Gadgets\test.gadget

But copying the files here doesn't run the gadget. 但是,在此处复制文件不会运行小工具。 How can I register/activate it? 我如何注册/激活它?

Is it enough to shell execute test.gadget? shell执行test.gadget是否足够?

Late answer, I know, but the other answer is talking about Windows Sideshow Gadgets, and your question is related to Windows Desktop Gadgets. 我知道,迟到的答案,但另一个答案是谈论Windows Sideshow小工具,你的问题与Windows桌面小工具有关。

It's possible to run the gadget on Windows 7 without shell executing the archive, you need to use the IDesktopGadget interface method RunGadget . 可以在Windows 7上运行小工具而无需shell执行存档,您需要使用IDesktopGadget接口方法RunGadget Call RunGadget on a folder containing your gadget's files and it will appear on the user's desktop. 在包含小工具文件的文件夹上调用RunGadget ,它将显示在用户的桌面上。

A description of the RunGadget method and sample code for C++ is offered here: 此处提供了RunGadget方法和C ++示例代码的说明:

http://msdn.microsoft.com/en-us/library/dd378390(VS.85).aspx http://msdn.microsoft.com/en-us/library/dd378390(VS.85).aspx

If you're using .NET, refer to a previous question I asked for how to implement the IDesktopGadget interface: 如果您使用的是.NET,请参阅我之前询问过如何实现IDesktopGadget接口的问题:

Stack Overflow - C#: Referencing a windows shell interface 堆栈溢出 - C#:引用Windows shell界面

For backwards compatibility (Vista), I would recommend you fall back to the shell execute method. 为了向后兼容(Vista),我建议你回到shell执行方法。

The following MSDN Article covers this: 以下MSDN文章涵盖了这一点:

http://msdn.microsoft.com/en-us/library/cc982277(VS.85).aspx http://msdn.microsoft.com/en-us/library/cc982277(VS.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM