简体   繁体   中英

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?

Late answer, I know, but the other answer is talking about Windows Sideshow Gadgets, and your question is related to Windows Desktop Gadgets.

It's possible to run the gadget on Windows 7 without shell executing the archive, you need to use the IDesktopGadget interface method RunGadget . Call RunGadget on a folder containing your gadget's files and it will appear on the user's desktop.

A description of the RunGadget method and sample code for C++ is offered here:

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:

Stack Overflow - C#: Referencing a windows shell interface

For backwards compatibility (Vista), I would recommend you fall back to the shell execute method.

The following MSDN Article covers this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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