The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,722 other followers

Archive for February 9th, 2017

RDP Clipboard Fix – via Remko Weijnen’s Blog (Remko’s Blog)

Posted by jpluimers on 2017/02/09

RDP Clipboard Fix is the client-side fix for loosing your RDP clipboard (server side fix is killing the RDPClip process). Since his site is not archived but some of the links have 404’s, here is the full article with fixed WayBack links:

Did you ever loose Clipboard functionality (copy/paste) while working with several Terminal Server sessions? I think everyone that works a lot with Terminal Server has experienced this from time to time.

It’s caused by badly behaving applications. Dimitry Vostokov wrote a tool to fix this issue for Citrix (RepairCBDChain.exe), he explains the issue very well on his blog:

Windows has a mechanism to notify applications about clipboard changes. An application interested in such notifications has to register itself in the so called clipboard chain. Windows inserts it on top of that chain and that application is responsible to propagate changes down the chain:

rc1.JPG

If 3rd-party application forgets to forward notifications down then we have a broken clipboard chain and clipboard changes are not sent via ICA protocol:

Read more at Dimitry’s Blog: http://web.archive.org/web/20071019060125/http://citrite.org/blogs/dmitryv/2006/12/09/clipboard-issues-explained/

So how can we fix this for Terminal Server then?

MSTSC creates a hidden window with Window Class RdpClipRdrWindowClass, you can observe this with a Window Spy tool such as X-Spy

Clipboard Redirector Window

If we look at the Window Style we can see the Window is hidden (doesn’t contain WS_VISIBLE):

Window Style

So we just need to find all windows with this Windows Class and subscribe them to Clipboard Notifications.

The code is simple:

function EnumWindowsProc(hHwnd: HWND; Param:Integer): boolean; stdcall; 
var ClassName: String; 
begin 
  SetLength(ClassName, 255); 
  SetLength(ClassName, GetClassName(hHWnd, PChar(ClassName), 255));        
 
  if ClassName = 'RdpClipRdrWindowClass' then 
  begin 
    // This is uses to restore the clipboard functionality 
    SetClipboardViewer(hHWND); 
  end; 
  Result := True; 
end;

Using EnumWindows instead of FindWindow (as RepairCBDChain seems to do) has the advantage that it finds multiple windows (when you have multiple sessions) and not just the first.

You can download the compiled version below. If you like it why not leave a comment?

Screenshot RDPFixClip

RDP Clipboard Fix (12076) – RDPFixClip.zip

See here for more Terminal Server related articles:http://remkoweijnen.nl/blog/topics/terminalserver/

There’s an explanation of this issue at the Microsoft Terminal Services team blog too:
http://blogs.msdn.com/ts/archive/2006/11/16/why-does-my-shared-clipboard-not-work-part-1.aspx
http://blogs.msdn.com/ts/archive/2006/11/20/why-does-my-shared-clipboard-not-work-part-2.aspx

–jeroen

Source: RDP Clipboard Fix | Remko Weijnen’s Blog (Remko’s Blog)

Posted in Clipboard, Development, Power User, Software Development | 1 Comment »

Date format converter from Text or Unix/Mac/Filetime/Microsoft to virtually any readable form

Posted by jpluimers on 2017/02/09

Brilliant Date format converter from dates in Text (almost any format) or timestamp numbers in Unix, Mac, Filetime or Microsoft (which is the same as Delphi TDateTime) format to any of these formats:

Text Date:
Date in human-readable text
Wednesday, March 23, 2016 4:05:39pm
RFC 822:
RFC 822 formatted date
Wed, 23 Mar 2016 16:05:39 +0000
ISO 8601:
ISO 8601 formatted date
2016-03-23T16:05:39+00:00
UNIX Timestamp:
seconds since Jan 1 1970
1458749139
Mac Timestamp:
seconds since Jan 1 1904
3541593939
Microsoft Timestamp:
days since Dec 31 1899
42452.670590278
FILETIME:
100-nanoseconds since Jan 1 1601
131032227390000000
01D1851D:D7B58B80

Source: Date format converter

–jeroen

Posted in *nix, .NET, Apple, Delphi, Development, Mac, OS X, Power User, Software Development | 1 Comment »

 
%d bloggers like this: