Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetCurrentProcessExplicitAppUserModelID Cause two icons in Win7

379 views
Skip to first unread message

Breath

unread,
Aug 25, 2009, 5:09:01 AM8/25/09
to
In windows7,

For a normal app, such as a.exe, When drag a.exe from explorer to taskbar, a
shortcut to a.exe created.
Double click a.exe in explorer, the taskbar icon shown right( only one icon
shown in task bar).

For a special app, such as b.exe.
I add SetCurrentProcessExplicitAppUserModelID( L"my.test" ); in app's init
function.

When drag b.exe from explorer to taskbar, a shortcut to b.exe created.
Double click b.exe in explorer, the taskbar icon shown wrong( there are two
icon shown in task bar, one is the shortcut, other is the app window).

Could anyone tell me how to fix the issue?

Jim Barry

unread,
Aug 25, 2009, 8:59:34 AM8/25/09
to
"Breath" wrote:
> For a special app, such as b.exe.
> I add SetCurrentProcessExplicitAppUserModelID( L"my.test" ); in app's init
> function.
>
> When drag b.exe from explorer to taskbar, a shortcut to b.exe created.
> Double click b.exe in explorer, the taskbar icon shown wrong( there are
> two
> icon shown in task bar, one is the shortcut, other is the app window).

The shortcut needs to have the System.AppUserModel.ID property. That's OK if
the shortcut is created by the software itself (e.g. during installation)
but not so good if it's the user who creates the shortcut.

--
Jim Barry, Microsoft MVP

Breath

unread,
Aug 27, 2009, 2:03:01 AM8/27/09
to
Thank you Jim Barry, but I do the same action with windows notepad.exe or
iexplorer.exe, they are all right.

Jim Barry

unread,
Aug 27, 2009, 6:03:18 AM8/27/09
to
"Breath" wrote:
> Thank you Jim Barry, but I do the same action with windows notepad.exe or
> iexplorer.exe, they are all right.

Well yes, I expect that's because they don't call
SetCurrentProcessExplicitAppUserModelID, so they get the default
system-assigned AppUserModelID.

Breath

unread,
Aug 27, 2009, 8:26:01 AM8/27/09
to
I use this function, because of I want to support jumplist.
IE support jumplist, so I guess there are some description in iexplore.exe's
resource, when win7 create a shortcut for the exe, it read the description
and assign right id.

But I didn't find them.

Jim Barry

unread,
Aug 27, 2009, 12:43:13 PM8/27/09
to
"Breath" wrote:
> I use this function, because of I want to support jumplist.

I don't think it's necessary to have an explicit AppUserModelID in order to
support Jump Lists. You can simply not call SetAppID, right?

Breath

unread,
Aug 28, 2009, 2:21:01 AM8/28/09
to
I use custom jumplist.
Code here:
BOOL SetUpJumpList()
{
HRESULT hr;
ICustomDestinationList * pDestList = NULL;

// Create a jump list COM object.
hr = CoCreateInstance( CLSID_DestinationList, NULL,
CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void **)&pDestList );

if ( SUCCEEDED(hr) && pDestList )
{
if( SUCCEEDED(pDestList->SetAppID ( _pwszAppTaskID )) )
{
UINT cMaxSlots;
IObjectArray * pRemovedItems = NULL ;

hr = pDestList->BeginList( &cMaxSlots, IID_PPV_ARGS(&pRemovedItems) );

if( SUCCEEDED(hr) && pRemovedItems )
{

// Create an object collection to hold the custom tasks.
IObjectCollection * pObjColl = NULL;
hr = CoCreateInstance( CLSID_EnumerableObjectCollection, NULL,
CLSCTX_INPROC_SERVER, IID_IObjectCollection, (void**)&pObjColl );

if ( SUCCEEDED(hr) && pObjColl )
{
AddJumpListTasks( pObjColl );

// Get an IObjectArray interface for AddUserTasks.
IObjectArray * pTasksArray = NULL;
pObjColl->QueryInterface( IID_IObjectArray, (void **)&pTasksArray );

if( pTasksArray )
{
hr = pDestList->AddUserTasks ( pTasksArray );
pDestList->CommitList();
pTasksArray->Release();
}

pObjColl->Release();
}

pRemovedItems->Release();
}
}
pDestList->Release();
}

return SUCCEEDED(hr);
}

I need call this: pDestList->SetAppID
Does I mis-understand something?

Jim Barry

unread,
Aug 28, 2009, 7:02:22 AM8/28/09
to
"Breath" wrote:
> I need call this: pDestList->SetAppID
> Does I mis-understand something?

Yes - see the remarks section of the ICustomDestinationList::SetAppID
documentation, where it says:

"Some applications will not declare an explicit AppUserModelID and should
not call this method."

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

Atti

unread,
Sep 28, 2009, 9:17:01 AM9/28/09
to
Hey, I've tried your code to add items to the 'Tasks' category, but I'm
failing somewhere. If your code works, then I didn't add the items correctly.
Here is my code:

IShellLink *link;
hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, reinterpret_cast<void**>(&link) );

if (SUCCEEDED(hr))
{
link->SetDescription(L"Calculator");
link->SetPath(L"calc.exe");

pObjColl->AddObject(link);
}

Thanks

0 new messages