• 0

Using API's in a <object>::<action> format?


Question

I'm using .net, and I've been reading about some windows features on Microsofts site, how do I made use of stuff in a format like this:

  Microsoft said:
APIs:

ITaskbarList3::SetProgressState

ITaskbarList3::SetProgressValue

Do I need to add a reference or something? Is it part of Windows API?

NOTE: This is a Windows 7 Feature

Link to comment
https://www.neowin.net/forum/topic/716968-using-apis-in-a-objectaction-format/
Share on other sites

6 answers to this question

Recommended Posts

  • 0

The :: operator is not used in VB.NET to access namespace of type members. In VB.NET, along with C#, use the following:

ITaskbarList3.SetProgressState

, you also need to make sure you reference whatever libraries are required

  • 0

Ideally, you should wait for it to be officially added, but simply put ITaskbarList3 is a COM interface exposed by Explorer. SetProgressValue is a method of this interface. If you have the Windows 7 Beta SDK, it's defined in ShObjIdl.idl. You can rip the relevant parts out and put it in your own IDL. You then compile that with the MIDL compiler (midl /tlb tl.tlb tl.idl) and then convert that type library to an assembly with Tlbimp (tlbimp tl.tlb /out:TaskbarLib.dll). Finally, you add that assembly as a reference in your project.

Here is an example I did just now (note that I make no guarantees about the correctness of this code, and I would not use it in production code without careful auditing first):

[
   uuid(683BF642-E9CA-4124-BE43-67065B2FA653),
   version(1.0),
]
library TaskbarLib
{
[
	uuid(56FDF342-FD6D-11d0-958A-006097C9A090),
	object,
]
interface ITaskbarList : IUnknown 
{
	HRESULT _stdcall HrInit();

	HRESULT _stdcall AddTab([in] long hwnd);

	HRESULT _stdcall DeleteTab([in] long hwnd);

	HRESULT _stdcall ActivateTab([in] long hwnd);

	HRESULT _stdcall SetActivateAlt([in] long hwnd);
};

[
	uuid(602D4995-B13A-429b-A66E-1935E44F4317),
	object,
]
interface ITaskbarList2 : ITaskbarList
{
	HRESULT MarkFullscreenWindow(
		[in] long hwnd,
		[in] BOOL fFullscreen);
}

cpp_quote("#ifdef MIDL_PASS")
typedef IUnknown* HIMAGELIST;
typedef IUNknown* HICON;
cpp_quote("#endif")

cpp_quote("#include &lt;pshpack8.h&gt;")
typedef struct tagTHUMBBUTTON
{
	DWORD   dwMask;
	UINT	iId;
	UINT	iBitmap;
	HICON   hIcon;
	WCHAR   szTip[260];
	DWORD   dwFlags;
} THUMBBUTTON, *LPTHUMBBUTTON;
cpp_quote("#include &lt;poppack.h&gt;")

[
	uuid(ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf),
	object,
]
interface ITaskbarList3 : ITaskbarList2
{
	// Flags for Setting Taskbar Progress state
	typedef [v1_enum] enum TBPFLAG
	{
		TBPF_NOPROGRESS	 = 0x00000000,
		TBPF_INDETERMINATE  = 0x00000001,
		TBPF_NORMAL		 = 0x00000002,
		TBPF_ERROR		  = 0x00000004,
		TBPF_PAUSED		 = 0x00000008,
	} TBPFLAG;

	cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG)")

	// Flags for SetTabActive
	typedef [v1_enum] enum TBATFLAG
	{
		TBATF_USEMDITHUMBNAIL   = 0x00000001,
		TBATF_USEMDILIVEPREVIEW = 0x00000002,
	} TBATFLAG;

	cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBATFLAG)")

	HRESULT SetProgressValue(
		[in] long hwnd,
		[in] ULONGLONG ullCompleted,
		[in] ULONGLONG ullTotal);

	HRESULT SetProgressState(
		[in] long hwnd,
		[in] TBPFLAG tbpFlags);

	HRESULT RegisterTab(
		[in] long hwndTab,
		[in] HWND hwndMDI);

	HRESULT UnregisterTab(
		[in] long hwndTab);

	HRESULT SetTabOrder(
		[in] long hwndTab,
		[in] long hwndInsertBefore);

	HRESULT SetTabActive(
		[in] long hwndTab,
		[in] long hwndMDI,
		[in] TBATFLAG tbatFlags);

	HRESULT ThumbBarAddButtons(
		[in] long hwnd,
		[in] UINT cButtons,
		[in, size_is(cButtons)] LPTHUMBBUTTON pButton);

	HRESULT ThumbBarUpdateButtons(
		[in] long hwnd,
		[in] UINT cButtons,
		[in, size_is(cButtons)] LPTHUMBBUTTON pButton);

	HRESULT ThumbBarSetImageList(
		[in] long hwnd,
		[in] HIMAGELIST himl);

	HRESULT SetOverlayIcon(
		[in] long hwnd, 
		[in] HICON hIcon,
		[in, string] LPCWSTR pszDescription);

	HRESULT SetThumbnailTooltip(
		[in] long hwnd, 
		[in, string] LPCWSTR pszTip);

	HRESULT SetThumbnailClip(
		[in] long hwnd, 
		[in] RECT *prcClip);
}

[ uuid(56FDF344-FD6D-11d0-958A-006097C9A090) ] coclass TaskbarList { interface ITaskbarList3; }
};

To use it, you would do something like

using TaskbarLib;

TaskbarList tl3 = new TaskbarList();
tl3.HrInit();
tl3.SetProgressValue((int)this.Handle, 50, 100);

I've included the version I compiled as an attachment, but remember that it comes with no warranties of any kind.

TaskbarLib.zipFetching info...

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I don't usually complain about articles here, but this is just ridiculous, you couldn't ask your precious AI to write something about tech instead? This literally has nothing to do with tech.
    • Microsoft's "Athena" AI: A blueprint for your own dev team's productivity boost by Paul Hill Last month, Microsoft made many developer-oriented announcements at its annual BUILD conference. One of the tools that it announced at the time was called Athena, an artificial intelligence agent that lives in Microsoft Teams and aims to speed up product development processes. Now, however, Microsoft has released the blueprint of Athena so anyone can begin implementing a similar helper for their work. Rather than just another chatbot, Athena is a deeply integrated agent accessible through Teams that helps to connect people, tools, and data throughout the product development process. Athena is smart enough to work out what needs to happen next and helps team members get it done without having to go to different applications - Athena controls it all from Teams and you just have to communicate in natural language. Athena can be embedded in several developer workflows including Teams, Azure DevOps, and GitHub. Perhaps the greatest thing about Athena is that it’s not a new product being sold by Microsoft, but rather a methodology and open-source template (Dex) that organizations or individuals can take to build their own AI agents, allowing for more customization. To get started with Athena, you'll want to set up the Dex agent. Microsoft has also published a breakout session video about Athena so you can take a deeper dive. Who it affects, and how The primary beneficiaries of Microsoft’s decision to release Athena open source are engineering teams everywhere who will be freed from boring, repetitive tasks such as pull request (PR) reviews, work item management, and security checks. This will let them get on with coding new features and innovating - something that Microsoft has been pushing hard for since the start of the latest AI revolution. For product managers and engineering leaders, Athena also looks set to be incredibly useful as they will get better real-time visibility into the status of projects, if a release is truly ready for launch, and to ensure the team is aligned. Organizations from small to large will be able to benefit from using Athena. Due to its open-source nature, Athena can be tailored to meet specific development processes. This could unlock faster delivery cycles and improve code quality across the board. Why it's happening Athena is already being used internally at Microsoft by over 2,000 of its engineers. The Redmond giant explained that this has led to “measurable gains” in speed, quality, and focus. Aside from faster review cycles for developers, Athena is also surfacing release-blocking bugs earlier, enabling the consistent completion of security and privacy workflows, and providing quicker health assessments so that teams can gauge the overall health of their software delivery. By handling all these more boring tasks, Athena can free up developers to build more features into their projects. It also has the potential to speed up delivery times so that end users can use the new software faster, and with potentially less bugs. We often hear the term “democratization” in tech, a process that makes technologies more accessible and affordable. According to this definition, Microsoft’s release of Athena delivers on democratizing AI for developers as its open source and allows people to integrate AI Into their workflows, without starting from scratch. The move also aligns with Microsoft's AI strategy, that is, putting it all throughout its products. Copilot is probably the most notorious for its omnipresence in essentially every Microsoft product including Windows and Edge. Unlike Copilot, developers get a bit more freedom with Athena, but it’s still tied up with Microsoft products, namely Teams and GitHub. Caveats and what to watch for While it’s great that Microsoft is making its Athena blueprint accessible, one issue is that developers may still find it a bit complex to implement as there are still specific customizations organizations will want to make. Additionally, this solution involves a more involved setup process as outlined in the GitHub README. Another thing organizations should be wary about is data privacy and security implications when it comes to integrating with sensitive internal systems. Organizations that are working on secretive projects probably wouldn’t want to use Athena as this could put sensitive code in the hands of third parties. It’s not only technical issues that need considering either, there is also the human element. Some people may have concerns about AI hallucinating or ethical concerns around job security that could hurt adoption. To this end, Microsoft has reaffirmed that Athena is supposed to assist teams only, not replace team members. While Athena can be extremely useful, as shown by the results internally at Microsoft, human oversight and judgment will still be vital. Complex decision and creative problem-solving in development are some areas where a human still needs to be involved. Source: Microsoft
    • How could it not be optional? ChatGPT isn't going to guess people's credentials :P
    • Mmmm, spread too thin into 2 quite different things
  • Recent Achievements

    • First Post
      James courage Tabla earned a badge
      First Post
    • Reacting Well
      James courage Tabla earned a badge
      Reacting Well
    • Apprentice
      DarkShrunken went up a rank
      Apprentice
    • Dedicated
      CHUNWEI earned a badge
      Dedicated
    • Collaborator
      DarkShrunken earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      382
    2. 2
      +FloatingFatMan
      176
    3. 3
      ATLien_0
      171
    4. 4
      snowy owl
      169
    5. 5
      Xenon
      133
  • Tell a friend

    Love Neowin? Tell a friend!