Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: TTaskBar and remote application


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 14 - Last Post: Nov 2, 2017 9:51 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Tomas Krejzek

Posts: 8
Registered: 1/22/04
TTaskBar and remote application  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2015 3:01 AM
Hello,

I add TTaskBar component to our application. It works fine - it shows progress correctly.

But one of our customers using application as a remote application - app is installed on the server, and they run MS terminal services client that automaticaly run only app.
It works fine untill I add the TaskBar.

Now it raises an error - Could not initialize taskbar : Error -2147467263

Can I do something to correct it - some setup of component?? Or I have to detect the remote start of app??

Thanks a lot,
Tomas

Edited by: Tomas Krejzek on Mar 29, 2015 3:02 AM
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2015 7:49 PM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas wrote:

Now it raises an error - Could not initialize taskbar :
Error -2147467263

TTaskBar is a wrapper for the ITaskbarList3 interface, which was introduced
in Windows 7. The error code you have shown is E_NOTIMPL, which means TTaskBar
was not able to create an instance of ITaskbarList3 because it is not supported
by Windows. Is your customer running Vista or XP (if not earlier)?

Can I do something to correct it - some setup of component??

If you are using XE6 or earlier, TTaskBar can only be used on Windows 7 and
later, otherwise it crashes when created (see QC #124644). To work around
that bug, instead of creating the TTaskBar at design-time, you could create
it dynamically at runtime after checking the OS version first, eg:

class TForm1 : public TForm
{
//...
private:
    TTaskBar *TaskBar;
//...
};
 
__fastcall TForm1::TForm1(TComponent *Owner)
    : TForm(Owner)
{
    if (CheckWin32Version(6, 1))
        TaskBar = new TTaskBar(this);
}


That bug was fixed in XE7.

The alternative is to simply stop using TTaskBar altogether and just use
the ITaskbarList3 interface directly instead, then you can do your own error
checking with it, eg:

class TForm1 : public TForm
{
//...
private:
    ITaskBarList3 *TaskBar;
//...
};
 
const UINT uiTaskbarButtonCreated = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
 
__fastcall TForm1::~TForm1()
{
    if (TaskBar) TaskBar->Release();
}
 
void __fastcall TForm1::WndProc(TMessage &Message)
{
    TForm::WndProc(Message);
 
    if ((Message.Msg != uiTaskbarButtonCreated) || (uiTaskbarButtonCreated 
== 0) || (TaskBar))
        return;
 
    if (SUCCEEDED(CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, 
IID_ITaskbarList3, (void**)&TaskBar)))
    {
        if (FAILED(TaskBar->HrInit()))
        {
            TaskBar->Release();
            TaskBar = NULL;
        }
    }
}


Either way, you would have to update the rest of your code to check if TaskBar
is not NULL before accessing it.

Or I have to detect the remote start of app??

This is not a remoting issue.

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2015 1:18 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Dear Remy, thank you for you replay.

Remy Lebeau (TeamB) wrote:
Tomas wrote:

Now it raises an error - Could not initialize taskbar :
Error -2147467263

TTaskBar is a wrapper for the ITaskbarList3 interface, which was introduced
in Windows 7. The error code you have shown is E_NOTIMPL, which means TTaskBar
was not able to create an instance of ITaskbarList3 because it is not supported
by Windows. Is your customer running Vista or XP (if not earlier)?

I tested it on WinXP and it run without any problem - of course task bar did not work.

I'm using Builder XE7 - so it should be repaired. I checked updates, but none available.


Can I do something to correct it - some setup of component??

If you are using XE6 or earlier, TTaskBar can only be used on Windows 7 and
later, otherwise it crashes when created (see QC #124644). To work around
that bug, instead of creating the TTaskBar at design-time, you could create
it dynamically at runtime after checking the OS version first, eg:

Yes, I think this is the way that I will go, I will create it dynamically. No problem with NULL value - I have only one place in prg. where I manipulate with this object.

best regards to all,

Tom
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2015 7:31 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Hello,

I test the situation - when I run the application on local computer, win xp, win 7, win 8, win 2008 server - it works fine. On win 7 and win 8 I can see the progress on task bar. On the others not - but no errors.

When I run it as remote application (Win 2008 server) - it raises an error everywhere - on win xp, win 7.

I think the problem is, that taskbar component should control the taskbar on local system, but when I run it as remote application - local taskbar is not accessible for application

I resolve this like Remy said. I remove it from designer, and create it dynamically - there I can enclose it in try-catch block.

Thanks all,

Tomas
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2015 12:10 PM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas wrote:

When I run it as remote application (Win 2008 server) - it raises
an error everywhere - on win xp, win 7.

What are the actual errors? And when do the errors occur? Only when creating
the component? Or on specific operations with the component?

I think the problem is, that taskbar component should control the
taskbar on local system, but when I run it as remote application -
local taskbar is not accessible for application

That is not how it works. It controls the taskbar on the PC that the app
is physically running on.

When you say "run it as a remote app", what does that actually mean? Are
you putting the .exe file on a UNC share of a server PC and then executing
it locally on remote PCs via that UNC share? Or are you using remoting technology,
like Remote Desktop or VNC, to run the app on the remote server PC itself
and then "view" it on the local PCs? Those are very different scenarios.

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 6:31 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi Remy


What are the actual errors? And when do the errors occur? Only when creating
the component? Or on specific operations with the component?

If I put the component to main form in designer - it raises the error on application start -> so application cannot start
When I create it dynamically - it raises error when I try to create it, but now it has no effect - I have there a try - catch block, so I only set TTaskbar variable to NULL and my function which is used to manipulate with task bar has first command

if (task_bar == NULL) {
return;
}

And it is OK

When you say "run it as a remote app", what does that actually mean? Are
you putting the .exe file on a UNC share of a server PC and then executing
it locally on remote PCs via that UNC share? Or are you using remoting technology,
like Remote Desktop or VNC, to run the app on the remote server PC itself
and then "view" it on the local PCs? Those are very different scenarios.

We create remote application msi in terminal services centre in windows. It using RDP. It works like remote desktop, but all you can see from desktop is application you prepare. The application running on server, and to client are sent application screens only. I can see application icon on task bar, but with rdp icon on it. MSI install application into - Start -> All programs -> Remote applications.
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 10:53 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas wrote:

If I put the component to main form in designer - it raises the error
on application start -> so application cannot start

When I create it dynamically - it raises error when I try to create it

Looking at the TTaskBar implementation again, I see that it is successfully
creating the ITaskBarList object, but the ITaskbarList.HrInit() method is
failing with E_NOTIMPL. Embarcadero is not checking for that condition.
I have created a QualityPortal ticket for you:

TTaskBar "Could not initialize taskbar" exception on Windows 2008 Server
over RDP
https://quality.embarcadero.com/browse/RSP-10260

The application running on server, and to client are sent application
screens only.

Then the app is going to interact with the Taskbar of the remote PC, not
the Taskbar of the local PCs. If the remote PC is running a version of Windows
that does not support ITaskbarList3, the component fails.

Also, take note of this warning in the documentation:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460.aspx

Note When an application displays a window, its taskbar button is created
by the system. When the button is in place, the taskbar sends a TaskbarButtonCreated
message to the window. Its value is computed by calling RegisterWindowMessage(L"TaskbarButtonCreated").
That message must be received by your application before it calls any ITaskbarList3
method.

The component cannot monitor that message, but you can update your TForm
to create the component in its WndProc() method when that message is caught.

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 6:01 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Hi All

I'm so sorry but the problem is back again.
When I moved to Builder XE10 and create first build it start raising new error. The error is Could not initialize TaskBar. Error: -2147467263.

The same like in previous case, but now I can't catch it using try catch

In Builder XE7 i have

try {
TaskBarButton = new TTaskbar(this);
} catch (Exception &e) {
TaskBarButton = NULL;
}

And it works, when it cannot create - it raises exception and I set it to NULL

But in XE10, new works correctly, but method Initialize() raises an error - I tried to add call of this method to try -> catch but it did not help, catch did not catch it and error occures

Do you know some correct way to detect possibility to use TaskBar??

Best regards, Tomas
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 11:04 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas Krejzek wrote:

When I moved to Builder XE10 and create first build it start raising
new error. The error is Could not initialize TaskBar. Error:
-2147467263.

That error code is E_NOTIMPL, which means TTaskbar is trying to access
something that is not available.

That particular error text is from the SInitializeException resource
string in the System.RTLConsts unit. There is only one place in
TTaskbar's source code where that error message is raised - in the
TWinTaskbar constructor (which is called by the TTaskbar constructor),
if the TWinTaskbar.HrInit() method (which calls the
ITaskbarList.HrInit() interface method) fails.

There are only two reasons I know of that can cause
ITaskbarList::HrInit() to return E_NOTIMPL:

1. if the Taskbar is not ready yet before you create the TTaskbar
object. Per MSDN documentation, you MUST wait for your window to
receive the "TaskbarCreated" notification message before you can then
call the ITaskbarList::HrInit() method:

Taskbar Creation Notification
https://msdn.microsoft.com/en-us/library/windows/desktop/cc144179.aspx#Taskbar_Creation_Not

However, ITaskbarList3 (which is what TTaskbar uses) has an additional
requirement that you must wait until you receive the
"TaskbarButtonCreated" notification message before any ITaskbarList3
interface methods can be called:

ITaskbarList3 interface
https://msdn.microsoft.com/en-us/library/windows/desktop/dd391692.aspx

2. your app is being acessed over RDP. TTaskbar does not work over RDP:

TTaskBar "Could not initialize taskbar" exception on Windows 2008
Server over RDP
https://quality.embarcadero.com/browse/RSP-10260

} catch (Exception &e) {

You should always catch by 'const' reference.

But in XE10, new works correctly but method Initialize() raises an
error

The error you mention can only be raised by the TTaskbar constructor.
The Initialize() method does not do anything that could raise any
exceptions (except maybe a "Could not register tab" exception).

I tried to add call of this method to try -> catch but it did
not help, catch did not catch it and error occures

That is because Initialize() does not throw an exception into your
code, so there is nothing to catch.

Do you know some correct way to detect possibility to use TaskBar??

Personally, I find TTaskbar to be a POS that never works correctly, so
I never use it. I always use the Win32 API ITaskbarList... interfaces
directly instead. I never have any problems with them. I can't fathom
why Embarcadero can't get TTaskbar right, these are not complicated
interfaces to use, but I think they have overcomplicate TTaskbar's
implementation.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2015 12:05 PM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas wrote:

I tested it on WinXP and it run without any problem - of course
task bar did not work.

I'm using Builder XE7

With all updates installed?

so it should be repaired. I checked updates, but none available.

There have been updates since XE7 was first released. Do you have them all?

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 6:33 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I'm using Embarcadero® C++Builder XE7 Version 21.0.17707.5020

When I find group in start menu a run application - Check for updates - it shows message - No updates available - so I think I have the last available version
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 10:03 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas wrote:

When I find group in start menu a run application - Check for
updates - it shows message - No updates available

That does not always work. Best to check the Registered User Downloads section
of your EDN account.

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2017 2:16 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
SORRY I FOUND IT - not ITaskBarList3 - BUT ITaskbarList :-(

Thank you Remy,

please would you be so kind and tell me what I need to include to work directly with - ITaskBarList3
I tried to include #include "Shobjidl.h" in which I found declaration of ITaskBarList3

But it can not compile it - it raises an error that type name expected

Thank you in advance, Tom

header file:
#ifndef taskbarfH
#define taskbarfH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include "Shobjidl.h"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TProgressBar *ProgressBar1;
TButton *Button1;
TTimer *Timer1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Timer1Timer(TObject *Sender);
private: // User declarations
ITaskBarList3 *TaskBar;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Edited by: Tomas Krejzek on Nov 2, 2017 2:30 AM
Remy Lebeau (Te...


Posts: 8,839
Registered: 12/23/01
Re: TTaskBar and remote application [Edit] [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2017 9:51 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
Tomas Krejzek wrote:

please would you be so kind and tell me what I need to include to
work directly with - ITaskBarList3 I tried to include #include
"Shobjidl.h" in which I found declaration of ITaskBarList3

But it can not compile it - it raises an error that type name expected

The correct name is ITaskbarList3 (lowercase b), not ITaskBarList3
(uppercase B). C++ is case-sensitive.

--
Remy Lebeau (TeamB)
Tomas Krejzek

Posts: 8
Registered: 1/22/04
Re: TTaskBar and remote application  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 9:16 AM   in response to: Tomas Krejzek in response to: Tomas Krejzek
After moving application from XE7 to XE10 the problem is back.
Instead of the fact that I now creating the TaskBar button dynamically according to advice.
I did not do any change of source code nor project properties.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02