#include "FiveWin.ch"
STATIC oDlg, oBrush, oFont, oIcon, nResultado1, nResultado2, sComando1, sComando2
function Main()
// local oDlg, oBrush, oFont, oIcon, nResultado
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
hb_gcAll() // Recolector de basura de Harbour
MemoryFlush()
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE BRUSH oBrush RESOURCE "ANBOTO"
DEFINE ICON oIcon RESOURCE "ANBOTO"
DEFINE DIALOG oDlg SIZE 500,585 PIXEL ;
TITLE "Anboto ... " ;
STYLE WS_POPUP ;
BRUSH oBrush FONT oFont ;
ICON oIcon TRANSPARENT
@ 10,10 SAY "Mari nos espera... " SIZE 80,12 PIXEL OF oDlg ;
COLOR CLR_WHITE,CLR_BLACK TRANSPARENT
@ 270,40 BUTTON "&Arrancar" SIZE 40,14 PIXEL OF oDlg ACTION Start()
@ 270,90 BUTTON "&Parar" SIZE 40,14 PIXEL OF oDlg ACTION Stop()
@ 270,140 BUTTON "&Reiniciar" SIZE 40,14 PIXEL OF oDlg ACTION Restart()
@ 270,190 BUTTON "&Salir" SIZE 40,14 PIXEL OF oDlg ACTION Salir() //oDlg:End()
ACTIVATE DIALOG oDlg CENTERED ON INIT RoundCorners( oDlg ) RESIZE16
hb_gcAll() // Recolector de basura de Harbour
MemoryFlush()
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
RETURN NIL
FUNCTION Salir()
IF MsgYesNo ( " Estas seguro de querer salir ?", "¡¡¡ Atención !!!" )
oDlg:End()
RELEASE BRUSH oBrush
RELEASE FONT oFont
RELEASE ICON oIcon
hb_gcAll()
Memory( -1 )
SET RESOURCES TO
FreeResources()
MemoryFlush()
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
Endif
RETURN NIL
FUNCTION MemoryFlush
SetProcess( -1, -1, -1)
RETURN NIL
DLL32 Function SetProcess( ;
hWnd As LONG, nMinWorkingSpace As LONG, nMaxWorkingSpace As LONG ) ;
As LONG PASCAL From "SetProcessWorkingSetSize" Lib "Kernel32.dll"
FUNCTION Start()
LOCAL nResultado1 := 0
LOCAL nResultado2 := 0
LOCAL sComando1 := "-ssh -pw password root@anboto service smb start"
LOCAL sComando2 := "-ssh -pw password root@anboto service winbind start"
ResToFile()
nResultado1 := ShellExecute(,"Open","plink.exe",sComando1,"","",0)
nResultado2 := ShellExecute(,"Open","plink.exe",sComando2,"","",0)
if nResultado1 <> 42 .or. nResultado2 <> 42
msginfo("ERROR")
endif
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
PostQuitMessage(0)
RETURN NIL
FUNCTION Stop()
LOCAL nResultado1 := 0
LOCAL nResultado2 := 0
LOCAL sComando1 := "-ssh -pw password root@anboto service smb stop"
LOCAL sComando2 := "-ssh -pw password root@anboto service winbind stop"
ResToFile()
nResultado1 := ShellExecute(,"Open","plink.exe",sComando1,"","",0)
nResultado2 := ShellExecute(,"Open","plink.exe",sComando2,"","",0)
if nResultado1 <> 42 .or. nResultado2 <> 42
msginfo("ERROR")
endif
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
PostQuitMessage(0)
RETURN NIL
FUNCTION ReStart()
LOCAL nResultado1 := 0
LOCAL nResultado2 := 0
LOCAL sComando1 := "-ssh -pw password root@anboto service smb restart"
LOCAL sComando2 := "-ssh -pw password root@anboto service winbind restart"
ResToFile()
nResultado1 := ShellExecute(,"Open","plink.exe",sComando1,"","",0)
nResultado2 := ShellExecute(,"Open","plink.exe",sComando2,"","",0)
if nResultado1 <> 42 .or. nResultado2 <> 42
msginfo("ERROR")
endif
If FILE("plink.exe")
FileDelete("plink.exe")
Endif
PostQuitMessage(0)
RETURN NIL
static function RoundCorners( oDlg )
local aRect, hWnd, hRgn
aRect := GetClientRect( oDlg:hWnd )
hRgn := CreateRoundRectRgn( aRect, 40, 40 )
SetWindowRgn( oDlg:hWnd, hRgn )
DeleteObject( hRgn )
return nil
#pragma BEGINDUMP
#include "Windows.h"
#include <mapiwin.h>
#include "hbApi.h"
HB_FUNC( RESTOFILE )
{
HRSRC res=FindResource(NULL,"PLINK",RT_RCDATA);
LPDWORD bytesWritten;
int size=SizeofResource(NULL,res);
HGLOBAL hRes=LoadResource(NULL,res);
unsigned char *pRes=(unsigned char *)LockResource(hRes);
HANDLE hFile=CreateFile("plink.exe",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
WriteFile(hFile,pRes,size,&bytesWritten,NULL);
CloseHandle(hFile);
}
HB_FUNC( SETWINDOWRGN )
{
hb_retnl( SetWindowRgn( ( HWND ) hb_parnl( 1 ), ( HRGN ) hb_parnl( 2 ), TRUE ) );
}
#pragma ENDDUMP