RDP-Manager

RDP-Manager

Postby Otto » Tue Feb 07, 2012 8:38 am

To all,

Image

Mr. Rao and I made an easy RDP-Manager.
All rdp-files are stored in the directory c:\RDP. The Program uses the directory() function and shows all the files in a xBrowse.
You can select any RDP-connection you want.

If there are more rdp-files for the same IP you have to add User and Password to the rdp-file.
Password is encrypted with the tool rdp.exe.

Author: Remko Weijnen (http://www.remkoweijnen.nl)
How to Encrypt:
Type in a password in the Password box and click Encrypt it.

Edit Rdp-file with Notepad and add the 2 lines
username:s:xyz
password 51:b: here put the key

Advantage: RDP-Connections are only opend once – and you can close all the connection with a single click

Best regards,
Otto

Code: Select all  Expand view


#include 'fivewin.ch'
#include 'xbrowse.ch'

#define SW_RESTORE    9
#define GW_CHILD      5
#define GW_HWNDNEXT   2

REQUEST DBFCDX

#DEFINE ROWSPACE  25

function Main()

   local oDlg, oFont, oBrw, nLen
   local aPrompts    := {}

   AEval( Directory( "C:\RDP\*.RDP" ), { |a| AAdd( aPrompts, cFileNoExt( a[ 1 ] ) ) } )
   AAdd( aPrompts, "Close All" )
   nLen     := Len( aPrompts )


   DEFINE FONT oFont    NAME "Segoe UI Light"   SIZE 0, -26

   DEFINE DIALOG oDlg TITLE "RDT - Manager"  PIXEL SIZE 570,400 FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      COLUMNS 1 ARRAY aPrompts ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nDataStrAligns      := AL_CENTER
      :lHeader             := .f.
      :lVScroll            := .f.
      :lHScroll            := .f.
      :lRecordSelector     := .f.
      :nStretchCol         := 1

      WITH OBJECT :aCols[ 1 ]
         :bClrStd          := { || If( oBrw:nArrayAt == nLen, { CLR_WHITE, CLR_HRED }, { CLR_BLACK, CLR_WHITE } ) }
         :bLDClickData     := { || If( oBrw:nArrayAt == nLen, oDlg:End(), start_rdp( oBrw:aRow ) ) }
      END

      :bLClicked           := :aCols[ 1 ]:bLDClickData
      :bKeyDown            := { |nKey| If( nKey == VK_RETURN, Eval( oBrw:aCols[ 1 ]:bLDClickData ), nil ) }

      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED ON INIT ( BrwFitHeight( oBrw ), oBrw:SetFocus(), .f. ) ;
      VALID CloseAll( aPrompts )

return nil

//----------------------------------------------------------------------------//

static function BrwFitHeight( oBrw )

   local oDlg     := oBrw:oWnd
   local h, dy

   h              := Len( oBrw:aArrayData ) * oBrw:nRowHeight + 2
   oBrw:nBottomMargin   := nil
   dy             := ( h - oBrw:DataRect:nHeight )
   oBrw:nHeight   += dy
   oDlg:nHeight   += dy
   oDlg:Center()

return nil

//----------------------------------------------------------------------------//

function start_rdp(cRdt)

    local hWnd  := 0
    local cFileNoExt := ""

    hWnd := FindWnd( cRdt ) // is the window title

    if hWnd == nil
       winexec("mstsc.exe c:\rdp\" + cRdt  +".rdp")
    else
       if IsIconic( hWnd )
           ShowWindow( hWnd, SW_RESTORE )
       endif
       SetFocus( hWnd )

       SetForeGroundWindow( hWnd )
    endif


return nil
//----------------------------------------------------------------------------//

function FindWnd( cTitle )
   local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD )

   while hWnd != 0

      if Upper( cTitle ) $ left(Upper( GetWindowText( hWnd ) ),len(cTitle) )
         return hWnd
      endif

      hWnd = GetWindow( hWnd, GW_HWNDNEXT )
   end


return nil
//----------------------------------------------------------------------------//

static function CloseAll( aWnd )

   local n, hWnd

   CursorWait()
   for n := 1 to Len( aWnd ) - 1
      if ! Empty( hWnd := FindWnd( aWnd[ n ] ) )
         PostMessage( hWnd, WM_CLOSE )
         SysWait( .1 )
      endif
   next
   SysWait( .2 )
   CursorArrow()

return .t.

//----------------------------------------------------------------------------//



********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6331
Joined: Fri Oct 07, 2005 7:07 pm

Re: RDP-Manager

Postby Antonio Linares » Tue Feb 07, 2012 11:30 am

Otto, Rao,

Thanks for sharing it! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42087
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests